-
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
chore: code coverage and minor cleanup #440
Changes from all commits
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ import ( | |
sdk "github.com/cosmos/cosmos-sdk/types" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
"github.com/stretchr/testify/suite" | ||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" | ||
ibctesting "github.com/cosmos/ibc-go/v2/testing" | ||
|
@@ -48,6 +47,13 @@ func (suite *TypesTestSuite) TestGenerateAddress() { | |
suite.Require().NotEmpty(accAddr) | ||
} | ||
|
||
func (suite *TypesTestSuite) TestParseAddressFromVersion() { | ||
version := types.NewAppVersion(types.VersionPrefix, TestOwnerAddress) | ||
|
||
addr := types.ParseAddressFromVersion(version) | ||
suite.Require().Equal(TestOwnerAddress, addr) | ||
} | ||
|
||
func (suite *TypesTestSuite) TestGeneratePortID() { | ||
var ( | ||
path *ibctesting.Path | ||
|
@@ -75,25 +81,25 @@ func (suite *TypesTestSuite) TestGeneratePortID() { | |
true, | ||
}, | ||
{ | ||
"invalid owner address", | ||
"invalid connectionID", | ||
func() { | ||
owner = " " | ||
path.EndpointA.ConnectionID = "connection" | ||
}, | ||
"", | ||
false, | ||
}, | ||
{ | ||
"invalid connectionID", | ||
"invalid counterparty connectionID", | ||
func() { | ||
path.EndpointA.ConnectionID = "connection" | ||
path.EndpointB.ConnectionID = "connection" | ||
}, | ||
"", | ||
false, | ||
}, | ||
{ | ||
"invalid counterparty connectionID", | ||
"invalid owner address", | ||
func() { | ||
path.EndpointB.ConnectionID = "connection" | ||
owner = " " | ||
}, | ||
"", | ||
false, | ||
|
@@ -172,20 +178,14 @@ func (suite *TypesTestSuite) TestGenesisAccountValidate() { | |
|
||
func (suite *TypesTestSuite) TestInterchainAccountMarshalYAML() { | ||
addr := suite.chainA.SenderAccount.GetAddress() | ||
ba := authtypes.NewBaseAccountWithAddress(addr) | ||
baseAcc := authtypes.NewBaseAccountWithAddress(addr) | ||
|
||
interchainAcc := types.NewInterchainAccount(ba, suite.chainB.SenderAccount.GetAddress().String()) | ||
bz, err := yaml.Marshal(types.InterchainAccountPretty{ | ||
Address: addr, | ||
PubKey: "", | ||
AccountNumber: interchainAcc.AccountNumber, | ||
Sequence: interchainAcc.Sequence, | ||
AccountOwner: interchainAcc.AccountOwner, | ||
}) | ||
interchainAcc := types.NewInterchainAccount(baseAcc, suite.chainB.SenderAccount.GetAddress().String()) | ||
bz, err := interchainAcc.MarshalYAML() | ||
suite.Require().NoError(err) | ||
|
||
bz1, err := interchainAcc.MarshalYAML() | ||
suite.Require().Equal(string(bz), string(bz1)) | ||
expected := fmt.Sprintf("address: %s\npublic_key: \"\"\naccount_number: 0\nsequence: 0\naccount_owner: %s\n", suite.chainA.SenderAccount.GetAddress(), suite.chainB.SenderAccount.GetAddress()) | ||
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. Making 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. yeah that's why I made it public :D Is it not better to leave it the other way? 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 think it makes more sense to maintain a "prettifying" struct as private, an external party should be unaware of its existence. Probably best to opt for consistency with the sdk. 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. consistency with sdk is my preference |
||
suite.Require().Equal(expected, string(bz)) | ||
} | ||
|
||
func (suite *TypesTestSuite) TestInterchainAccountJSON() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types" | ||
) | ||
|
||
func TestKeyActiveChannel(t *testing.T) { | ||
key := types.KeyActiveChannel("owner") | ||
require.Equal(t, string(key), "activeChannel/owner") | ||
func (suite *TypesTestSuite) TestKeyActiveChannel() { | ||
key := types.KeyActiveChannel("port-id") | ||
suite.Require().Equal("activeChannel/port-id", string(key)) | ||
} | ||
|
||
func (suite *TypesTestSuite) TestKeyOwnerAccount() { | ||
key := types.KeyOwnerAccount("port-id") | ||
suite.Require().Equal("owner/port-id", string(key)) | ||
} |
This file was deleted.
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.
Based off of #288, is this the intended usage? @seantking @colin-axner
I've added
IsBound
to expected keeper interface and re-enabled the previously commented out test.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.
Yes it is 👍 Thanks!