Skip to content
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

tests: nit, move storeWasmCode to be a method on suite. #6166

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (suite *KeeperTestSuite) TestWasmInstantiate() {
tc := tc
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()
checksum := storeWasmCode(suite, wasmtesting.Code)
checksum := suite.storeWasmCode(wasmtesting.Code)

tc.malleate()

Expand Down Expand Up @@ -307,7 +307,7 @@ func (suite *KeeperTestSuite) TestWasmMigrate() {
tc := tc
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()
_ = storeWasmCode(suite, wasmtesting.Code)
_ = suite.storeWasmCode(wasmtesting.Code)

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
Expand Down Expand Up @@ -378,7 +378,7 @@ func (suite *KeeperTestSuite) TestWasmQuery() {
tc := tc
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()
_ = storeWasmCode(suite, wasmtesting.Code)
_ = suite.storeWasmCode(wasmtesting.Code)

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
Expand Down Expand Up @@ -549,7 +549,7 @@ func (suite *KeeperTestSuite) TestWasmSudo() {
tc := tc
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()
_ = storeWasmCode(suite, wasmtesting.Code)
_ = suite.storeWasmCode(wasmtesting.Code)

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/08-wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (suite *KeeperTestSuite) setupWasmWithMockVM() (ibctesting.TestingApp, map[
}

// storeWasmCode stores the wasm code on chain and returns the checksum.
func storeWasmCode(suite *KeeperTestSuite, wasmCode []byte) []byte {
func (suite *KeeperTestSuite) storeWasmCode(wasmCode []byte) []byte {
ctx := suite.chainA.GetContext().WithBlockGasMeter(storetypes.NewInfiniteGasMeter())

msg := types.NewMsgStoreCode(authtypes.NewModuleAddress(govtypes.ModuleName).String(), wasmCode)
Expand Down Expand Up @@ -402,7 +402,7 @@ func (suite *KeeperTestSuite) TestMigrateContract() {
tc := tc
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()
storeWasmCode(suite, wasmtesting.Code)
suite.storeWasmCode(wasmtesting.Code)

var err error
oldHash, err = types.CreateChecksum(wasmtesting.Code)
Expand Down Expand Up @@ -459,7 +459,7 @@ func (suite *KeeperTestSuite) TestGetChecksums() {
"success: default mock vm contract stored.",
func() {
suite.SetupWasmWithMockVM()
storeWasmCode(suite, wasmtesting.Code)
suite.storeWasmCode(wasmtesting.Code)
},
func(checksums []types.Checksum) {
suite.Require().Len(checksums, 1)
Expand All @@ -472,7 +472,7 @@ func (suite *KeeperTestSuite) TestGetChecksums() {
"success: non-empty checksums",
func() {
suite.SetupWasmWithMockVM()
storeWasmCode(suite, wasmtesting.Code)
suite.storeWasmCode(wasmtesting.Code)

err := GetSimApp(suite.chainA).WasmClientKeeper.GetChecksums().Set(suite.chainA.GetContext(), types.Checksum("checksum"))
suite.Require().NoError(err)
Expand All @@ -498,7 +498,7 @@ func (suite *KeeperTestSuite) TestGetChecksums() {

func (suite *KeeperTestSuite) TestAddChecksum() {
suite.SetupWasmWithMockVM()
storeWasmCode(suite, wasmtesting.Code)
suite.storeWasmCode(wasmtesting.Code)

wasmClientKeeper := GetSimApp(suite.chainA).WasmClientKeeper

Expand Down
6 changes: 3 additions & 3 deletions modules/light-clients/08-wasm/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ func (suite *KeeperTestSuite) TestMsgMigrateContract() {
var ok bool
suite.SetupWasmWithMockVM()

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

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
Expand Down Expand Up @@ -397,7 +397,7 @@ func (suite *KeeperTestSuite) TestMsgRemoveChecksum() {
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()

storeWasmCode(suite, wasmtesting.Code)
_ = suite.storeWasmCode(wasmtesting.Code)

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/08-wasm/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (suite *KeeperTestSuite) TestCustomQuery() {
for _, tc := range testCases {
suite.Run(tc.name, func() {
suite.SetupWasmWithMockVM()
_ = storeWasmCode(suite, wasmtesting.Code)
_ = suite.storeWasmCode(wasmtesting.Code)

endpoint := wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
Expand Down Expand Up @@ -305,7 +305,7 @@ func (suite *KeeperTestSuite) TestStargateQuery() {
suite.Run(tc.name, func() {
expDiscardedState = false
suite.SetupWasmWithMockVM()
checksum = storeWasmCode(suite, wasmtesting.Code)
checksum = suite.storeWasmCode(wasmtesting.Code)

endpoint = wasmtesting.NewWasmEndpoint(suite.chainA)
err := endpoint.CreateClient()
Expand Down
Loading