Skip to content

Commit

Permalink
adding additional tests with multiple versions, creating TestAccAddre…
Browse files Browse the repository at this point in the history
…ss const
  • Loading branch information
damiannolan committed Aug 24, 2022
1 parent 67dd670 commit 7160c2f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
36 changes: 28 additions & 8 deletions modules/apps/27-interchain-accounts/controller/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ import (

"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"
feetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
ibctesting "github.com/cosmos/ibc-go/v5/testing"
)

var (
testAccAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"
testMetadataString = icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)
)

func TestMsgRegisterAccountValidateBasic(t *testing.T) {
var msg *types.MsgRegisterAccount

Expand All @@ -29,6 +25,26 @@ func TestMsgRegisterAccountValidateBasic(t *testing.T) {
func() {},
true,
},
{
"success: with empty channel version",
func() {
msg.Version = ""
},
true,
},
{
"success: with fee enabled channel version",
func() {
feeMetadata := feetypes.Metadata{
FeeVersion: feetypes.Version,
AppVersion: icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID),
}

bz := feetypes.ModuleCdc.MustMarshalJSON(&feeMetadata)
msg.Version = string(bz)
},
true,
},
{
"connection id is invalid",
func() {
Expand All @@ -54,7 +70,11 @@ func TestMsgRegisterAccountValidateBasic(t *testing.T) {

for i, tc := range testCases {

msg = types.NewMsgRegisterAccount(ibctesting.FirstConnectionID, testAccAddress, testMetadataString)
msg = types.NewMsgRegisterAccount(
ibctesting.FirstConnectionID,
ibctesting.TestAccAddress,
icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID),
)

tc.malleate()

Expand All @@ -68,9 +88,9 @@ func TestMsgRegisterAccountValidateBasic(t *testing.T) {
}

func TestMsgRegisterAccountGetSigners(t *testing.T) {
expSigner, err := sdk.AccAddressFromBech32(testAccAddress)
expSigner, err := sdk.AccAddressFromBech32(ibctesting.TestAccAddress)
require.NoError(t, err)

msg := types.NewMsgRegisterAccount(ibctesting.FirstConnectionID, testAccAddress, testMetadataString)
msg := types.NewMsgRegisterAccount(ibctesting.FirstConnectionID, ibctesting.TestAccAddress, "")
require.Equal(t, []sdk.AccAddress{expSigner}, msg.GetSigners())
}
4 changes: 3 additions & 1 deletion testing/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ var (

// DefaultTrustLevel sets params variables used to create a TM client
DefaultTrustLevel = ibctm.DefaultTrustLevel
TestCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))

TestAccAddress = "cosmos17dtl0mjt3t77kpuhg2edqzjpszulwhgzuj9ljs"
TestCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))

UpgradePath = []string{"upgrade", "upgradedIBCState"}

Expand Down

0 comments on commit 7160c2f

Please sign in to comment.