Skip to content

Commit

Permalink
execute contract's before and after an upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Feb 5, 2024
1 parent 93635e7 commit c630308
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions interchaintest/chain_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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",
}
)
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions interchaintest/conformance/cosmwasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ 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
err := helpers.SmartQueryString(t, ctx, chain, contractAddr, `{"get_count":{}}`, &res)
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) {
Expand Down

0 comments on commit c630308

Please sign in to comment.