From c630308c8fb989478a299d9d8791748d987767c9 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Mon, 5 Feb 2024 17:56:44 -0600 Subject: [PATCH] execute contract's before and after an upgrade --- interchaintest/chain_upgrade_test.go | 11 +++++++++-- interchaintest/conformance/cosmwasm.go | 8 +++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/interchaintest/chain_upgrade_test.go b/interchaintest/chain_upgrade_test.go index 49ee1d111..6b073ae2d 100644 --- a/interchaintest/chain_upgrade_test.go +++ b/interchaintest/chain_upgrade_test.go @@ -7,6 +7,7 @@ import ( "time" junoconformance "github.com/CosmosContracts/juno/tests/interchaintest/conformance" + helpers "github.com/CosmosContracts/juno/tests/interchaintest/helpers" cosmosproto "github.com/cosmos/gogoproto/proto" "github.com/docker/docker/client" "github.com/strangelove-ventures/interchaintest/v7" @@ -20,7 +21,7 @@ import ( const ( chainName = "juno" - upgradeName = "v19" + upgradeName = "v20" haltHeightDelta = uint64(9) // will propose upgrade this many blocks in the future blocksAfterUpgrade = uint64(7) @@ -30,7 +31,7 @@ var ( // baseChain is the current version of the chain that will be upgraded from baseChain = ibc.DockerImage{ Repository: JunoMainRepo, - Version: "v18.0.0", + Version: "v19.1.0", UidGid: "1025:1025", } ) @@ -82,6 +83,9 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, upgradeBranchVersion, upgra users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain) chainUser := users[0] + // execute a contract before the upgrade + beforeContract := junoconformance.StdExecute(t, ctx, chain, chainUser) + // upgrade height, err := chain.Height(ctx) require.NoError(t, err, "error fetching height before submit upgrade proposal") @@ -93,6 +97,9 @@ func CosmosChainUpgradeTest(t *testing.T, chainName, upgradeBranchVersion, upgra UpgradeNodes(t, ctx, chain, client, haltHeight, upgradeRepo, upgradeBranchVersion) + // confirm we can execute against the beforeContract (ref: v20 upgrade patch) + helpers.ExecuteMsgWithFee(t, ctx, chain, chainUser, beforeContract, "", "10000"+chain.Config().Denom, `{"increment":{}}`) + // Post Upgrade: Conformance Validation junoconformance.ConformanceCosmWasm(t, ctx, chain, chainUser) // TODO: ibc conformance test diff --git a/interchaintest/conformance/cosmwasm.go b/interchaintest/conformance/cosmwasm.go index 592f990b1..0941f93da 100644 --- a/interchaintest/conformance/cosmwasm.go +++ b/interchaintest/conformance/cosmwasm.go @@ -15,12 +15,12 @@ import ( // 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) { - std(t, ctx, chain, user) + StdExecute(t, ctx, chain, user) subMsg(t, ctx, chain, user) } -func std(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet) { - _, contractAddr := helpers.SetupContract(t, ctx, chain, user.KeyName(), "contracts/cw_template.wasm", `{"count":0}`) +func StdExecute(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet) (contractAddr string) { + _, contractAddr = helpers.SetupContract(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 helpers.GetCountResponse @@ -28,6 +28,8 @@ func std(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc. require.NoError(t, err) require.Equal(t, int64(1), res.Data.Count) + + return contractAddr } func subMsg(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet) {