-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: x/clock v2 - permissionless (#893)
* Update Clock Proto * Add Keeper Logic * Update Msg Server, Querier, & Params * Add Tx Cmds * Ensure Sender is Admin * Add Clock CLI Queries, Update Txs * Update Clock Codec * Fix Get All & Manager Check * Update Genesis, Fix Genesis Export * Jail Contract on Error * Pass Clock Interchain Tests (Tests are Incomplete) * Error Check on Jail Contract * Test Msg Server * Test Msg Server with Admin * Test Querier * Test Params * Test Genesis * Update Codec Tests * Fix Msg Tests * Refactor Stores into Singular Store * Lint * Update Tx CLI Desc, More Lint * Update Clock SubCmd Descs * Remove Contracts from Genesis * Refactor Request Validation * Use Logger in EndBlocker * Init EndBlocker Tests * Test Clock End Blocker * Upload Clock Contract (No Sudo) * Add Interchain Clock Helper * Add Clock Interchain Tests * Test Unregister Clock * Update Spec Docs * remove `SetupContractWithAdmin` and instead use extraFlags * wait for 2 blocks in the Clock helpers (ictest thing) * fix: updateParams contractGasLimit * patch e2e no admin flag * Extract Anon Func --------- Co-authored-by: Reece Williams <[email protected]>
- Loading branch information
1 parent
68e08e7
commit 3dadeb5
Showing
50 changed files
with
4,852 additions
and
523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" | ||
"github.com/strangelove-ventures/interchaintest/v7/ibc" | ||
"github.com/strangelove-ventures/interchaintest/v7/testutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// Register the clock contract | ||
func RegisterClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, contract string) { | ||
cmd := []string{ | ||
"junod", "tx", "clock", "register", contract, | ||
"--node", chain.GetRPCAddress(), | ||
"--home", chain.HomeDir(), | ||
"--chain-id", chain.Config().ChainID, | ||
"--fees", "500ujuno", | ||
"--from", user.KeyName(), | ||
"--keyring-dir", chain.HomeDir(), | ||
"--keyring-backend", keyring.BackendTest, | ||
"-y", | ||
} | ||
stdout, _, err := chain.Exec(ctx, cmd, nil) | ||
require.NoError(t, err) | ||
|
||
debugOutput(t, string(stdout)) | ||
|
||
err = testutil.WaitForBlocks(ctx, 2, chain) | ||
require.NoError(t, err) | ||
} | ||
|
||
// Unregister the clock contract | ||
func UnregisterClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, contract string) { | ||
cmd := []string{ | ||
"junod", "tx", "clock", "unregister", contract, | ||
"--node", chain.GetRPCAddress(), | ||
"--home", chain.HomeDir(), | ||
"--chain-id", chain.Config().ChainID, | ||
"--fees", "500ujuno", | ||
"--from", user.KeyName(), | ||
"--keyring-dir", chain.HomeDir(), | ||
"--keyring-backend", keyring.BackendTest, | ||
"-y", | ||
} | ||
stdout, _, err := chain.Exec(ctx, cmd, nil) | ||
require.NoError(t, err) | ||
|
||
debugOutput(t, string(stdout)) | ||
|
||
err = testutil.WaitForBlocks(ctx, 2, chain) | ||
require.NoError(t, err) | ||
} | ||
|
||
// Unjail the clock contract | ||
func UnjailClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, contract string) { | ||
cmd := []string{ | ||
"junod", "tx", "clock", "unjail", contract, | ||
"--node", chain.GetRPCAddress(), | ||
"--home", chain.HomeDir(), | ||
"--chain-id", chain.Config().ChainID, | ||
"--fees", "500ujuno", | ||
"--from", user.KeyName(), | ||
"--keyring-dir", chain.HomeDir(), | ||
"--keyring-backend", keyring.BackendTest, | ||
"-y", | ||
} | ||
stdout, _, err := chain.Exec(ctx, cmd, nil) | ||
require.NoError(t, err) | ||
|
||
debugOutput(t, string(stdout)) | ||
|
||
err = testutil.WaitForBlocks(ctx, 2, chain) | ||
require.NoError(t, err) | ||
} | ||
|
||
type ClockContract struct { | ||
ClockContract struct { | ||
ContractAddress string `json:"contract_address"` | ||
IsJailed bool `json:"is_jailed"` | ||
} `json:"clock_contract"` | ||
} | ||
|
||
// Get the clock contract | ||
func GetClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, contract string) ClockContract { | ||
var res ClockContract | ||
|
||
cmd := getClockQueryCommand(chain, contract) | ||
stdout, _, err := chain.Exec(ctx, cmd, nil) | ||
require.NoError(t, err) | ||
|
||
fmt.Println(string(stdout)) | ||
|
||
if err := json.Unmarshal(stdout, &res); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
return res | ||
} | ||
|
||
// Validate a contract is not registered with the clock module | ||
func ValidateNoClockContract(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, contract string) { | ||
cmd := getClockQueryCommand(chain, contract) | ||
_, _, err := chain.Exec(ctx, cmd, nil) | ||
require.Error(t, err) | ||
} | ||
|
||
// Get the clock query command | ||
func getClockQueryCommand(chain *cosmos.CosmosChain, contract string) []string { | ||
return []string{"junod", "query", "clock", "contract", contract, | ||
"--node", chain.GetRPCAddress(), | ||
"--chain-id", chain.Config().ChainID, | ||
"--output", "json", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
package juno.clock.v1; | ||
|
||
option go_package = "github.com/CosmosContracts/juno/x/clock/types"; | ||
|
||
// This object is used to store the contract address and the | ||
// jail status of the contract. | ||
message ClockContract { | ||
// The address of the contract. | ||
string contract_address = 1; | ||
// The jail status of the contract. | ||
bool is_jailed = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.