Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup 03-connection msg validate basic test #3244

Merged
merged 3 commits into from
Mar 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}