Skip to content

Commit

Permalink
Merge pull request #2022 from CosmWasm/tkulik/refactor
Browse files Browse the repository at this point in the history
chore: Refactor test case
  • Loading branch information
chipshort authored Nov 5, 2024
2 parents 60ed81c + c0a4a60 commit 9a485bf
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions x/wasm/keeper/submsg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,29 +652,6 @@ func TestMigrateGovSubMsgAuthzPropagated(t *testing.T) {

var instanceLevel int
// mock wasvm to return new migrate msgs with the response
mockWasmVM.MigrateWithInfoFn = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, migrateMsg []byte, migrateInfo wasmvmtypes.MigrateInfo, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.ContractResult, uint64, error) {
if instanceLevel == 1 {
return &wasmvmtypes.ContractResult{Ok: &wasmvmtypes.Response{}}, 0, nil
}
instanceLevel++
submsgPayload := fmt.Sprintf(`{"sub":%d}`, instanceLevel)
return &wasmvmtypes.ContractResult{
Ok: &wasmvmtypes.Response{
Messages: []wasmvmtypes.SubMsg{
{
ReplyOn: wasmvmtypes.ReplyNever,
Msg: wasmvmtypes.CosmosMsg{
Wasm: &wasmvmtypes.WasmMsg{Migrate: &wasmvmtypes.MigrateMsg{
ContractAddr: example1.Contract.String(),
NewCodeID: example2.CodeID,
Msg: []byte(submsgPayload),
}},
},
},
},
},
}, 0, nil
}
mockWasmVM.MigrateFn = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, migrateMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.ContractResult, uint64, error) {
if instanceLevel == 1 {
return &wasmvmtypes.ContractResult{Ok: &wasmvmtypes.Response{}}, 0, nil
Expand All @@ -698,6 +675,9 @@ func TestMigrateGovSubMsgAuthzPropagated(t *testing.T) {
},
}, 0, nil
}
mockWasmVM.MigrateWithInfoFn = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, migrateMsg []byte, migrateInfo wasmvmtypes.MigrateInfo, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.ContractResult, uint64, error) {
return mockWasmVM.MigrateFn(codeID, env, migrateMsg, store, goapi, querier, gasMeter, gasLimit, deserCost)
}

specs := map[string]struct {
policy types.AuthorizationPolicy
Expand Down

0 comments on commit 9a485bf

Please sign in to comment.