Skip to content

Commit

Permalink
imp(ica_test): improved tests without type assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Aug 1, 2023
1 parent 11a859a commit fbcf8b7
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions modules/apps/27-interchain-accounts/types/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (suite *TypesTestSuite) TestPacketDataProvider() {
testCases := []struct {
name string
packetData types.InterchainAccountPacketData
expCustomData map[string]interface{}
expCustomData interface{}
}{
{
"success: src_callback key in memo",
Expand All @@ -118,37 +118,36 @@ func (suite *TypesTestSuite) TestPacketDataProvider() {
},
},
{
"failure: empty memo",
"success: src_callback has string valu",
types.InterchainAccountPacketData{
Type: types.EXECUTE_TX,
Data: []byte("data"),
Memo: "",
Memo: `{"src_callback": "string"}`,
},
nil,
"string",
},
{
"failure: non-json memo",
"failure: empty memo",
types.InterchainAccountPacketData{
Type: types.EXECUTE_TX,
Data: []byte("data"),
Memo: "invalid",
Memo: "",
},
nil,
},
{
"failure: invalid src_callback key",
"failure: non-json memo",
types.InterchainAccountPacketData{
Type: types.EXECUTE_TX,
Data: []byte("data"),
Memo: `{"src_callback": "invalid"}`,
Memo: "invalid",
},
nil,
},
}

for _, tc := range testCases {
additionalData, ok := tc.packetData.GetCustomPacketData("src_callback").(map[string]interface{})
suite.Require().Equal(ok, additionalData != nil)
suite.Require().Equal(tc.expCustomData, additionalData)
customData := tc.packetData.GetCustomPacketData("src_callback")
suite.Require().Equal(tc.expCustomData, customData)
}
}

0 comments on commit fbcf8b7

Please sign in to comment.