-
Notifications
You must be signed in to change notification settings - Fork 625
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
add ParseKeyForwardRelayerAddress function + test #1046
Changes from 2 commits
90b3872
4699bd9
06b30e9
cd0f281
53067c9
983ca75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,11 +88,47 @@ func TestParseKeyFeesInEscrow(t *testing.T) { | |
} | ||
|
||
for _, tc := range testCases { | ||
packetId, err := types.ParseKeyFeesInEscrow(tc.key) | ||
packetID, err := types.ParseKeyFeesInEscrow(tc.key) | ||
|
||
if tc.expPass { | ||
require.NoError(t, err) | ||
require.Equal(t, validPacketID, packetId) | ||
require.Equal(t, validPacketID, packetID) | ||
} else { | ||
require.Error(t, err) | ||
} | ||
} | ||
} | ||
|
||
func TestParseKeyForwardRelayerAddress(t *testing.T) { | ||
|
||
testCases := []struct { | ||
name string | ||
key string | ||
expPass bool | ||
}{ | ||
{ | ||
"success", | ||
string(types.KeyForwardRelayerAddress(validPacketID)), | ||
true, | ||
}, | ||
{ | ||
"incorrect key - key split has incorrect length", | ||
string(types.KeyFeeEnabled(validPacketID.PortId, validPacketID.ChannelId)), | ||
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. nit: It might be easier to understand this case if you just wrote a raw string. e.g. "transfer/channel-9" 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. true! i can do that |
||
false, | ||
}, | ||
{ | ||
"incorrect key - sequence cannot be parsed", | ||
fmt.Sprintf("%s/%s", types.KeyFeesInEscrowChannelPrefix(validPacketID.PortId, validPacketID.ChannelId), "sequence"), | ||
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. ditto 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. actually i realised i should used the KeyForwardRelayerAddress anyway in this function -- 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. yup, since otherwise it won't pass the length check |
||
false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
packetID, err := types.ParseKeyForwardRelayerAddress(tc.key) | ||
|
||
if tc.expPass { | ||
require.NoError(t, err) | ||
require.Equal(t, validPacketID, packetID) | ||
} else { | ||
require.Error(t, err) | ||
} | ||
|
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.
It might make sense to put this function underneath
KeyForwardRealyerAddress
(or at least that's how I was organizing the code). Open to other suggestions