Some checks failed
CodeQL / Analyze (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Deploy to GitHub Pages / Deploy to GitHub Pages (push) Has been cancelled
Buf-Push / push (push) Has been cancelled
59 lines
1.9 KiB
Go
59 lines
1.9 KiB
Go
package keeper_test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
sdkmath "cosmossdk.io/math"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
|
|
)
|
|
|
|
func (suite *KeeperTestSuite) TestGenesis() {
|
|
getHop := func(index uint) types.Hop {
|
|
return types.NewHop("transfer", fmt.Sprintf("channelToChain%d", index))
|
|
}
|
|
|
|
var (
|
|
denoms types.Denoms
|
|
escrows sdk.Coins
|
|
traceAndEscrowAmounts = []struct {
|
|
trace []types.Hop
|
|
escrow string
|
|
}{
|
|
{[]types.Hop{getHop(0)}, "10"},
|
|
{[]types.Hop{getHop(1), getHop(0)}, "100000"},
|
|
{[]types.Hop{getHop(2), getHop(1), getHop(0)}, "10000000000"},
|
|
{[]types.Hop{getHop(3), getHop(2), getHop(1), getHop(0)}, "1000000000000000"},
|
|
{[]types.Hop{getHop(4), getHop(3), getHop(2), getHop(1), getHop(0)}, "100000000000000000000"},
|
|
}
|
|
)
|
|
|
|
for _, traceAndEscrowAmount := range traceAndEscrowAmounts {
|
|
denom := types.NewDenom("uatom", traceAndEscrowAmount.trace...)
|
|
denoms = append(denoms, denom)
|
|
suite.chainA.GetSimApp().TransferKeeper.SetDenom(suite.chainA.GetContext(), denom)
|
|
|
|
amount, ok := sdkmath.NewIntFromString(traceAndEscrowAmount.escrow)
|
|
suite.Require().True(ok)
|
|
escrow := sdk.NewCoin(denom.IBCDenom(), amount)
|
|
escrows = append(escrows, escrow)
|
|
suite.chainA.GetSimApp().TransferKeeper.SetTotalEscrowForDenom(suite.chainA.GetContext(), escrow)
|
|
}
|
|
|
|
genesis := suite.chainA.GetSimApp().TransferKeeper.ExportGenesis(suite.chainA.GetContext())
|
|
|
|
suite.Require().Equal(types.PortID, genesis.PortId)
|
|
suite.Require().Equal(denoms.Sort(), genesis.Denoms)
|
|
suite.Require().Equal(escrows.Sort(), genesis.TotalEscrowed)
|
|
|
|
suite.Require().NotPanics(func() {
|
|
suite.chainA.GetSimApp().TransferKeeper.InitGenesis(suite.chainA.GetContext(), *genesis)
|
|
})
|
|
|
|
for _, denom := range denoms {
|
|
_, found := suite.chainA.GetSimApp().BankKeeper.GetDenomMetaData(suite.chainA.GetContext(), denom.IBCDenom())
|
|
suite.Require().True(found)
|
|
}
|
|
}
|