Skip to content

Commit

Permalink
Merge branch 'master-tunnel' into tunnel-ibc
Browse files Browse the repository at this point in the history
  • Loading branch information
satawatnack committed Nov 21, 2024
2 parents f045ebf + 9bfc143 commit 4477b96
Showing 1 changed file with 0 additions and 104 deletions.
104 changes: 0 additions & 104 deletions x/tunnel/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package keeper_test

import (
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
Expand All @@ -19,107 +16,6 @@ import (
"github.com/bandprotocol/chain/v3/x/tunnel/types"
)

func TestValidateGenesis(t *testing.T) {
cases := map[string]struct {
genesis *types.GenesisState
requireErr bool
errMsg string
}{
"length of tunnels does not match tunnel count": {
genesis: &types.GenesisState{
TunnelCount: 2,
Tunnels: []types.Tunnel{
{ID: 1},
},
},
requireErr: true,
errMsg: "length of tunnels does not match tunnel count",
},
"tunnel count mismatch in tunnels": {
genesis: &types.GenesisState{
TunnelCount: 2,
Tunnels: []types.Tunnel{
{ID: 1},
{ID: 3},
},
},
requireErr: true,
errMsg: "tunnel count mismatch in tunnels",
},
"invalid total fees": {
genesis: &types.GenesisState{
TunnelCount: 1,
Tunnels: []types.Tunnel{
{ID: 1},
},
TotalFees: types.TotalFees{
TotalPacketFee: sdk.Coins{
{Denom: "uband", Amount: sdkmath.NewInt(-100)},
}, // Invalid coin
},
},
requireErr: true,
errMsg: "invalid total fees",
},
"deposits mismatch total deposit for tunnel": {
genesis: &types.GenesisState{
TunnelCount: 1,
Tunnels: []types.Tunnel{
{ID: 1, TotalDeposit: sdk.NewCoins()},
},
TotalFees: types.TotalFees{},
Deposits: []types.Deposit{
{
TunnelID: 1,
Depositor: sdk.AccAddress("account1").String(),
Amount: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))),
},
},
},
requireErr: true,
errMsg: "deposits mismatch total deposit for tunnel",
},
"all good": {
genesis: &types.GenesisState{
TunnelCount: 2,
Tunnels: []types.Tunnel{
{ID: 1, TotalDeposit: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100)))},
{ID: 2, TotalDeposit: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100)))},
},
TotalFees: types.TotalFees{
TotalPacketFee: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))),
},
Deposits: []types.Deposit{
{
TunnelID: 1,
Depositor: sdk.AccAddress("account1").String(),
Amount: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))),
},
{
TunnelID: 2,
Depositor: sdk.AccAddress("account2").String(),
Amount: sdk.NewCoins(sdk.NewCoin("uband", sdkmath.NewInt(100))),
},
},
Params: types.DefaultParams(),
},
requireErr: false,
},
}

for name, tc := range cases {
t.Run(name, func(t *testing.T) {
err := types.ValidateGenesis(*tc.genesis)
if tc.requireErr {
require.Error(t, err)
require.Contains(t, err.Error(), tc.errMsg)
} else {
require.NoError(t, err)
}
})
}
}

func (s *KeeperTestSuite) TestInitExportGenesis() {
ctx, k := s.ctx, s.keeper

Expand Down

0 comments on commit 4477b96

Please sign in to comment.