-
Notifications
You must be signed in to change notification settings - Fork 629
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
chore: adding sdk.Msg
impl for ics27 MsgRegisterAccount
#2081
Merged
damiannolan
merged 13 commits into
main
from
damian/2053-impl-sdk-msg-interface-register-acc
Aug 24, 2022
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f0eb4d1
adding new controller msg service, register account types, register i…
damiannolan 0849625
fixing typo
damiannolan 1723c74
fixing protodoc and regenerate godocs
damiannolan 154fcd9
Merge branch 'main' into damian/2051-add-register-account-protos
damiannolan bf4a521
adding channel id to MsgRegisterAccountResponse
damiannolan ffa2908
Merge branch 'damian/2051-add-register-account-protos' of github.com:…
damiannolan 52d063d
adding sdk.Msg impl for MsgRegisterAccount
damiannolan 6f4e26a
Merge branch 'main' into damian/2053-impl-sdk-msg-interface-register-acc
damiannolan 9a3aede
Merge branch 'main' into damian/2053-impl-sdk-msg-interface-register-acc
damiannolan 11a7d57
formatting imports
damiannolan 67dd670
Merge branch 'damian/2053-impl-sdk-msg-interface-register-acc' of git…
damiannolan 7160c2f
adding additional tests with multiple versions, creating TestAccAddre…
damiannolan 85f32bf
Merge branch 'main' into damian/2053-impl-sdk-msg-interface-register-acc
damiannolan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
modules/apps/27-interchain-accounts/controller/types/msgs_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types" | ||
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types" | ||
ibctesting "github.com/cosmos/ibc-go/v5/testing" | ||
) | ||
|
||
var ( | ||
testAccAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit but maybe we can add this a const file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added |
||
testMetadataString = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID) | ||
) | ||
|
||
func TestMsgRegisterAccountValidateBasic(t *testing.T) { | ||
var msg *types.MsgRegisterAccount | ||
|
||
testCases := []struct { | ||
name string | ||
malleate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"success", | ||
func() {}, | ||
true, | ||
}, | ||
colin-axner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"connection id is invalid", | ||
func() { | ||
msg.ConnectionId = "" | ||
}, | ||
false, | ||
}, | ||
{ | ||
"owner address is empty", | ||
func() { | ||
msg.Owner = "" | ||
}, | ||
false, | ||
}, | ||
{ | ||
"owner address is invalid", | ||
func() { | ||
msg.Owner = "invalid_address" | ||
}, | ||
false, | ||
}, | ||
} | ||
|
||
for i, tc := range testCases { | ||
|
||
msg = types.NewMsgRegisterAccount(ibctesting.FirstConnectionID, testAccAddress, testMetadataString) | ||
|
||
tc.malleate() | ||
|
||
err := msg.ValidateBasic() | ||
if tc.expPass { | ||
require.NoError(t, err, "valid test case %d failed: %s", i, tc.name) | ||
} else { | ||
require.Error(t, err, "invalid test case %d passed: %s", i, tc.name) | ||
} | ||
} | ||
} | ||
|
||
func TestMsgRegisterAccountGetSigners(t *testing.T) { | ||
expSigner, err := sdk.AccAddressFromBech32(testAccAddress) | ||
require.NoError(t, err) | ||
|
||
msg := types.NewMsgRegisterAccount(ibctesting.FirstConnectionID, testAccAddress, testMetadataString) | ||
require.Equal(t, []sdk.AccAddress{expSigner}, msg.GetSigners()) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we also need a validation on the version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can since this version may be wrapped with many different versions (ics29 and so forth). There's no guarantee that the provided version is an ics27 version at the top level