-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Interchaintest] Installment # 2 #165
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2e296d9
chore: add chain_state_test
jim380 cfd8f7a
chore: change numOfValidators to 2
jim380 ecdd35c
fix: custom encoding in cosmwam conformance test
jim380 23bc8d7
refactor: interchaintest setup
jim380 61d5ff6
chore: remove params module
jim380 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ import ( | |
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" | ||
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" | ||
abci "github.com/cometbft/cometbft/abci/types" | ||
tmos "github.com/cometbft/cometbft/libs/os" | ||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types" | ||
dbm "github.com/cosmos/cosmos-db" | ||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/client" | ||
|
@@ -46,6 +46,7 @@ import ( | |
"github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/cosmos-sdk/runtime" | ||
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" | ||
"github.com/cosmos/cosmos-sdk/server" | ||
"github.com/cosmos/cosmos-sdk/server/api" | ||
"github.com/cosmos/cosmos-sdk/server/config" | ||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
|
@@ -59,7 +60,6 @@ import ( | |
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" | ||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" | ||
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" | ||
"github.com/cosmos/cosmos-sdk/x/auth/tx" | ||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" | ||
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
|
@@ -92,6 +92,7 @@ import ( | |
"github.com/cosmos/cosmos-sdk/x/mint" | ||
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" | ||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" | ||
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
"github.com/cosmos/cosmos-sdk/x/slashing" | ||
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" | ||
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" | ||
|
@@ -308,15 +309,16 @@ func NewApp( | |
/* STORE KEYS */ | ||
/* =================================================== */ | ||
keys := storetypes.NewKVStoreKeys( | ||
authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey, | ||
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, | ||
crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, | ||
govtypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, | ||
feegrant.StoreKey, evidencetypes.StoreKey, circuittypes.StoreKey, group.StoreKey, | ||
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, | ||
feegrant.StoreKey, evidencetypes.StoreKey, circuittypes.StoreKey, authzkeeper.StoreKey, group.StoreKey, | ||
capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey, | ||
wasmtypes.StoreKey, icahosttypes.StoreKey, | ||
icacontrollertypes.StoreKey, | ||
) | ||
|
||
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to previous comment - If we don't need params module, we don't need transient store either |
||
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) | ||
|
||
app := &App{ | ||
|
@@ -385,12 +387,12 @@ func NewApp( | |
) | ||
|
||
// optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper) | ||
enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) | ||
txConfigOpts := tx.ConfigOptions{ | ||
enabledSignModes := append(authtx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) | ||
txConfigOpts := authtx.ConfigOptions{ | ||
EnabledSignModes: enabledSignModes, | ||
TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), | ||
} | ||
txConfig, err = tx.NewTxConfigWithOptions( | ||
txConfig, err = authtx.NewTxConfigWithOptions( | ||
appCodec, | ||
txConfigOpts, | ||
) | ||
|
@@ -474,6 +476,7 @@ func NewApp( | |
groupConfig, | ||
) | ||
|
||
// set the governance module account as the authority for conducting upgrades | ||
app.UpgradeKeeper = upgradekeeper.NewKeeper( | ||
skipUpgradeHeights, | ||
runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), | ||
|
@@ -825,6 +828,7 @@ func NewApp( | |
|
||
// initialize stores | ||
app.MountKVStores(keys) | ||
app.MountTransientStores(tkeys) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
app.MountMemoryStores(memKeys) | ||
|
||
// initialize BaseApp | ||
|
@@ -848,10 +852,11 @@ func NewApp( | |
panic(fmt.Errorf("failed to create AnteHandler: %w", err)) | ||
} | ||
|
||
app.SetAnteHandler(anteHandler) | ||
app.SetInitChainer(app.InitChainer) | ||
app.SetPreBlocker(app.PreBlocker) | ||
app.SetBeginBlocker(app.BeginBlocker) | ||
app.SetEndBlocker(app.EndBlocker) | ||
app.SetAnteHandler(anteHandler) | ||
|
||
if manager := app.SnapshotManager(); manager != nil { | ||
err = manager.RegisterExtensions( | ||
|
@@ -862,24 +867,35 @@ func NewApp( | |
} | ||
} | ||
|
||
if loadLatest { | ||
if err := app.LoadLatestVersion(); err != nil { | ||
tmos.Exit(err.Error()) | ||
} | ||
} | ||
|
||
app.ScopedIBCKeeper = scopedIBCKeeper | ||
app.ScopedTransferKeeper = scopedTransferKeeper | ||
app.ScopedWasmKeeper = scopedWasmKeeper | ||
app.ScopedICAHostKeeper = scopedICAHostKeeper | ||
app.ScopedICAControllerKeeper = scopedICAControllerKeeper | ||
|
||
if loadLatest { | ||
if err := app.LoadLatestVersion(); err != nil { | ||
panic(fmt.Errorf("error loading last version: %w", err)) | ||
} | ||
ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) | ||
|
||
// Initialize pinned codes in wasmvm as they are not persisted there | ||
if err := app.WasmKeeper.InitializePinnedCodes(ctx); err != nil { | ||
panic(fmt.Sprintf("failed initialize pinned codes %s", err)) | ||
} | ||
} | ||
|
||
return app | ||
} | ||
|
||
// Name returns the name of the App | ||
func (app *App) Name() string { return app.BaseApp.Name() } | ||
|
||
// PreBlocker application updates every pre block | ||
func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { | ||
return app.mm.PreBlock(ctx) | ||
} | ||
|
||
// BeginBlocker application updates every begin block | ||
func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { | ||
return app.mm.BeginBlock(ctx) | ||
|
@@ -896,8 +912,12 @@ func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci. | |
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { | ||
panic(err) | ||
} | ||
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) | ||
return app.mm.InitGenesis(ctx, app.appCodec, genesisState) | ||
err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
response, err := app.mm.InitGenesis(ctx, app.appCodec, genesisState) | ||
return response, err | ||
} | ||
|
||
// Configurator get app configurator | ||
|
@@ -1004,8 +1024,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig | |
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) | ||
|
||
// Register grpc-gateway routes for all modules. | ||
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) | ||
|
||
app.bmm.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) | ||
// register app's OpenAPI routes. | ||
docs.RegisterOpenAPIService(Name, apiSvr.Router) | ||
} | ||
|
@@ -1017,11 +1036,12 @@ func (app *App) RegisterTxService(clientCtx client.Context) { | |
|
||
// RegisterTendermintService implements the Application.RegisterTendermintService method. | ||
func (app *App) RegisterTendermintService(clientCtx client.Context) { | ||
cmtApp := server.NewCometABCIWrapper(app) | ||
cmtservice.RegisterTendermintService( | ||
clientCtx, | ||
app.BaseApp.GRPCQueryRouter(), | ||
app.interfaceRegistry, | ||
app.Query, | ||
cmtApp.Query, | ||
) | ||
} | ||
|
||
|
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,39 @@ | ||
package interchaintest | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/sedaprotocol/seda-chain/interchaintest/conformance" | ||
"github.com/strangelove-ventures/interchaintest/v8" | ||
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestChainStart(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip() | ||
} | ||
|
||
t.Parallel() | ||
|
||
numOfValidators := 2 | ||
numOfFullNodes := 0 | ||
|
||
chains := CreateChains(t, numOfValidators, numOfFullNodes) | ||
ic, ctx, _, _ := BuildAll(t, chains) | ||
|
||
chain := chains[0].(*cosmos.CosmosChain) | ||
|
||
const userFunds = int64(10_000_000_000) | ||
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain) | ||
chainUser := users[0] | ||
|
||
conformance.ConformanceCosmWasm(t, ctx, chain, chainUser) | ||
|
||
require.NotNil(t, ic) | ||
require.NotNil(t, ctx) | ||
|
||
t.Cleanup(func() { | ||
_ = ic.Close() | ||
}) | ||
} |
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,28 @@ | ||
package conformance | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/sedaprotocol/seda-chain/interchaintest/helpers" | ||
"github.com/sedaprotocol/seda-chain/interchaintest/types" | ||
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" | ||
"github.com/strangelove-ventures/interchaintest/v8/ibc" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// ConformanceCosmWasm validates that store, instantiate, execute, and query work on a CosmWasm contract. | ||
func ConformanceCosmWasm(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet) { | ||
basic(t, ctx, chain, user) | ||
} | ||
|
||
func basic(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet) { | ||
_, contractAddr := helpers.SetupAndInstantiateContract(t, ctx, chain, user.KeyName(), "contracts/cw_template.wasm", `{"count":0}`) | ||
helpers.ExecuteMsgWithFee(t, ctx, chain, user, contractAddr, "", "10000"+chain.Config().Denom, `{"increment":{}}`) | ||
|
||
var res types.GetCountResponse | ||
err := helpers.SmartQueryString(t, ctx, chain, contractAddr, `{"get_count":{}}`, &res) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, int64(1), res.Data.Count) | ||
} |
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,67 @@ | ||
package interchaintest | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/strangelove-ventures/interchaintest/v8" | ||
"github.com/strangelove-ventures/interchaintest/v8/conformance" | ||
"github.com/strangelove-ventures/interchaintest/v8/ibc" | ||
"github.com/strangelove-ventures/interchaintest/v8/testreporter" | ||
"go.uber.org/zap/zaptest" | ||
) | ||
|
||
/* TestConformance tests the followings: | ||
* - Client, channel, and connection creation | ||
* - Messages are properly relayed and acknowledged | ||
* - Packets are being properly timed out | ||
*/ | ||
func TestConformance(t *testing.T) { | ||
|
||
/* =================================================== */ | ||
/* CHAIN FACTORY */ | ||
/* =================================================== */ | ||
numOfValidators := 1 | ||
numOfFullNodes := 1 | ||
|
||
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ | ||
{ | ||
Name: "seda", | ||
ChainConfig: SedaCfg, | ||
NumValidators: &numOfValidators, // defaults to 2 when unspecified | ||
NumFullNodes: &numOfFullNodes, // defaults to 1 when unspecified | ||
}, | ||
// pre configured chain pulled from | ||
// https://github.com/strangelove-ventures/heighliner | ||
{ | ||
Name: "gaia", | ||
Version: "v14.1.0", | ||
NumValidators: &numOfValidators, | ||
NumFullNodes: &numOfFullNodes, | ||
}, | ||
}) | ||
|
||
/* =================================================== */ | ||
/* RELAYER FACTORY */ | ||
/* =================================================== */ | ||
rlyFactory := interchaintest.NewBuiltinRelayerFactory( | ||
ibc.CosmosRly, | ||
zaptest.NewLogger(t), | ||
) | ||
|
||
hermesFactory := interchaintest.NewBuiltinRelayerFactory( | ||
ibc.Hermes, | ||
zaptest.NewLogger(t), | ||
) | ||
|
||
ctx := context.Background() | ||
|
||
// don't collect test reports | ||
rep := testreporter.NewNopReporter() | ||
|
||
/* | ||
* Test against both chains, ensuring that they both have basic IBC capabilities | ||
* properly implemented and work with both the Go relayer and Hermes | ||
*/ | ||
conformance.Test(t, ctx, []interchaintest.ChainFactory{cf}, []interchaintest.RelayerFactory{rlyFactory, hermesFactory}, rep) | ||
} |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to add
paramstypes.StoreKey