From ffcfa8dfa0be7d402620324a56b8b8c94272d7cd Mon Sep 17 00:00:00 2001 From: Pino' Surace Date: Mon, 4 Sep 2023 17:01:29 +0200 Subject: [PATCH] Remove Wasmer references --- x/wasm/ibc_integration_test.go | 12 ++-- x/wasm/ibctesting/wasm.go | 2 +- x/wasm/keeper/contract_keeper_test.go | 2 +- x/wasm/keeper/handler_plugin_test.go | 2 +- x/wasm/keeper/keeper.go | 6 +- x/wasm/keeper/keeper_test.go | 22 ++++---- x/wasm/keeper/options.go | 4 +- x/wasm/keeper/options_test.go | 13 +++-- x/wasm/keeper/proposal_integration_test.go | 6 +- x/wasm/keeper/querier_test.go | 2 +- x/wasm/keeper/recurse_test.go | 4 +- x/wasm/keeper/relay_test.go | 12 ++-- x/wasm/keeper/submsg_test.go | 4 +- x/wasm/keeper/test_common.go | 10 ++-- x/wasm/keeper/wasmtesting/mock_engine.go | 66 +++++++++++----------- x/wasm/migrations/v3/store_test.go | 2 +- x/wasm/relay_pingpong_test.go | 4 +- x/wasm/relay_test.go | 22 ++++---- x/wasm/types/wasmer_engine.go | 4 +- 19 files changed, 100 insertions(+), 99 deletions(-) diff --git a/x/wasm/ibc_integration_test.go b/x/wasm/ibc_integration_test.go index 0f3eaa80df..a08d367593 100644 --- a/x/wasm/ibc_integration_test.go +++ b/x/wasm/ibc_integration_test.go @@ -48,7 +48,7 @@ func TestOnChanOpenInitVersion(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContract)), + wasmtesting.NewIBCContractMockWasmEngine(myContract)), } coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) chainA = coordinator.GetChain(wasmibctesting.GetChainID(1)) @@ -100,7 +100,7 @@ func TestOnChanOpenTryVersion(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContract)), + wasmtesting.NewIBCContractMockWasmEngine(myContract)), } coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) chainA = coordinator.GetChain(wasmibctesting.GetChainID(1)) @@ -225,12 +225,12 @@ func TestOnIBCPacketReceive(t *testing.T) { // mock to submit an ibc data package from given chain and capture the ack type captureAckTestContractEngine struct { - *wasmtesting.MockWasmer + *wasmtesting.MockWasmEngine } // NewCaptureAckTestContractEngine constructor func NewCaptureAckTestContractEngine() *captureAckTestContractEngine { - m := wasmtesting.NewIBCContractMockWasmer(&wasmtesting.MockIBCContractCallbacks{ + m := wasmtesting.NewIBCContractMockWasmEngine(&wasmtesting.MockIBCContractCallbacks{ IBCChannelOpenFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelOpenMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBC3ChannelOpenResponse, uint64, error) { return &wasmvmtypes.IBC3ChannelOpenResponse{}, 0, nil }, @@ -245,7 +245,7 @@ func NewCaptureAckTestContractEngine() *captureAckTestContractEngine { func (x *captureAckTestContractEngine) SubmitIBCPacket(t *testing.T, path *wasmibctesting.Path, chainA *wasmibctesting.TestChain, senderContractAddr sdk.AccAddress, packetData []byte) *[]byte { t.Helper() // prepare a bridge to send an ibc packet by an ordinary wasm execute message - x.MockWasmer.ExecuteFn = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { + x.MockWasmEngine.ExecuteFn = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { return &wasmvmtypes.Response{ Messages: []wasmvmtypes.SubMsg{{ID: 1, ReplyOn: wasmvmtypes.ReplyNever, Msg: wasmvmtypes.CosmosMsg{IBC: &wasmvmtypes.IBCMsg{SendPacket: &wasmvmtypes.SendPacketMsg{ ChannelID: path.EndpointA.ChannelID, Data: executeMsg, Timeout: wasmvmtypes.IBCTimeout{Block: &wasmvmtypes.IBCTimeoutBlock{Revision: 1, Height: 10000000}}, @@ -254,7 +254,7 @@ func (x *captureAckTestContractEngine) SubmitIBCPacket(t *testing.T, path *wasmi } // capture acknowledgement var gotAck []byte - x.MockWasmer.IBCPacketAckFn = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { + x.MockWasmEngine.IBCPacketAckFn = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { gotAck = msg.Acknowledgement.Data return &wasmvmtypes.IBCBasicResponse{}, 0, nil } diff --git a/x/wasm/ibctesting/wasm.go b/x/wasm/ibctesting/wasm.go index 3939967ee9..b01611a8b5 100644 --- a/x/wasm/ibctesting/wasm.go +++ b/x/wasm/ibctesting/wasm.go @@ -23,7 +23,7 @@ var wasmIdent = []byte("\x00\x61\x73\x6D") // SeedNewContractInstance stores some wasm code and instantiates a new contract on this chain. // This method can be called to prepare the store with some valid CodeInfo and ContractInfo. The returned -// Address is the contract address for this instance. Test should make use of this data and/or use NewIBCContractMockWasmer +// Address is the contract address for this instance. Test should make use of this data and/or use NewIBCContractMockWasmEngine // for using a contract mock in Go. func (chain *TestChain) SeedNewContractInstance() sdk.AccAddress { pInstResp := chain.StoreCode(append(wasmIdent, rand.Bytes(10)...)) diff --git a/x/wasm/keeper/contract_keeper_test.go b/x/wasm/keeper/contract_keeper_test.go index 37dd1dd86e..e816ac096b 100644 --- a/x/wasm/keeper/contract_keeper_test.go +++ b/x/wasm/keeper/contract_keeper_test.go @@ -22,7 +22,7 @@ func TestInstantiate2(t *testing.T) { example := StoreHackatomExampleContract(t, parentCtx, keepers) otherExample := StoreReflectContract(t, parentCtx, keepers) - mock := &wasmtesting.MockWasmer{} + mock := &wasmtesting.MockWasmEngine{} wasmtesting.MakeInstantiable(mock) keepers.WasmKeeper.wasmVM = mock // set mock to not fail on contract init message diff --git a/x/wasm/keeper/handler_plugin_test.go b/x/wasm/keeper/handler_plugin_test.go index 09661722a5..8d21ed8682 100644 --- a/x/wasm/keeper/handler_plugin_test.go +++ b/x/wasm/keeper/handler_plugin_test.go @@ -387,7 +387,7 @@ func TestBurnCoinMessageHandlerIntegration(t *testing.T) { for name, spec := range specs { t.Run(name, func(t *testing.T) { ctx, _ = parentCtx.CacheContext() - k.wasmVM = &wasmtesting.MockWasmer{ExecuteFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { + k.wasmVM = &wasmtesting.MockWasmEngine{ExecuteFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { return &wasmvmtypes.Response{ Messages: []wasmvmtypes.SubMsg{ {Msg: wasmvmtypes.CosmosMsg{Bank: &wasmvmtypes.BankMsg{Burn: &spec.msg}}, ReplyOn: wasmvmtypes.ReplyNever}, diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index 5c44f3e4ab..f32f7cdef3 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -77,7 +77,7 @@ var defaultAcceptedAccountTypes = map[reflect.Type]struct{}{ reflect.TypeOf(&authtypes.BaseAccount{}): {}, } -// Keeper will have a reference to Wasmer with it's own data directory. +// Keeper will have a reference to Wasm Engine with it's own data directory. type Keeper struct { storeKey storetypes.StoreKey cdc codec.Codec @@ -85,7 +85,7 @@ type Keeper struct { bank CoinTransferrer portKeeper types.PortKeeper capabilityKeeper types.CapabilityKeeper - wasmVM types.WasmerEngine + wasmVM types.WasmEngine wasmVMQueryHandler WasmVMQueryHandler wasmVMResponseHandler WasmVMResponseHandler messenger Messenger @@ -1026,7 +1026,7 @@ func (k Keeper) consumeRuntimeGas(ctx sdk.Context, gas uint64) { ctx.GasMeter().ConsumeGas(consumed, "wasm contract") // throw OutOfGas error if we ran out (got exactly to zero due to better limit enforcing) if ctx.GasMeter().IsOutOfGas() { - panic(sdk.ErrorOutOfGas{Descriptor: "Wasmer function execution"}) + panic(sdk.ErrorOutOfGas{Descriptor: "Wasm engine function execution"}) } } diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index a2d1fae648..5b09153f21 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -711,7 +711,7 @@ func TestInstantiateWithNonExistingCodeID(t *testing.T) { func TestInstantiateWithContractDataResponse(t *testing.T) { ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) - wasmerMock := &wasmtesting.MockWasmer{ + wasmEngineMock := &wasmtesting.MockWasmEngine{ InstantiateFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { return &wasmvmtypes.Response{Data: []byte("my-response-data")}, 0, nil }, @@ -719,7 +719,7 @@ func TestInstantiateWithContractDataResponse(t *testing.T) { StoreCodeFn: wasmtesting.NoOpStoreCodeFn, } - example := StoreRandomContract(t, ctx, keepers, wasmerMock) + example := StoreRandomContract(t, ctx, keepers, wasmEngineMock) _, data, err := keepers.ContractKeeper.Instantiate(ctx, example.CodeID, example.CreatorAddr, nil, nil, "test", nil) require.NoError(t, err) assert.Equal(t, []byte("my-response-data"), data) @@ -738,7 +738,7 @@ func TestInstantiateWithContractFactoryChildQueriesParent(t *testing.T) { var instantiationCount int callbacks := make([]func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error), 2) - wasmerMock := &wasmtesting.MockWasmer{ + wasmEngineMock := &wasmtesting.MockWasmEngine{ // dispatch instantiation calls to callbacks InstantiateFn: func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { require.Greater(t, len(callbacks), instantiationCount, "unexpected call to instantiation") @@ -758,7 +758,7 @@ func TestInstantiateWithContractFactoryChildQueriesParent(t *testing.T) { // overwrite wasmvm in response handler keeper.wasmVMResponseHandler = NewDefaultWasmVMContractResponseHandler(NewMessageDispatcher(keeper.messenger, keeper)) - example := StoreRandomContract(t, ctx, keepers, wasmerMock) + example := StoreRandomContract(t, ctx, keepers, wasmEngineMock) // factory contract callbacks[0] = func(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { t.Log("called factory") @@ -1467,7 +1467,7 @@ func TestIterateContractsByCode(t *testing.T) { func TestIterateContractsByCodeWithMigration(t *testing.T) { // mock migration so that it does not fail when migrate example1 to example2.codeID - mockWasmVM := wasmtesting.MockWasmer{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.Response, uint64, error) { + mockWasmVM := wasmtesting.MockWasmEngine{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.Response, uint64, error) { return &wasmvmtypes.Response{}, 1, nil }} wasmtesting.MakeInstantiable(&mockWasmVM) @@ -1733,7 +1733,7 @@ func TestPinCode(t *testing.T) { k := keepers.WasmKeeper var capturedChecksums []wasmvm.Checksum - mock := wasmtesting.MockWasmer{PinFn: func(checksum wasmvm.Checksum) error { + mock := wasmtesting.MockWasmEngine{PinFn: func(checksum wasmvm.Checksum) error { capturedChecksums = append(capturedChecksums, checksum) return nil }} @@ -1760,7 +1760,7 @@ func TestUnpinCode(t *testing.T) { k := keepers.WasmKeeper var capturedChecksums []wasmvm.Checksum - mock := wasmtesting.MockWasmer{ + mock := wasmtesting.MockWasmEngine{ PinFn: func(checksum wasmvm.Checksum) error { return nil }, @@ -1794,7 +1794,7 @@ func TestInitializePinnedCodes(t *testing.T) { k := keepers.WasmKeeper var capturedChecksums []wasmvm.Checksum - mock := wasmtesting.MockWasmer{PinFn: func(checksum wasmvm.Checksum) error { + mock := wasmtesting.MockWasmEngine{PinFn: func(checksum wasmvm.Checksum) error { capturedChecksums = append(capturedChecksums, checksum) return nil }} @@ -1822,7 +1822,7 @@ func TestInitializePinnedCodes(t *testing.T) { func TestPinnedContractLoops(t *testing.T) { var capturedChecksums []wasmvm.Checksum - mock := wasmtesting.MockWasmer{PinFn: func(checksum wasmvm.Checksum) error { + mock := wasmtesting.MockWasmEngine{PinFn: func(checksum wasmvm.Checksum) error { capturedChecksums = append(capturedChecksums, checksum) return nil }} @@ -1948,7 +1948,7 @@ func TestNewDefaultWasmVMContractResponseHandler(t *testing.T) { func TestReply(t *testing.T) { ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) k := keepers.WasmKeeper - var mock wasmtesting.MockWasmer + var mock wasmtesting.MockWasmEngine wasmtesting.MakeInstantiable(&mock) example := SeedNewContractInstance(t, ctx, keepers, &mock) @@ -2017,7 +2017,7 @@ func TestReply(t *testing.T) { func TestQueryIsolation(t *testing.T) { ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) k := keepers.WasmKeeper - var mock wasmtesting.MockWasmer + var mock wasmtesting.MockWasmEngine wasmtesting.MakeInstantiable(&mock) example := SeedNewContractInstance(t, ctx, keepers, &mock) WithQueryHandlerDecorator(func(other WasmVMQueryHandler) WasmVMQueryHandler { diff --git a/x/wasm/keeper/options.go b/x/wasm/keeper/options.go index 52c1aa1b5c..2fb3d2ea4d 100644 --- a/x/wasm/keeper/options.go +++ b/x/wasm/keeper/options.go @@ -26,14 +26,14 @@ func (f postOptsFn) apply(keeper *Keeper) { // WithWasmEngine is an optional constructor parameter to replace the default wasmVM engine with the // given one. -func WithWasmEngine(x types.WasmerEngine) Option { +func WithWasmEngine(x types.WasmEngine) Option { return optsFn(func(k *Keeper) { k.wasmVM = x }) } // WithWasmEngineDecorator is an optional constructor parameter to decorate the default wasmVM engine. -func WithWasmEngineDecorator(d func(old types.WasmerEngine) types.WasmerEngine) Option { +func WithWasmEngineDecorator(d func(old types.WasmEngine) types.WasmEngine) Option { return postOptsFn(func(k *Keeper) { k.wasmVM = d(k.wasmVM) }) diff --git a/x/wasm/keeper/options_test.go b/x/wasm/keeper/options_test.go index 1f93ca6d57..620087b77e 100644 --- a/x/wasm/keeper/options_test.go +++ b/x/wasm/keeper/options_test.go @@ -1,10 +1,11 @@ package keeper import ( - "github.com/prometheus/client_golang/prometheus" "reflect" "testing" + "github.com/prometheus/client_golang/prometheus" + wasmvm "github.com/CosmWasm/wasmvm" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -26,10 +27,10 @@ func TestConstructorOptions(t *testing.T) { isPostOpt bool }{ "wasm engine": { - srcOpt: WithWasmEngine(&wasmtesting.MockWasmer{}), + srcOpt: WithWasmEngine(&wasmtesting.MockWasmEngine{}), verify: func(t *testing.T, k Keeper) { t.Helper() - assert.IsType(t, &wasmtesting.MockWasmer{}, k.wasmVM) + assert.IsType(t, &wasmtesting.MockWasmEngine{}, k.wasmVM) }, }, "vm cache metrics": { @@ -42,13 +43,13 @@ func TestConstructorOptions(t *testing.T) { isPostOpt: true, }, "decorate wasmvm": { - srcOpt: WithWasmEngineDecorator(func(old types.WasmerEngine) types.WasmerEngine { + srcOpt: WithWasmEngineDecorator(func(old types.WasmEngine) types.WasmEngine { require.IsType(t, &wasmvm.VM{}, old) - return &wasmtesting.MockWasmer{} + return &wasmtesting.MockWasmEngine{} }), verify: func(t *testing.T, k Keeper) { t.Helper() - assert.IsType(t, &wasmtesting.MockWasmer{}, k.wasmVM) + assert.IsType(t, &wasmtesting.MockWasmEngine{}, k.wasmVM) }, isPostOpt: true, }, diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index d21dbd739e..2335090168 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -654,7 +654,7 @@ func TestPinCodesProposal(t *testing.T) { ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper - mock := wasmtesting.MockWasmer{ + mock := wasmtesting.MockWasmEngine{ StoreCodeFn: wasmtesting.NoOpStoreCodeFn, AnalyzeCodeFn: wasmtesting.WithoutIBCAnalyzeFn, } @@ -745,7 +745,7 @@ func TestUnpinCodesProposal(t *testing.T) { ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper - mock := wasmtesting.MockWasmer{ + mock := wasmtesting.MockWasmEngine{ StoreCodeFn: wasmtesting.NoOpStoreCodeFn, AnalyzeCodeFn: wasmtesting.WithoutIBCAnalyzeFn, } @@ -835,7 +835,7 @@ func TestUpdateInstantiateConfigProposal(t *testing.T) { ctx, keepers := CreateTestInput(t, false, "staking") wasmKeeper := keepers.WasmKeeper - mock := wasmtesting.MockWasmer{ + mock := wasmtesting.MockWasmEngine{ StoreCodeFn: wasmtesting.NoOpStoreCodeFn, AnalyzeCodeFn: wasmtesting.WithoutIBCAnalyzeFn, } diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index 8fd64159e5..f79c389045 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -192,7 +192,7 @@ func TestQuerySmartContractPanics(t *testing.T) { } for msg, spec := range specs { t.Run(msg, func(t *testing.T) { - keepers.WasmKeeper.wasmVM = &wasmtesting.MockWasmer{QueryFn: func(checksum wasmvm.Checksum, env wasmvmtypes.Env, queryMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) ([]byte, uint64, error) { + keepers.WasmKeeper.wasmVM = &wasmtesting.MockWasmEngine{QueryFn: func(checksum wasmvm.Checksum, env wasmvmtypes.Env, queryMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) ([]byte, uint64, error) { spec.doInContract() return nil, 0, nil }} diff --git a/x/wasm/keeper/recurse_test.go b/x/wasm/keeper/recurse_test.go index 4b2e22ffb1..2254db95ba 100644 --- a/x/wasm/keeper/recurse_test.go +++ b/x/wasm/keeper/recurse_test.go @@ -55,7 +55,7 @@ func initRecurseContract(t *testing.T) (contract sdk.AccAddress, ctx sdk.Context func TestGasCostOnQuery(t *testing.T) { const ( GasNoWork uint64 = 63_950 - // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 + // Note: about 100 SDK gas (10k CosmWasm gas) for each round of sha256 GasWork50 uint64 = 64_218 // this is a little shy of 50k gas - to keep an eye on the limit GasReturnUnhashed uint64 = 29 @@ -208,7 +208,7 @@ func TestLimitRecursiveQueryGas(t *testing.T) { // eventually hitting an OutOfGas panic. const ( - // Note: about 100 SDK gas (10k wasmer gas) for each round of sha256 + // Note: about 100 SDK gas (10k CosmWasm gas) for each round of sha256 GasWork2k uint64 = 77_161 // = NewContractInstanceCosts + x // we have 6x gas used in cpu than in the instance // This is overhead for calling into a sub-contract GasReturnHashed uint64 = 25 diff --git a/x/wasm/keeper/relay_test.go b/x/wasm/keeper/relay_test.go index a2bb9a5f70..928176591d 100644 --- a/x/wasm/keeper/relay_test.go +++ b/x/wasm/keeper/relay_test.go @@ -18,7 +18,7 @@ import ( ) func TestOnOpenChannel(t *testing.T) { - var m wasmtesting.MockWasmer + var m wasmtesting.MockWasmEngine wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithMessageHandler(messenger)) @@ -88,7 +88,7 @@ func TestOnOpenChannel(t *testing.T) { } func TestOnConnectChannel(t *testing.T) { - var m wasmtesting.MockWasmer + var m wasmtesting.MockWasmEngine wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithMessageHandler(messenger)) @@ -200,7 +200,7 @@ func TestOnConnectChannel(t *testing.T) { } func TestOnCloseChannel(t *testing.T) { - var m wasmtesting.MockWasmer + var m wasmtesting.MockWasmEngine wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithMessageHandler(messenger)) @@ -310,7 +310,7 @@ func TestOnCloseChannel(t *testing.T) { } func TestOnRecvPacket(t *testing.T) { - var m wasmtesting.MockWasmer + var m wasmtesting.MockWasmEngine wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithMessageHandler(messenger)) @@ -500,7 +500,7 @@ func TestOnRecvPacket(t *testing.T) { } func TestOnAckPacket(t *testing.T) { - var m wasmtesting.MockWasmer + var m wasmtesting.MockWasmEngine wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithMessageHandler(messenger)) @@ -605,7 +605,7 @@ func TestOnAckPacket(t *testing.T) { } func TestOnTimeoutPacket(t *testing.T) { - var m wasmtesting.MockWasmer + var m wasmtesting.MockWasmEngine wasmtesting.MakeIBCInstantiable(&m) messenger := &wasmtesting.MockMessageHandler{} parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithMessageHandler(messenger)) diff --git a/x/wasm/keeper/submsg_test.go b/x/wasm/keeper/submsg_test.go index d67dd9787c..fe301dc37b 100644 --- a/x/wasm/keeper/submsg_test.go +++ b/x/wasm/keeper/submsg_test.go @@ -562,7 +562,7 @@ func TestDispatchSubMsgConditionalReplyOn(t *testing.T) { } func TestInstantiateGovSubMsgAuthzPropagated(t *testing.T) { - mockWasmVM := &wasmtesting.MockWasmer{} + mockWasmVM := &wasmtesting.MockWasmEngine{} wasmtesting.MakeInstantiable(mockWasmVM) var instanceLevel int // mock wasvm to return new instantiate msgs with the response @@ -643,7 +643,7 @@ func TestInstantiateGovSubMsgAuthzPropagated(t *testing.T) { } func TestMigrateGovSubMsgAuthzPropagated(t *testing.T) { - mockWasmVM := &wasmtesting.MockWasmer{} + mockWasmVM := &wasmtesting.MockWasmEngine{} wasmtesting.MakeInstantiable(mockWasmVM) ctx, keepers := CreateTestInput(t, false, AvailableCapabilities, WithWasmEngine(mockWasmVM)) k := keepers.WasmKeeper diff --git a/x/wasm/keeper/test_common.go b/x/wasm/keeper/test_common.go index 82993cc0ff..ccb3d2dd34 100644 --- a/x/wasm/keeper/test_common.go +++ b/x/wasm/keeper/test_common.go @@ -661,8 +661,8 @@ type ExampleContractInstance struct { Contract sdk.AccAddress } -// SeedNewContractInstance sets the mock wasmerEngine in keeper and calls store + instantiate to init the contract's metadata -func SeedNewContractInstance(tb testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContractInstance { +// SeedNewContractInstance sets the mock WasmEngine in keeper and calls store + instantiate to init the contract's metadata +func SeedNewContractInstance(tb testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmEngine) ExampleContractInstance { tb.Helper() exampleContract := StoreRandomContract(tb, ctx, keepers, mock) contractAddr, _, err := keepers.ContractKeeper.Instantiate(ctx, exampleContract.CodeID, exampleContract.CreatorAddr, exampleContract.CreatorAddr, []byte(`{}`), "", nil) @@ -673,8 +673,8 @@ func SeedNewContractInstance(tb testing.TB, ctx sdk.Context, keepers TestKeepers } } -// StoreRandomContract sets the mock wasmerEngine in keeper and calls store -func StoreRandomContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmerEngine) ExampleContract { +// StoreRandomContract sets the mock WasmEngine in keeper and calls store +func StoreRandomContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers, mock types.WasmEngine) ExampleContract { tb.Helper() return StoreRandomContractWithAccessConfig(tb, ctx, keepers, mock, nil) @@ -683,7 +683,7 @@ func StoreRandomContract(tb testing.TB, ctx sdk.Context, keepers TestKeepers, mo func StoreRandomContractWithAccessConfig( tb testing.TB, ctx sdk.Context, keepers TestKeepers, - mock types.WasmerEngine, + mock types.WasmEngine, cfg *types.AccessConfig, ) ExampleContract { tb.Helper() diff --git a/x/wasm/keeper/wasmtesting/mock_engine.go b/x/wasm/keeper/wasmtesting/mock_engine.go index 4036d6e02c..b1c7b11d04 100644 --- a/x/wasm/keeper/wasmtesting/mock_engine.go +++ b/x/wasm/keeper/wasmtesting/mock_engine.go @@ -12,11 +12,11 @@ import ( "github.com/CosmWasm/wasmd/x/wasm/types" ) -var _ types.WasmerEngine = &MockWasmer{} +var _ types.WasmEngine = &MockWasmEngine{} -// MockWasmer implements types.WasmerEngine for testing purpose. One or multiple messages can be stubbed. +// MockWasmEngine implements types.WasmEngine for testing purpose. One or multiple messages can be stubbed. // Without a stub function a panic is thrown. -type MockWasmer struct { +type MockWasmEngine struct { StoreCodeFn func(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) StoreCodeUncheckedFn func(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) AnalyzeCodeFn func(codeID wasmvm.Checksum) (*wasmvmtypes.AnalysisReport, error) @@ -39,42 +39,42 @@ type MockWasmer struct { GetMetricsFn func() (*wasmvmtypes.Metrics, error) } -func (m *MockWasmer) IBCChannelOpen(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelOpenMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBC3ChannelOpenResponse, uint64, error) { +func (m *MockWasmEngine) IBCChannelOpen(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelOpenMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBC3ChannelOpenResponse, uint64, error) { if m.IBCChannelOpenFn == nil { panic("not supposed to be called!") } return m.IBCChannelOpenFn(codeID, env, msg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) IBCChannelConnect(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelConnectMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (m *MockWasmEngine) IBCChannelConnect(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelConnectMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { if m.IBCChannelConnectFn == nil { panic("not supposed to be called!") } return m.IBCChannelConnectFn(codeID, env, msg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) IBCChannelClose(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelCloseMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (m *MockWasmEngine) IBCChannelClose(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCChannelCloseMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { if m.IBCChannelCloseFn == nil { panic("not supposed to be called!") } return m.IBCChannelCloseFn(codeID, env, msg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { +func (m *MockWasmEngine) IBCPacketReceive(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketReceiveMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCReceiveResult, uint64, error) { if m.IBCPacketReceiveFn == nil { panic("not supposed to be called!") } return m.IBCPacketReceiveFn(codeID, env, msg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (m *MockWasmEngine) IBCPacketAck(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketAckMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { if m.IBCPacketAckFn == nil { panic("not supposed to be called!") } return m.IBCPacketAckFn(codeID, env, msg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) IBCPacketTimeout(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketTimeoutMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { +func (m *MockWasmEngine) IBCPacketTimeout(codeID wasmvm.Checksum, env wasmvmtypes.Env, msg wasmvmtypes.IBCPacketTimeoutMsg, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.IBCBasicResponse, uint64, error) { if m.IBCPacketTimeoutFn == nil { panic("not supposed to be called!") } @@ -82,113 +82,113 @@ func (m *MockWasmer) IBCPacketTimeout(codeID wasmvm.Checksum, env wasmvmtypes.En } // Deprecated: use StoreCode instead. -func (m *MockWasmer) Create(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) { +func (m *MockWasmEngine) Create(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) { panic("Deprecated: use StoreCode instead") } -func (m *MockWasmer) StoreCode(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) { +func (m *MockWasmEngine) StoreCode(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) { if m.StoreCodeFn == nil { panic("not supposed to be called!") } return m.StoreCodeFn(codeID) } -func (m *MockWasmer) StoreCodeUnchecked(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) { +func (m *MockWasmEngine) StoreCodeUnchecked(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) { if m.StoreCodeUncheckedFn == nil { panic("not supposed to be called!") } return m.StoreCodeUncheckedFn(codeID) } -func (m *MockWasmer) AnalyzeCode(codeID wasmvm.Checksum) (*wasmvmtypes.AnalysisReport, error) { +func (m *MockWasmEngine) AnalyzeCode(codeID wasmvm.Checksum) (*wasmvmtypes.AnalysisReport, error) { if m.AnalyzeCodeFn == nil { panic("not supposed to be called!") } return m.AnalyzeCodeFn(codeID) } -func (m *MockWasmer) Instantiate(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (m *MockWasmEngine) Instantiate(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, initMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { if m.InstantiateFn == nil { panic("not supposed to be called!") } return m.InstantiateFn(codeID, env, info, initMsg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) Execute(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (m *MockWasmEngine) Execute(codeID wasmvm.Checksum, env wasmvmtypes.Env, info wasmvmtypes.MessageInfo, executeMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { if m.ExecuteFn == nil { panic("not supposed to be called!") } return m.ExecuteFn(codeID, env, info, executeMsg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) Query(codeID wasmvm.Checksum, env wasmvmtypes.Env, queryMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) ([]byte, uint64, error) { +func (m *MockWasmEngine) Query(codeID wasmvm.Checksum, env wasmvmtypes.Env, queryMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) ([]byte, uint64, error) { if m.QueryFn == nil { panic("not supposed to be called!") } return m.QueryFn(codeID, env, queryMsg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) Migrate(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.Response, uint64, error) { +func (m *MockWasmEngine) Migrate(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.Response, uint64, error) { if m.MigrateFn == nil { panic("not supposed to be called!") } return m.MigrateFn(codeID, env, migrateMsg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) Sudo(codeID wasmvm.Checksum, env wasmvmtypes.Env, sudoMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (m *MockWasmEngine) Sudo(codeID wasmvm.Checksum, env wasmvmtypes.Env, sudoMsg []byte, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { if m.SudoFn == nil { panic("not supposed to be called!") } return m.SudoFn(codeID, env, sudoMsg, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) Reply(codeID wasmvm.Checksum, env wasmvmtypes.Env, reply wasmvmtypes.Reply, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { +func (m *MockWasmEngine) Reply(codeID wasmvm.Checksum, env wasmvmtypes.Env, reply wasmvmtypes.Reply, store wasmvm.KVStore, goapi wasmvm.GoAPI, querier wasmvm.Querier, gasMeter wasmvm.GasMeter, gasLimit uint64, deserCost wasmvmtypes.UFraction) (*wasmvmtypes.Response, uint64, error) { if m.ReplyFn == nil { panic("not supposed to be called!") } return m.ReplyFn(codeID, env, reply, store, goapi, querier, gasMeter, gasLimit, deserCost) } -func (m *MockWasmer) GetCode(codeID wasmvm.Checksum) (wasmvm.WasmCode, error) { +func (m *MockWasmEngine) GetCode(codeID wasmvm.Checksum) (wasmvm.WasmCode, error) { if m.GetCodeFn == nil { panic("not supposed to be called!") } return m.GetCodeFn(codeID) } -func (m *MockWasmer) Cleanup() { +func (m *MockWasmEngine) Cleanup() { if m.CleanupFn == nil { panic("not supposed to be called!") } m.CleanupFn() } -func (m *MockWasmer) Pin(checksum wasmvm.Checksum) error { +func (m *MockWasmEngine) Pin(checksum wasmvm.Checksum) error { if m.PinFn == nil { panic("not supposed to be called!") } return m.PinFn(checksum) } -func (m *MockWasmer) Unpin(checksum wasmvm.Checksum) error { +func (m *MockWasmEngine) Unpin(checksum wasmvm.Checksum) error { if m.UnpinFn == nil { panic("not supposed to be called!") } return m.UnpinFn(checksum) } -func (m *MockWasmer) GetMetrics() (*wasmvmtypes.Metrics, error) { +func (m *MockWasmEngine) GetMetrics() (*wasmvmtypes.Metrics, error) { if m.GetMetricsFn == nil { panic("not expected to be called") } return m.GetMetricsFn() } -var AlwaysPanicMockWasmer = &MockWasmer{} +var AlwaysPanicMockWasmEngine = &MockWasmEngine{} -// SelfCallingInstMockWasmer prepares a Wasmer mock that calls itself on instantiation. -func SelfCallingInstMockWasmer(executeCalled *bool) *MockWasmer { - return &MockWasmer{ +// SelfCallingInstMockWasmEngine prepares a WasmEngine mock that calls itself on instantiation. +func SelfCallingInstMockWasmEngine(executeCalled *bool) *MockWasmEngine { + return &MockWasmEngine{ StoreCodeFn: func(code wasmvm.WasmCode) (wasmvm.Checksum, error) { anyCodeID := bytes.Repeat([]byte{0x1}, 32) return anyCodeID, nil @@ -302,24 +302,24 @@ type contractExecutable interface { } // MakeInstantiable adds some noop functions to not fail when contract is used for instantiation -func MakeInstantiable(m *MockWasmer) { +func MakeInstantiable(m *MockWasmEngine) { m.StoreCodeFn = HashOnlyStoreCodeFn m.InstantiateFn = NoOpInstantiateFn m.AnalyzeCodeFn = WithoutIBCAnalyzeFn } // MakeIBCInstantiable adds some noop functions to not fail when contract is used for instantiation -func MakeIBCInstantiable(m *MockWasmer) { +func MakeIBCInstantiable(m *MockWasmEngine) { MakeInstantiable(m) m.AnalyzeCodeFn = HasIBCAnalyzeFn } -// NewIBCContractMockWasmer prepares a mocked wasm_engine for testing with an IBC contract test type. +// NewIBCContractMockWasmEngine prepares a mocked wasm_engine for testing with an IBC contract test type. // It is safe to use the mock with store code and instantiate functions in keeper as is also prepared // with stubs. Execute is optional. When implemented by the Go test contract then it can be used with // the mock. -func NewIBCContractMockWasmer(c IBCContractCallbacks) *MockWasmer { - m := &MockWasmer{ +func NewIBCContractMockWasmEngine(c IBCContractCallbacks) *MockWasmEngine { + m := &MockWasmEngine{ IBCChannelOpenFn: c.IBCChannelOpen, IBCChannelConnectFn: c.IBCChannelConnect, IBCChannelCloseFn: c.IBCChannelClose, diff --git a/x/wasm/migrations/v3/store_test.go b/x/wasm/migrations/v3/store_test.go index 815988380c..0bd217d299 100644 --- a/x/wasm/migrations/v3/store_test.go +++ b/x/wasm/migrations/v3/store_test.go @@ -29,7 +29,7 @@ func TestMigrate3To4(t *testing.T) { creator := sdk.AccAddress(bytes.Repeat([]byte{1}, address.Len)) keepers.Faucet.Fund(ctx, creator, deposit...) - var mock wasmtesting.MockWasmer + var mock wasmtesting.MockWasmEngine wasmtesting.MakeInstantiable(&mock) // contract with only address permission diff --git a/x/wasm/relay_pingpong_test.go b/x/wasm/relay_pingpong_test.go index ea8bd75e7e..a9eadc7f90 100644 --- a/x/wasm/relay_pingpong_test.go +++ b/x/wasm/relay_pingpong_test.go @@ -43,10 +43,10 @@ func TestPinPong(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(pingContract)), + wasmtesting.NewIBCContractMockWasmEngine(pingContract)), } chainBOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(pongContract), + wasmtesting.NewIBCContractMockWasmEngine(pongContract), )} coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts, chainBOpts) chainA = coordinator.GetChain(wasmibctesting.GetChainID(1)) diff --git a/x/wasm/relay_test.go b/x/wasm/relay_test.go index f3dc9b3236..91a6a37d15 100644 --- a/x/wasm/relay_test.go +++ b/x/wasm/relay_test.go @@ -86,7 +86,7 @@ func TestFromIBCTransferToContract(t *testing.T) { t.Run(name, func(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(spec.contract), + wasmtesting.NewIBCContractMockWasmEngine(spec.contract), )} coordinator = wasmibctesting.NewCoordinator(t, 2, []wasmkeeper.Option{}, chainAOpts) chainA = coordinator.GetChain(wasmibctesting.GetChainID(1)) @@ -162,7 +162,7 @@ func TestContractCanInitiateIBCTransferMsg(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContract)), + wasmtesting.NewIBCContractMockWasmEngine(myContract)), } coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) chainA = coordinator.GetChain(wasmibctesting.GetChainID(1)) @@ -233,7 +233,7 @@ func TestContractCanEmulateIBCTransferMessage(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContract)), + wasmtesting.NewIBCContractMockWasmEngine(myContract)), } coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) @@ -308,7 +308,7 @@ func TestContractCanEmulateIBCTransferMessageWithTimeout(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContract)), + wasmtesting.NewIBCContractMockWasmEngine(myContract)), } coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts) @@ -389,10 +389,10 @@ func TestContractEmulateIBCTransferMessageOnDiffContractIBCChannel(t *testing.T) var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContractA1), + wasmtesting.NewIBCContractMockWasmEngine(myContractA1), ), wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContractA2), + wasmtesting.NewIBCContractMockWasmEngine(myContractA2), ), } @@ -452,11 +452,11 @@ func TestContractHandlesChannelClose(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContractA)), + wasmtesting.NewIBCContractMockWasmEngine(myContractA)), } chainBOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContractB)), + wasmtesting.NewIBCContractMockWasmEngine(myContractB)), } coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts, chainBOpts) @@ -498,13 +498,13 @@ func TestContractHandlesChannelCloseNotOwned(t *testing.T) { var ( chainAOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContractA1)), + wasmtesting.NewIBCContractMockWasmEngine(myContractA1)), wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContractA2)), + wasmtesting.NewIBCContractMockWasmEngine(myContractA2)), } chainBOpts = []wasmkeeper.Option{ wasmkeeper.WithWasmEngine( - wasmtesting.NewIBCContractMockWasmer(myContractB)), + wasmtesting.NewIBCContractMockWasmEngine(myContractB)), } coordinator = wasmibctesting.NewCoordinator(t, 2, chainAOpts, chainBOpts) diff --git a/x/wasm/types/wasmer_engine.go b/x/wasm/types/wasmer_engine.go index f72ae2010e..d3b465de77 100644 --- a/x/wasm/types/wasmer_engine.go +++ b/x/wasm/types/wasmer_engine.go @@ -10,8 +10,8 @@ import ( // DefaultMaxQueryStackSize maximum size of the stack of contract instances doing queries const DefaultMaxQueryStackSize uint32 = 10 -// WasmerEngine defines the WASM contract runtime engine. -type WasmerEngine interface { +// WasmEngine defines the WASM contract runtime engine. +type WasmEngine interface { // Create will compile the wasm code, and store the resulting pre-compile // as well as the original code. Both can be referenced later via CodeID // This must be done one time for given code, after which it can be