Skip to content

Commit

Permalink
Remove stored wasm contract in test_data. (cosmos#5149)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim authored Nov 21, 2023
1 parent 595e1a9 commit b5dd876
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
20 changes: 9 additions & 11 deletions modules/light-clients/08-wasm/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package keeper_test

import (
"encoding/hex"
"os"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

wasmtesting "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
)

Expand All @@ -23,14 +23,12 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
{
"success",
func() {
checksum := "9b18dc4aa6a4dc6183f148bdcadbf7d3de2fdc7aac59394f1589b81e77de5e3c" //nolint:gosec // these are not hard-coded credentials
contractCode, err := os.ReadFile("../test_data/ics07_tendermint_cw.wasm.gz")
suite.Require().NoError(err)
checksum := "b3a49b2914f5e6a673215e74325c1d153bb6776e079774e52c5b7e674d9ad3ab" //nolint:gosec // these are not hard-coded credentials

genesisState = *types.NewGenesisState(
[]types.Contract{
{
CodeBytes: contractCode,
CodeBytes: wasmtesting.Code,
},
},
)
Expand All @@ -49,7 +47,8 @@ func (suite *KeeperTestSuite) TestInitGenesis() {

for _, tc := range testCases {
suite.Run(tc.name, func() {
suite.SetupTest()
suite.SetupWasmWithMockVM()

ctx := suite.chainA.GetContext()
tc.malleate()

Expand All @@ -71,16 +70,15 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
}

func (suite *KeeperTestSuite) TestExportGenesis() {
suite.SetupTest()
suite.SetupWasmWithMockVM()

ctx := suite.chainA.GetContext()

expChecksum := "9b18dc4aa6a4dc6183f148bdcadbf7d3de2fdc7aac59394f1589b81e77de5e3c" //nolint:gosec // these are not hard-coded credentials
expChecksum := "b3a49b2914f5e6a673215e74325c1d153bb6776e079774e52c5b7e674d9ad3ab" //nolint:gosec // these are not hard-coded credentials

signer := authtypes.NewModuleAddress(govtypes.ModuleName).String()
contractCode, err := os.ReadFile("../test_data/ics07_tendermint_cw.wasm.gz")
suite.Require().NoError(err)

msg := types.NewMsgStoreCode(signer, contractCode)
msg := types.NewMsgStoreCode(signer, wasmtesting.Code)
res, err := GetSimApp(suite.chainA).WasmClientKeeper.StoreCode(ctx, msg)
suite.Require().NoError(err)
suite.Require().Equal(expChecksum, hex.EncodeToString(res.Checksum))
Expand Down
2 changes: 0 additions & 2 deletions modules/light-clients/08-wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ func (suite *KeeperTestSuite) SetupWasmWithMockVM() {

suite.coordinator = ibctesting.NewCoordinator(suite.T(), 1)
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1))

_ = storeWasmCode(suite, wasmtesting.Code)
}

func (suite *KeeperTestSuite) setupWasmWithMockVM() (ibctesting.TestingApp, map[string]json.RawMessage) {
Expand Down
3 changes: 3 additions & 0 deletions modules/light-clients/08-wasm/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func (suite *KeeperTestSuite) TestMsgMigrateContract() {
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()

storeWasmCode(suite, wasmtesting.Code)
newChecksum = storeWasmCode(suite, newByteCode)

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
Expand Down Expand Up @@ -385,6 +386,8 @@ func (suite *KeeperTestSuite) TestMsgRemoveChecksum() {
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()

storeWasmCode(suite, wasmtesting.Code)

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
suite.Require().NoError(err)
Expand Down
Binary file not shown.

0 comments on commit b5dd876

Please sign in to comment.