Skip to content

Commit

Permalink
imp: Cleanup 03-connection msg validate basic test (#3244)
Browse files Browse the repository at this point in the history
  • Loading branch information
expertdicer authored Mar 8, 2023
1 parent 8ca7344 commit 3dc9a96
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions modules/core/03-connection/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,30 +208,23 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() {
}

func (suite *MsgTestSuite) TestNewMsgConnectionOpenConfirm() {
testMsgs := []*types.MsgConnectionOpenConfirm{
types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, clientHeight, signer),
types.NewMsgConnectionOpenConfirm(connectionID, emptyProof, clientHeight, signer),
types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, ""),
types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, signer),
}

testCases := []struct {
name string
msg *types.MsgConnectionOpenConfirm
expPass bool
errMsg string
}{
{testMsgs[0], false, "invalid connection ID"},
{testMsgs[1], false, "empty proofTry"},
{testMsgs[2], false, "empty signer"},
{testMsgs[3], true, "success"},
{"invalid connection ID", types.NewMsgConnectionOpenConfirm("test/conn1", suite.proof, clientHeight, signer), false},
{"empty proofTry", types.NewMsgConnectionOpenConfirm(connectionID, emptyProof, clientHeight, signer), false},
{"empty signer", types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, ""), false},
{"success", types.NewMsgConnectionOpenConfirm(connectionID, suite.proof, clientHeight, signer), true},
}

for i, tc := range testCases {
for _, tc := range testCases {
err := tc.msg.ValidateBasic()
if tc.expPass {
suite.Require().NoError(err, "Msg %d failed: %s", i, tc.errMsg)
suite.Require().NoError(err, tc.name)
} else {
suite.Require().Error(err, "Invalid Msg %d passed: %s", i, tc.errMsg)
suite.Require().Error(err, tc.name)
}
}
}

0 comments on commit 3dc9a96

Please sign in to comment.