From 1a591b17be9dbf424cc8b4157f120bd735ed73a0 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 15:36:54 +0900 Subject: [PATCH 01/13] refactor: Changed to use abci type --- .../keeper/msg_server_integration_test.go | 77 ++++++++++++++----- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index 691780e43c..83f02c317c 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -7,9 +7,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + abcitypes "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - sdk "github.com/Finschia/finschia-sdk/types" + sdktypes "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/wasmd/appplus" @@ -25,18 +26,58 @@ func TestStoreAndInstantiateContract(t *testing.T) { ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) var ( - myAddress sdk.AccAddress = make([]byte, wasmtypes.ContractAddrLen) + myAddress sdktypes.AccAddress = make([]byte, wasmtypes.ContractAddrLen) ) specs := map[string]struct { addr string permission *wasmtypes.AccessConfig expErr bool + events []abcitypes.Event }{ "address can instantiate a contract when permission is everybody": { addr: myAddress.String(), permission: &wasmtypes.AllowEverybody, - expErr: false, + events: []abcitypes.Event{{ + Type: "store_code", + Attributes: []abcitypes.EventAttribute{abcitypes.EventAttribute{ + Key: []byte("code_checksum"), + Value: []byte("2843664c3b6c1de8bdeca672267c508aeb79bb947c87f75d8053f971d8658c89"), + Index: false, + }, { + Key: []byte("code_id"), + Value: []byte("1"), + Index: false, + }, + }, + }, { + Type: "message", + Attributes: []abcitypes.EventAttribute{abcitypes.EventAttribute{ + Key: []byte("module"), + Value: []byte("wasm"), + Index: false, + }, { + Key: []byte("sender"), + Value: []byte("link1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjhjmun"), + Index: false, + }, + }, + }, + { + Type: "instantiate", + Attributes: []abcitypes.EventAttribute{abcitypes.EventAttribute{ + Key: []byte("_contract_address"), + Value: []byte("link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8"), + Index: false, + }, { + Key: []byte("code_id"), + Value: []byte("1"), + Index: false, + }, + }, + }, + }, + expErr: false, }, "address cannot instantiate a contract when permission is nobody": { addr: myAddress.String(), @@ -55,7 +96,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { Admin: myAddress.String(), Label: "test", Msg: []byte(`{}`), - Funds: sdk.Coins{}, + Funds: sdktypes.Coins{}, } rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(xCtx, msg) @@ -71,21 +112,21 @@ func TestStoreAndInstantiateContract(t *testing.T) { // check event events := rsp.Events assert.Equal(t, 3, len(events)) - assert.Equal(t, "store_code", events[0].Type) - assert.Equal(t, 2, len(events[0].Attributes)) - assert.Equal(t, "code_checksum", string(events[0].Attributes[0].Key)) - assert.Equal(t, "code_id", string(events[0].Attributes[1].Key)) - assert.Equal(t, "1", string(events[0].Attributes[1].Value)) - assert.Equal(t, "message", events[1].Type) - assert.Equal(t, 2, len(events[1].Attributes)) - assert.Equal(t, "module", string(events[1].Attributes[0].Key)) - assert.Equal(t, "wasm", string(events[1].Attributes[0].Value)) - assert.Equal(t, "sender", string(events[1].Attributes[1].Key)) - assert.Equal(t, "instantiate", events[2].Type) - assert.Equal(t, "_contract_address", string(events[2].Attributes[0].Key)) + assert.Equal(t, spec.events[0].Type, events[0].Type) + assert.Equal(t, len(spec.events[0].Attributes), len(events[0].Attributes)) + assert.Equal(t, string(spec.events[0].Attributes[0].Key), string(events[0].Attributes[0].Key)) + assert.Equal(t, string(spec.events[0].Attributes[1].Key), string(events[0].Attributes[1].Key)) + assert.Equal(t, string(spec.events[0].Attributes[1].Value), string(events[0].Attributes[1].Value)) + assert.Equal(t, spec.events[1].Type, events[1].Type) + assert.Equal(t, len(spec.events[1].Attributes), len(events[1].Attributes)) + assert.Equal(t, string(spec.events[1].Attributes[0].Key), string(events[1].Attributes[0].Key)) + assert.Equal(t, string(spec.events[1].Attributes[0].Value), string(events[1].Attributes[0].Value)) + assert.Equal(t, string(spec.events[1].Attributes[1].Key), string(events[1].Attributes[1].Key)) + assert.Equal(t, spec.events[2].Type, events[2].Type) + assert.Equal(t, string(spec.events[2].Attributes[0].Key), string(events[2].Attributes[0].Key)) assert.Equal(t, storeAndInstantiateResponse.Address, string(events[2].Attributes[0].Value)) - assert.Equal(t, "code_id", string(events[2].Attributes[1].Key)) - assert.Equal(t, "1", string(events[2].Attributes[1].Value)) + assert.Equal(t, string(spec.events[2].Attributes[1].Key), string(events[2].Attributes[1].Key)) + assert.Equal(t, string(spec.events[2].Attributes[1].Value), string(events[2].Attributes[1].Value)) require.NoError(t, err) }) From 0e144f9670db8aa22d522f9756b99ec50b1be2b1 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 15:44:50 +0900 Subject: [PATCH 02/13] refactor: Changed to use `reflect.DeepEqual` --- .../keeper/msg_server_integration_test.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index 83f02c317c..fde5772c92 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -2,6 +2,7 @@ package keeper_test import ( _ "embed" + "reflect" "testing" "time" @@ -110,23 +111,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &storeAndInstantiateResponse)) // check event - events := rsp.Events - assert.Equal(t, 3, len(events)) - assert.Equal(t, spec.events[0].Type, events[0].Type) - assert.Equal(t, len(spec.events[0].Attributes), len(events[0].Attributes)) - assert.Equal(t, string(spec.events[0].Attributes[0].Key), string(events[0].Attributes[0].Key)) - assert.Equal(t, string(spec.events[0].Attributes[1].Key), string(events[0].Attributes[1].Key)) - assert.Equal(t, string(spec.events[0].Attributes[1].Value), string(events[0].Attributes[1].Value)) - assert.Equal(t, spec.events[1].Type, events[1].Type) - assert.Equal(t, len(spec.events[1].Attributes), len(events[1].Attributes)) - assert.Equal(t, string(spec.events[1].Attributes[0].Key), string(events[1].Attributes[0].Key)) - assert.Equal(t, string(spec.events[1].Attributes[0].Value), string(events[1].Attributes[0].Value)) - assert.Equal(t, string(spec.events[1].Attributes[1].Key), string(events[1].Attributes[1].Key)) - assert.Equal(t, spec.events[2].Type, events[2].Type) - assert.Equal(t, string(spec.events[2].Attributes[0].Key), string(events[2].Attributes[0].Key)) - assert.Equal(t, storeAndInstantiateResponse.Address, string(events[2].Attributes[0].Value)) - assert.Equal(t, string(spec.events[2].Attributes[1].Key), string(events[2].Attributes[1].Key)) - assert.Equal(t, string(spec.events[2].Attributes[1].Value), string(events[2].Attributes[1].Value)) + assert.True(t, reflect.DeepEqual(spec.events, rsp.Events)) require.NoError(t, err) }) From ad18f157063439fa4f9d75640686aa59d96d3f5a Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 15:47:32 +0900 Subject: [PATCH 03/13] chore: add this pr to change.log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25b464a0f0..44f3fc9825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ * [\#88](https://github.com/Finschia/wasmd/pull/88) add the test case for invalid address * [\#76](https://github.com/Finschia/wasmd/pull/76) add an integration test for ClearAdmin * [\#68](https://github.com/Finschia/wasmd/pull/68) add an integration test for UpdateAdmin +* [\#98](https://github.com/Finschia/wasmd/pull/98) Changed to use abci type ### Bug Fixes * [\#62](https://github.com/Finschia/wasmd/pull/62) fill ContractHistory querier result's Updated field From 9555ae4167f344158d32da0325772d504e20ae26 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi <52264064+kokeshiM0chi@users.noreply.github.com> Date: Thu, 24 Aug 2023 16:35:20 +0900 Subject: [PATCH 04/13] Update x/wasmplus/keeper/msg_server_integration_test.go Co-authored-by: 170210 <85928898+170210@users.noreply.github.com> --- x/wasmplus/keeper/msg_server_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index fde5772c92..454b6c74e1 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -11,7 +11,7 @@ import ( abcitypes "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - sdktypes "github.com/Finschia/finschia-sdk/types" + sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/wasmd/appplus" From 88bfff626cca3ba3f0b4e4743bd6145c317675e5 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 16:50:26 +0900 Subject: [PATCH 05/13] fix: fix import alias and the value of the address specified in spec --- x/wasmplus/keeper/msg_server_integration_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index 454b6c74e1..eec3590f6b 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -27,14 +27,14 @@ func TestStoreAndInstantiateContract(t *testing.T) { ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) var ( - myAddress sdktypes.AccAddress = make([]byte, wasmtypes.ContractAddrLen) + myAddress sdk.AccAddress = make([]byte, wasmtypes.ContractAddrLen) ) specs := map[string]struct { addr string permission *wasmtypes.AccessConfig - expErr bool events []abcitypes.Event + expErr bool }{ "address can instantiate a contract when permission is everybody": { addr: myAddress.String(), @@ -59,7 +59,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { Index: false, }, { Key: []byte("sender"), - Value: []byte("link1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjhjmun"), + Value: []byte(myAddress.String()), Index: false, }, }, @@ -97,7 +97,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { Admin: myAddress.String(), Label: "test", Msg: []byte(`{}`), - Funds: sdktypes.Coins{}, + Funds: sdk.Coins{}, } rsp, err := wasmApp.MsgServiceRouter().Handler(msg)(xCtx, msg) From bd842c974de6b9bcf3b60c77fc4dcbafddd19fa0 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 16:54:42 +0900 Subject: [PATCH 06/13] fix: fix the pr title --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44f3fc9825..ada9b527ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ * [\#88](https://github.com/Finschia/wasmd/pull/88) add the test case for invalid address * [\#76](https://github.com/Finschia/wasmd/pull/76) add an integration test for ClearAdmin * [\#68](https://github.com/Finschia/wasmd/pull/68) add an integration test for UpdateAdmin -* [\#98](https://github.com/Finschia/wasmd/pull/98) Changed to use abci type +* [\#98](https://github.com/Finschia/wasmd/pull/98) refactor TestStoreAndInstantiateContract ### Bug Fixes * [\#62](https://github.com/Finschia/wasmd/pull/62) fill ContractHistory querier result's Updated field From b3f4091f28343b394bf21fde9ef6425435e0f571 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 16:57:51 +0900 Subject: [PATCH 07/13] fix: fix comparison test code --- x/wasmplus/keeper/msg_server_integration_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index eec3590f6b..68cf17e65e 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -2,7 +2,6 @@ package keeper_test import ( _ "embed" - "reflect" "testing" "time" @@ -111,7 +110,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &storeAndInstantiateResponse)) // check event - assert.True(t, reflect.DeepEqual(spec.events, rsp.Events)) + assert.Equal(t, spec.events, rsp.Events) require.NoError(t, err) }) From e0a45f2f853bbac1f5dc45fd9746b7443a35b5dc Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 17:24:29 +0900 Subject: [PATCH 08/13] fix: rename import alias --- x/wasmplus/keeper/msg_server_integration_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index 68cf17e65e..56579e7131 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - abcitypes "github.com/tendermint/tendermint/abci/types" + abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" sdk "github.com/Finschia/finschia-sdk/types" @@ -32,15 +32,15 @@ func TestStoreAndInstantiateContract(t *testing.T) { specs := map[string]struct { addr string permission *wasmtypes.AccessConfig - events []abcitypes.Event + events []abci.Event expErr bool }{ "address can instantiate a contract when permission is everybody": { addr: myAddress.String(), permission: &wasmtypes.AllowEverybody, - events: []abcitypes.Event{{ + events: []abci.Event{{ Type: "store_code", - Attributes: []abcitypes.EventAttribute{abcitypes.EventAttribute{ + Attributes: []abci.EventAttribute{abci.EventAttribute{ Key: []byte("code_checksum"), Value: []byte("2843664c3b6c1de8bdeca672267c508aeb79bb947c87f75d8053f971d8658c89"), Index: false, @@ -52,7 +52,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { }, }, { Type: "message", - Attributes: []abcitypes.EventAttribute{abcitypes.EventAttribute{ + Attributes: []abci.EventAttribute{abci.EventAttribute{ Key: []byte("module"), Value: []byte("wasm"), Index: false, @@ -65,7 +65,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { }, { Type: "instantiate", - Attributes: []abcitypes.EventAttribute{abcitypes.EventAttribute{ + Attributes: []abci.EventAttribute{abci.EventAttribute{ Key: []byte("_contract_address"), Value: []byte("link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8"), Index: false, From 0ea982558538617530bb8c4c2344c2369645e1d6 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 24 Aug 2023 21:14:23 +0900 Subject: [PATCH 09/13] refactor: rename a valuable name --- x/wasmplus/keeper/msg_server_integration_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index 56579e7131..040b025c42 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -32,13 +32,13 @@ func TestStoreAndInstantiateContract(t *testing.T) { specs := map[string]struct { addr string permission *wasmtypes.AccessConfig - events []abci.Event + expEvents []abci.Event expErr bool }{ "address can instantiate a contract when permission is everybody": { addr: myAddress.String(), permission: &wasmtypes.AllowEverybody, - events: []abci.Event{{ + expEvents: []abci.Event{{ Type: "store_code", Attributes: []abci.EventAttribute{abci.EventAttribute{ Key: []byte("code_checksum"), @@ -110,7 +110,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { require.NoError(t, wasmApp.AppCodec().Unmarshal(rsp.Data, &storeAndInstantiateResponse)) // check event - assert.Equal(t, spec.events, rsp.Events) + assert.Equal(t, spec.expEvents, rsp.Events) require.NoError(t, err) }) From a865043684b15e6085fbc906d1b42ac5ae271781 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Fri, 25 Aug 2023 09:56:14 +0900 Subject: [PATCH 10/13] refactor: add the test function --- .../keeper/msg_server_integration_test.go | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index 040b025c42..5bcc408fb3 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -50,19 +50,7 @@ func TestStoreAndInstantiateContract(t *testing.T) { Index: false, }, }, - }, { - Type: "message", - Attributes: []abci.EventAttribute{abci.EventAttribute{ - Key: []byte("module"), - Value: []byte("wasm"), - Index: false, - }, { - Key: []byte("sender"), - Value: []byte(myAddress.String()), - Index: false, - }, - }, - }, + }, createMsgEvent(myAddress), { Type: "instantiate", Attributes: []abci.EventAttribute{abci.EventAttribute{ @@ -116,3 +104,21 @@ func TestStoreAndInstantiateContract(t *testing.T) { }) } } + +// This function is utilized to generate the msg event for event checking in integration tests +// It will be deleted in release/v0.1.x +func createMsgEvent(sender sdk.AccAddress) abci.Event { + return abci.Event{ + Type: "message", + Attributes: []abci.EventAttribute{ + { + Key: []byte("module"), + Value: []byte("wasm"), + }, + { + Key: []byte("sender"), + Value: []byte(sender.String()), + }, + }, + } +} From f72ad5bd1d4008d9f56da682422e25f7459f2493 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Fri, 25 Aug 2023 15:14:19 +0900 Subject: [PATCH 11/13] fix: add the `Index` field, etc --- x/wasm/keeper/msg_server_integration_test.go | 30 ++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/x/wasm/keeper/msg_server_integration_test.go b/x/wasm/keeper/msg_server_integration_test.go index 9384f984e4..51497538ff 100644 --- a/x/wasm/keeper/msg_server_integration_test.go +++ b/x/wasm/keeper/msg_server_integration_test.go @@ -73,7 +73,9 @@ func TestInstantiateContract(t *testing.T) { wasmApp := app.Setup(false) ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) - var myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + ) specs := map[string]struct { addr string @@ -119,7 +121,7 @@ func TestInstantiateContract(t *testing.T) { } rsp, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(xCtx, msgInstantiate) - // then + //then if spec.expErr { require.Error(t, err) return @@ -150,7 +152,9 @@ func TestInstantiateContract2(t *testing.T) { wasmApp := app.Setup(false) ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) - var myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + var ( + myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) + ) specs := map[string]struct { addr string @@ -201,7 +205,7 @@ func TestInstantiateContract2(t *testing.T) { } rsp, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(xCtx, msgInstantiate) - // then + //then if spec.expErr { require.Error(t, err) return @@ -377,7 +381,7 @@ func TestExecuteContract(t *testing.T) { addr string expErr bool }{ - "address can execute a contract": { + "adress can execute a contract": { addr: myAddress.String(), expErr: false, }, @@ -480,19 +484,7 @@ func TestUpdateAdmin(t *testing.T) { addr: myAddress.String(), expErr: false, expEvents: []abci.Event{ - { - Type: "message", - Attributes: []abci.EventAttribute{ - { - Key: []byte("module"), - Value: []byte("wasm"), - }, - { - Key: []byte("sender"), - Value: []byte(myAddress.String()), - }, - }, - }, + createMsgEvent(myAddress), { Type: "update_contract_admin", Attributes: []abci.EventAttribute{ @@ -633,10 +625,12 @@ func createMsgEvent(sender sdk.AccAddress) abci.Event { { Key: []byte("module"), Value: []byte("wasm"), + Index: false, }, { Key: []byte("sender"), Value: []byte(sender.String()), + Index: false, }, }, } From a1e14a7b77ac10655ceb9bdca5a9a7b98218dac0 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Fri, 25 Aug 2023 15:28:07 +0900 Subject: [PATCH 12/13] fix: revert --- x/wasm/keeper/msg_server_integration_test.go | 30 ++++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/x/wasm/keeper/msg_server_integration_test.go b/x/wasm/keeper/msg_server_integration_test.go index 51497538ff..9384f984e4 100644 --- a/x/wasm/keeper/msg_server_integration_test.go +++ b/x/wasm/keeper/msg_server_integration_test.go @@ -73,9 +73,7 @@ func TestInstantiateContract(t *testing.T) { wasmApp := app.Setup(false) ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) - var ( - myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) - ) + var myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) specs := map[string]struct { addr string @@ -121,7 +119,7 @@ func TestInstantiateContract(t *testing.T) { } rsp, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(xCtx, msgInstantiate) - //then + // then if spec.expErr { require.Error(t, err) return @@ -152,9 +150,7 @@ func TestInstantiateContract2(t *testing.T) { wasmApp := app.Setup(false) ctx := wasmApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) - var ( - myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) - ) + var myAddress sdk.AccAddress = make([]byte, types.ContractAddrLen) specs := map[string]struct { addr string @@ -205,7 +201,7 @@ func TestInstantiateContract2(t *testing.T) { } rsp, err = wasmApp.MsgServiceRouter().Handler(msgInstantiate)(xCtx, msgInstantiate) - //then + // then if spec.expErr { require.Error(t, err) return @@ -381,7 +377,7 @@ func TestExecuteContract(t *testing.T) { addr string expErr bool }{ - "adress can execute a contract": { + "address can execute a contract": { addr: myAddress.String(), expErr: false, }, @@ -484,7 +480,19 @@ func TestUpdateAdmin(t *testing.T) { addr: myAddress.String(), expErr: false, expEvents: []abci.Event{ - createMsgEvent(myAddress), + { + Type: "message", + Attributes: []abci.EventAttribute{ + { + Key: []byte("module"), + Value: []byte("wasm"), + }, + { + Key: []byte("sender"), + Value: []byte(myAddress.String()), + }, + }, + }, { Type: "update_contract_admin", Attributes: []abci.EventAttribute{ @@ -625,12 +633,10 @@ func createMsgEvent(sender sdk.AccAddress) abci.Event { { Key: []byte("module"), Value: []byte("wasm"), - Index: false, }, { Key: []byte("sender"), Value: []byte(sender.String()), - Index: false, }, }, } From 31d0babdf956d423c531f40f4c17dab0fb79debf Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Fri, 25 Aug 2023 15:29:45 +0900 Subject: [PATCH 13/13] fix: add Index flag --- .../keeper/msg_server_integration_test.go | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/x/wasmplus/keeper/msg_server_integration_test.go b/x/wasmplus/keeper/msg_server_integration_test.go index 0115a6dabe..ad9ca4b5a4 100644 --- a/x/wasmplus/keeper/msg_server_integration_test.go +++ b/x/wasmplus/keeper/msg_server_integration_test.go @@ -36,30 +36,34 @@ func TestStoreAndInstantiateContract(t *testing.T) { "address can instantiate a contract when permission is everybody": { addr: myAddress.String(), permission: &wasmtypes.AllowEverybody, - expEvents: []abci.Event{{ - Type: "store_code", - Attributes: []abci.EventAttribute{abci.EventAttribute{ - Key: []byte("code_checksum"), - Value: []byte("2843664c3b6c1de8bdeca672267c508aeb79bb947c87f75d8053f971d8658c89"), - Index: false, - }, { - Key: []byte("code_id"), - Value: []byte("1"), - Index: false, - }, + expEvents: []abci.Event{ + { + Type: "store_code", + Attributes: []abci.EventAttribute{ + { + Key: []byte("code_checksum"), + Value: []byte("2843664c3b6c1de8bdeca672267c508aeb79bb947c87f75d8053f971d8658c89"), + Index: false, + }, { + Key: []byte("code_id"), + Value: []byte("1"), + Index: false, + }, + }, }, - }, createMsgEvent(myAddress), + createMsgEvent(myAddress), { Type: "instantiate", - Attributes: []abci.EventAttribute{abci.EventAttribute{ - Key: []byte("_contract_address"), - Value: []byte("link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8"), - Index: false, - }, { - Key: []byte("code_id"), - Value: []byte("1"), - Index: false, - }, + Attributes: []abci.EventAttribute{ + { + Key: []byte("_contract_address"), + Value: []byte("link14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sgf2vn8"), + Index: false, + }, { + Key: []byte("code_id"), + Value: []byte("1"), + Index: false, + }, }, }, }, @@ -112,10 +116,12 @@ func createMsgEvent(sender sdk.AccAddress) abci.Event { { Key: []byte("module"), Value: []byte("wasm"), + Index: false, }, { Key: []byte("sender"), Value: []byte(sender.String()), + Index: false, }, }, }