From 88fe2d351e042d454016a7d785d05828546c89a7 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Wed, 12 Apr 2023 14:34:22 +0900 Subject: [PATCH] Add tests on x/collection CreateContract --- x/collection/keeper/msg_server_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/x/collection/keeper/msg_server_test.go b/x/collection/keeper/msg_server_test.go index 5088b319d8..f4b60daff5 100644 --- a/x/collection/keeper/msg_server_test.go +++ b/x/collection/keeper/msg_server_test.go @@ -377,6 +377,7 @@ func (s *KeeperTestSuite) TestMsgCreateContract() { }{ "valid request": { owner: s.vendor, + events: sdk.Events{sdk.Event{Type:"create_collection", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x6e, 0x61, 0x6d, 0x65}, Value:[]uint8{}, Index:false}, abci.EventAttribute{Key:[]uint8{0x6d, 0x65, 0x74, 0x61}, Value:[]uint8{}, Index:false}, abci.EventAttribute{Key:[]uint8{0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x69, 0x64}, Value:[]uint8{0x33, 0x33, 0x33, 0x36, 0x62, 0x37, 0x36, 0x66}, Index:false}, abci.EventAttribute{Key:[]uint8{0x6f, 0x77, 0x6e, 0x65, 0x72}, Value:[]uint8{0x6c, 0x69, 0x6e, 0x6b, 0x31, 0x76, 0x39, 0x6a, 0x78, 0x67, 0x75, 0x6e, 0x39, 0x77, 0x64, 0x65, 0x6e, 0x71, 0x61, 0x32, 0x78, 0x7a, 0x66, 0x78}, Index:false}, abci.EventAttribute{Key:[]uint8{0x62, 0x61, 0x73, 0x65, 0x5f, 0x69, 0x6d, 0x67, 0x5f, 0x75, 0x72, 0x69}, Value:[]uint8{}, Index:false}}}, sdk.Event{Type:"lbm.collection.v1.EventCreatedContract", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x69, 0x64}, Value:[]uint8{0x22, 0x33, 0x33, 0x33, 0x36, 0x62, 0x37, 0x36, 0x66, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72}, Value:[]uint8{0x22, 0x6c, 0x69, 0x6e, 0x6b, 0x31, 0x76, 0x39, 0x6a, 0x78, 0x67, 0x75, 0x6e, 0x39, 0x77, 0x64, 0x65, 0x6e, 0x71, 0x61, 0x32, 0x78, 0x7a, 0x66, 0x78, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x6d, 0x65, 0x74, 0x61}, Value:[]uint8{0x22, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x6e, 0x61, 0x6d, 0x65}, Value:[]uint8{0x22, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x75, 0x72, 0x69}, Value:[]uint8{0x22, 0x22}, Index:false}}}, sdk.Event{Type:"grant_perm", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x69, 0x64}, Value:[]uint8{0x33, 0x33, 0x33, 0x36, 0x62, 0x37, 0x36, 0x66}, Index:false}, abci.EventAttribute{Key:[]uint8{0x74, 0x6f}, Value:[]uint8{0x6c, 0x69, 0x6e, 0x6b, 0x31, 0x76, 0x39, 0x6a, 0x78, 0x67, 0x75, 0x6e, 0x39, 0x77, 0x64, 0x65, 0x6e, 0x71, 0x61, 0x32, 0x78, 0x7a, 0x66, 0x78}, Index:false}}}, sdk.Event{Type:"grant_perm", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d}, Value:[]uint8{0x69, 0x73, 0x73, 0x75, 0x65}, Index:false}}}, sdk.Event{Type:"lbm.collection.v1.EventGranted", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x69, 0x64}, Value:[]uint8{0x22, 0x33, 0x33, 0x33, 0x36, 0x62, 0x37, 0x36, 0x66, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65}, Value:[]uint8{0x22, 0x6c, 0x69, 0x6e, 0x6b, 0x31, 0x76, 0x39, 0x6a, 0x78, 0x67, 0x75, 0x6e, 0x39, 0x77, 0x64, 0x65, 0x6e, 0x71, 0x61, 0x32, 0x78, 0x7a, 0x66, 0x78, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72}, Value:[]uint8{0x22, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e}, Value:[]uint8{0x22, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x22}, Index:false}}}, sdk.Event{Type:"grant_perm", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d}, Value:[]uint8{0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79}, Index:false}}}, sdk.Event{Type:"lbm.collection.v1.EventGranted", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x69, 0x64}, Value:[]uint8{0x22, 0x33, 0x33, 0x33, 0x36, 0x62, 0x37, 0x36, 0x66, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65}, Value:[]uint8{0x22, 0x6c, 0x69, 0x6e, 0x6b, 0x31, 0x76, 0x39, 0x6a, 0x78, 0x67, 0x75, 0x6e, 0x39, 0x77, 0x64, 0x65, 0x6e, 0x71, 0x61, 0x32, 0x78, 0x7a, 0x66, 0x78, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72}, Value:[]uint8{0x22, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e}, Value:[]uint8{0x22, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x59, 0x22}, Index:false}}}, sdk.Event{Type:"grant_perm", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d}, Value:[]uint8{0x6d, 0x69, 0x6e, 0x74}, Index:false}}}, sdk.Event{Type:"lbm.collection.v1.EventGranted", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x69, 0x64}, Value:[]uint8{0x22, 0x33, 0x33, 0x33, 0x36, 0x62, 0x37, 0x36, 0x66, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65}, Value:[]uint8{0x22, 0x6c, 0x69, 0x6e, 0x6b, 0x31, 0x76, 0x39, 0x6a, 0x78, 0x67, 0x75, 0x6e, 0x39, 0x77, 0x64, 0x65, 0x6e, 0x71, 0x61, 0x32, 0x78, 0x7a, 0x66, 0x78, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72}, Value:[]uint8{0x22, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e}, Value:[]uint8{0x22, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x49, 0x4e, 0x54, 0x22}, Index:false}}}, sdk.Event{Type:"grant_perm", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d}, Value:[]uint8{0x62, 0x75, 0x72, 0x6e}, Index:false}}}, sdk.Event{Type:"lbm.collection.v1.EventGranted", Attributes:[]abci.EventAttribute{abci.EventAttribute{Key:[]uint8{0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x69, 0x64}, Value:[]uint8{0x22, 0x33, 0x33, 0x33, 0x36, 0x62, 0x37, 0x36, 0x66, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65}, Value:[]uint8{0x22, 0x6c, 0x69, 0x6e, 0x6b, 0x31, 0x76, 0x39, 0x6a, 0x78, 0x67, 0x75, 0x6e, 0x39, 0x77, 0x64, 0x65, 0x6e, 0x71, 0x61, 0x32, 0x78, 0x7a, 0x66, 0x78, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72}, Value:[]uint8{0x22, 0x22}, Index:false}, abci.EventAttribute{Key:[]uint8{0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e}, Value:[]uint8{0x22, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x42, 0x55, 0x52, 0x4e, 0x22}, Index:false}}}}, }, } @@ -395,9 +396,9 @@ func (s *KeeperTestSuite) TestMsgCreateContract() { s.Require().NotNil(res) - // if s.deterministic { - // s.Require().Equal(tc.events, ctx.EventManager().Events()) - // } + if s.deterministic { + s.Require().Equal(tc.events, ctx.EventManager().Events()) + } }) } }