From 0fbce7f981d6ee9ea9a7330f1e0b525aea9b1034 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Thu, 14 Apr 2022 12:43:36 -0600 Subject: [PATCH] Fix gas assertions. Move juno tests to trophies folder. Make relay test end to end (both directions IBC). cleanup --- go.mod | 13 +-- go.sum | 21 +++-- ibc/Chain.go | 3 + ibc/Relayer.go | 3 + ibc/cosmos_chain.go | 7 ++ ibc/cosmos_relayer.go | 11 ++- ibc/test_node.go | 10 +-- ibc/test_relay.go | 154 +++++++++++++++++++++++++-------- ibc/test_setup.go | 74 ++++++++++++---- {ibc => trophies}/test_juno.go | 45 +++++----- 10 files changed, 244 insertions(+), 97 deletions(-) rename {ibc => trophies}/test_juno.go (87%) diff --git a/go.mod b/go.mod index cc24fdf8f..96826db0e 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/cosmos/cosmos-sdk v0.45.1 github.com/cosmos/ibc-go/v3 v3.0.0 github.com/ory/dockertest v3.3.5+incompatible + github.com/spf13/cobra v1.4.0 github.com/stretchr/testify v1.7.0 github.com/tendermint/tendermint v0.34.14 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c @@ -54,6 +55,7 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.3 // indirect github.com/google/btree v1.0.0 // indirect + github.com/google/go-cmp v0.5.7 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect @@ -95,7 +97,6 @@ require ( github.com/sirupsen/logrus v1.8.1 // indirect github.com/spf13/afero v1.6.0 // indirect github.com/spf13/cast v1.4.1 // indirect - github.com/spf13/cobra v1.4.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.10.1 // indirect @@ -109,12 +110,12 @@ require ( github.com/tendermint/tm-db v0.6.4 // indirect github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.5 // indirect - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect - golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect - golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect - golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect + golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect + golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect + golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect + google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.66.2 // indirect diff --git a/go.sum b/go.sum index f647ea3a7..cd33717a2 100644 --- a/go.sum +++ b/go.sum @@ -394,8 +394,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= @@ -833,7 +834,6 @@ github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tL github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= -github.com/spf13/cobra v1.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0= github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= @@ -969,8 +969,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 h1:syTAU9FwmvzEoIYMqcPHOcVm4H3U5u90WsvuYgwpETU= +golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1067,8 +1068,10 @@ golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f h1:w6wWR0H+nyVpbSAQbzVEIACVyr/h8l/BEkY6Sokc7Eg= golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1192,11 +1195,14 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1391,8 +1397,9 @@ google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa h1:I0YcKz0I7OAhddo7ya8kMnvprhcWM045PmkBdMO9zN0= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf h1:SVYXkUz2yZS9FWb2Gm8ivSlbNQzL2Z/NpPKE3RG2jWk= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= diff --git a/ibc/Chain.go b/ibc/Chain.go index 3a76cc4a2..ff5d5a03d 100644 --- a/ibc/Chain.go +++ b/ibc/Chain.go @@ -88,6 +88,9 @@ type Chain interface { // fetch balance for a specific account address and denom GetBalance(ctx context.Context, address string, denom string) (int64, error) + // get the fees in native denom for an amount of spent gas + GetGasFeesInNativeDenom(gasPaid int64) int64 + // fetch transaction GetTransaction(ctx context.Context, txHash string) (*types.TxResponse, error) } diff --git a/ibc/Relayer.go b/ibc/Relayer.go index 99453ff95..3d1683d63 100644 --- a/ibc/Relayer.go +++ b/ibc/Relayer.go @@ -40,6 +40,9 @@ type Relayer interface { // setup channels, connections, and clients LinkPath(ctx context.Context, pathName string) error + // update clients, such as after new genesis + UpdateClients(ctx context.Context, pathName string) error + // get channel IDs for chain GetChannels(ctx context.Context, chainID string) ([]ChannelOutput, error) diff --git a/ibc/cosmos_chain.go b/ibc/cosmos_chain.go index e8a9e94d2..e715bf2d8 100644 --- a/ibc/cosmos_chain.go +++ b/ibc/cosmos_chain.go @@ -12,6 +12,7 @@ import ( "path" "sort" "strconv" + "strings" "time" "github.com/cosmos/cosmos-sdk/types" @@ -176,6 +177,12 @@ func (c *CosmosChain) GetTransaction(ctx context.Context, txHash string) (*types return authTx.QueryTx(c.getRelayerNode().CliContext(), txHash) } +func (c *CosmosChain) GetGasFeesInNativeDenom(gasPaid int64) int64 { + gasPrice, _ := strconv.ParseFloat(strings.Replace(c.cfg.GasPrices, c.cfg.Denom, "", 1), 64) + fees := float64(gasPaid) * gasPrice + return int64(fees) +} + // creates the test node objects required for bootstrapping tests func (c *CosmosChain) initializeChainNodes(testName, home string, pool *dockertest.Pool, networkID string) { diff --git a/ibc/cosmos_relayer.go b/ibc/cosmos_relayer.go index ee666ece3..88e0d9808 100644 --- a/ibc/cosmos_relayer.go +++ b/ibc/cosmos_relayer.go @@ -48,7 +48,7 @@ type CosmosRelayerChainConfig struct { var ( containerImage = "ghcr.io/cosmos/relayer" - containerVersion = "latest" + containerVersion = "v2.0.0-beta4" ) func ChainConfigToCosmosRelayerChainConfig(chainConfig ChainConfig, keyName, rpcAddr, gprcAddr string) CosmosRelayerChainConfig { @@ -188,6 +188,13 @@ func (relayer *CosmosRelayer) GeneratePath(ctx context.Context, srcChainID, dstC return handleNodeJobError(relayer.NodeJob(ctx, command)) } +func (relayer *CosmosRelayer) UpdateClients(ctx context.Context, pathName string) error { + command := []string{"rly", "tx", "update-clients", pathName, + "--home", relayer.NodeHome(), + } + return handleNodeJobError(relayer.NodeJob(ctx, command)) +} + func (relayer *CosmosRelayer) CreateNodeContainer(pathName string) error { err := relayer.pool.Client.PullImage(docker.PullImageOptions{ Repository: containerImage, @@ -197,7 +204,7 @@ func (relayer *CosmosRelayer) CreateNodeContainer(pathName string) error { return err } containerName := fmt.Sprintf("%s-%s", relayer.Name(), pathName) - cmd := []string{"rly", "start", pathName, "--home", relayer.NodeHome()} + cmd := []string{"rly", "start", pathName, "--home", relayer.NodeHome(), "--debug"} fmt.Printf("{%s} -> '%s'\n", containerName, strings.Join(cmd, " ")) cont, err := relayer.pool.Client.CreateContainer(docker.CreateContainerOptions{ Name: containerName, diff --git a/ibc/test_node.go b/ibc/test_node.go index 980fa63c1..79b20af93 100644 --- a/ibc/test_node.go +++ b/ibc/test_node.go @@ -313,7 +313,7 @@ func (tn *ChainNode) SendIBCTransfer(ctx context.Context, channelID string, keyN amount.Address, fmt.Sprintf("%d%s", amount.Amount, amount.Denom), "--keyring-backend", keyring.BackendTest, "--gas-prices", tn.Chain.Config().GasPrices, - "--gas", fmt.Sprint(10000000000), + "--gas-adjustment", fmt.Sprint(tn.Chain.Config().GasAdjustment), "--node", fmt.Sprintf("tcp://%s:26657", tn.Name()), "--from", keyName, "--output", "json", @@ -417,7 +417,7 @@ func (tn *ChainNode) InstantiateContract(ctx context.Context, keyName string, am command := []string{tn.Chain.Config().Bin, "tx", "wasm", "store", newFilePathContainer, "--from", keyName, "--gas-prices", tn.Chain.Config().GasPrices, - "--gas", fmt.Sprint(10000000000), + "--gas-adjustment", fmt.Sprint(tn.Chain.Config().GasAdjustment), "--keyring-backend", keyring.BackendTest, "--node", fmt.Sprintf("tcp://%s:26657", tn.Name()), "--output", "json", @@ -458,7 +458,7 @@ func (tn *ChainNode) InstantiateContract(ctx context.Context, keyName string, am command = []string{tn.Chain.Config().Bin, "tx", "wasm", "instantiate", codeID, initMessage, "--gas-prices", tn.Chain.Config().GasPrices, - "--gas", fmt.Sprint(10000000000), + "--gas-adjustment", fmt.Sprint(tn.Chain.Config().GasAdjustment), "--label", "satoshi-test", "--from", keyName, "--keyring-backend", keyring.BackendTest, @@ -509,7 +509,7 @@ func (tn *ChainNode) ExecuteContract(ctx context.Context, keyName string, contra "tx", "wasm", "execute", contractAddress, message, "--from", keyName, "--gas-prices", tn.Chain.Config().GasPrices, - "--gas", fmt.Sprint(10000000000), + "--gas-adjustment", fmt.Sprint(tn.Chain.Config().GasAdjustment), "--keyring-backend", keyring.BackendTest, "--node", fmt.Sprintf("tcp://%s:26657", tn.Name()), "--output", "json", @@ -581,7 +581,7 @@ func (tn *ChainNode) CreatePool(ctx context.Context, keyName string, contractAdd "tx", "gamm", "create-pool", "--pool-file", poolFilePath, "--gas-prices", tn.Chain.Config().GasPrices, - "--gas", fmt.Sprint(10000000000), + "--gas-adjustment", fmt.Sprint(tn.Chain.Config().GasAdjustment), "--from", keyName, "--keyring-backend", keyring.BackendTest, "--node", fmt.Sprintf("tcp://%s:26657", tn.Name()), diff --git a/ibc/test_relay.go b/ibc/test_relay.go index d908233c4..33f910c24 100644 --- a/ibc/test_relay.go +++ b/ibc/test_relay.go @@ -19,7 +19,7 @@ func (ibc IBCTestCase) RelayPacketTest(testName string, srcChain Chain, dstChain // funds relayer src and dst wallets on respective chain in genesis // creates a user account on the src chain (separate fullnode) // funds user account on src chain in genesis - _, channels, user, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, nil) + _, channels, srcUser, dstUser, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, nil) if err != nil { return err } @@ -27,34 +27,34 @@ func (ibc IBCTestCase) RelayPacketTest(testName string, srcChain Chain, dstChain // will test a user sending an ibc transfer from the src chain to the dst chain // denom will be src chain native denom - testDenom := srcChain.Config().Denom + testDenomSrc := srcChain.Config().Denom // query initial balance of user wallet for src chain native denom on the src chain - srcInitialBalance, err := srcChain.GetBalance(ctx, user.SrcChainAddress, testDenom) + srcInitialBalance, err := srcChain.GetBalance(ctx, srcUser.SrcChainAddress, testDenomSrc) if err != nil { return err } // get ibc denom for test denom on dst chain - denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channels[0].Counterparty.PortID, channels[0].Counterparty.ChannelID, testDenom)) + denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channels[0].Counterparty.PortID, channels[0].Counterparty.ChannelID, testDenomSrc)) dstIbcDenom := denomTrace.IBCDenom() // query initial balance of user wallet for src chain native denom on the dst chain // don't care about error here, account does not exist on destination chain - dstInitialBalance, _ := dstChain.GetBalance(ctx, user.DstChainAddress, dstIbcDenom) + dstInitialBalance, _ := dstChain.GetBalance(ctx, srcUser.DstChainAddress, dstIbcDenom) fmt.Printf("Initial balances: Src chain: %d\nDst chain: %d\n", srcInitialBalance, dstInitialBalance) // test coin, address is recipient of ibc transfer on dst chain - testCoin := WalletAmount{ - Address: user.DstChainAddress, - Denom: testDenom, + testCoinSrc := WalletAmount{ + Address: srcUser.DstChainAddress, + Denom: testDenomSrc, Amount: 1000000, } // send ibc transfer from the user wallet using its fullnode // timeout is nil so that it will use the default timeout - txHash, err := srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, user.KeyName, testCoin, nil) + srcTxHash, err := srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, srcUser.KeyName, testCoinSrc, nil) if err != nil { return err } @@ -65,31 +65,106 @@ func (ibc IBCTestCase) RelayPacketTest(testName string, srcChain Chain, dstChain } // fetch ibc transfer tx - srcTx, err := srcChain.GetTransaction(ctx, txHash) + srcTx, err := srcChain.GetTransaction(ctx, srcTxHash) if err != nil { return err } fmt.Printf("Transaction:\n%v\n", srcTx) - // query final balance of user wallet for src chain native denom on the src chain - srcFinalBalance, err := srcChain.GetBalance(ctx, user.SrcChainAddress, testDenom) + // query final balance of src user wallet for src chain native denom on the src chain + srcFinalBalance, err := srcChain.GetBalance(ctx, srcUser.SrcChainAddress, testDenomSrc) if err != nil { return err } - // query final balance of user wallet for src chain native denom on the dst chain - dstFinalBalance, err := dstChain.GetBalance(ctx, user.DstChainAddress, dstIbcDenom) + // query final balance of src user wallet for src chain native denom on the dst chain + dstFinalBalance, err := dstChain.GetBalance(ctx, srcUser.DstChainAddress, dstIbcDenom) if err != nil { return err } - if srcFinalBalance != srcInitialBalance-testCoin.Amount { - return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcInitialBalance-testCoin.Amount, srcFinalBalance) + totalFees := srcChain.GetGasFeesInNativeDenom(srcTx.GasWanted) + expectedDifference := testCoinSrc.Amount + totalFees + + if srcFinalBalance != srcInitialBalance-expectedDifference { + return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcInitialBalance-expectedDifference, srcFinalBalance) } - if dstFinalBalance != dstInitialBalance+testCoin.Amount { - return fmt.Errorf("destination balances do not match. expected: %d, actual: %d", dstInitialBalance+testCoin.Amount, dstFinalBalance) + if dstFinalBalance != dstInitialBalance+testCoinSrc.Amount { + return fmt.Errorf("destination balances do not match. expected: %d, actual: %d", dstInitialBalance+testCoinSrc.Amount, dstFinalBalance) + } + + // Now relay from dst chain to src chain using dst user wallet + + // will test a user sending an ibc transfer from the dst chain to the src chain + // denom will be dst chain native denom + testDenomDst := dstChain.Config().Denom + + // query initial balance of dst user wallet for dst chain native denom on the dst chain + dstInitialBalance, err = dstChain.GetBalance(ctx, dstUser.DstChainAddress, testDenomDst) + if err != nil { + return err + } + + // get ibc denom for test denom on src chain + srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom(channels[0].PortID, channels[0].ChannelID, testDenomDst)) + srcIbcDenom := srcDenomTrace.IBCDenom() + + // query initial balance of user wallet for src chain native denom on the dst chain + // don't care about error here, account does not exist on destination chain + srcInitialBalance, _ = srcChain.GetBalance(ctx, dstUser.SrcChainAddress, srcIbcDenom) + + fmt.Printf("Initial balances: Src chain: %d\nDst chain: %d\n", srcInitialBalance, dstInitialBalance) + + // test coin, address is recipient of ibc transfer on src chain + testCoinDst := WalletAmount{ + Address: dstUser.SrcChainAddress, + Denom: testDenomDst, + Amount: 1000000, + } + + // send ibc transfer from the dst user wallet using its fullnode + // timeout is nil so that it will use the default timeout + dstTxHash, err := dstChain.SendIBCTransfer(ctx, channels[0].Counterparty.ChannelID, dstUser.KeyName, testCoinDst, nil) + if err != nil { + return err + } + + // wait for both chains to produce 10 blocks + if err := WaitForBlocks(srcChain, dstChain, 10); err != nil { + return err + } + + // fetch ibc transfer tx + dstTx, err := dstChain.GetTransaction(ctx, dstTxHash) + if err != nil { + return err + } + + fmt.Printf("Transaction:\n%v\n", dstTx) + + // query final balance of dst user wallet for dst chain native denom on the dst chain + dstFinalBalance, err = dstChain.GetBalance(ctx, dstUser.DstChainAddress, testDenomDst) + if err != nil { + return err + } + + // query final balance of dst user wallet for dst chain native denom on the src chain + srcFinalBalance, err = srcChain.GetBalance(ctx, dstUser.SrcChainAddress, srcIbcDenom) + if err != nil { + return err + } + + totalFeesDst := dstChain.GetGasFeesInNativeDenom(dstTx.GasWanted) + expectedDifference = testCoinDst.Amount + totalFeesDst + + if dstFinalBalance != dstInitialBalance-expectedDifference { + return fmt.Errorf("destination balances do not match. expected: %d, actual: %d", dstInitialBalance-expectedDifference, dstFinalBalance) + } + + if srcFinalBalance != srcInitialBalance+testCoinDst.Amount { + return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcInitialBalance+testCoinDst.Amount, srcFinalBalance) } return nil @@ -110,9 +185,9 @@ func (ibc IBCTestCase) RelayPacketTestNoTimeout(testName string, srcChain Chain, var testCoin WalletAmount // Query user account balances on both chains and send IBC transfer before starting the relayer - preRelayerStart := func(channels []ChannelOutput, user User) error { + preRelayerStart := func(channels []ChannelOutput, srcUser User, dstUser User) error { var err error - srcInitialBalance, err = srcChain.GetBalance(ctx, user.SrcChainAddress, testDenom) + srcInitialBalance, err = srcChain.GetBalance(ctx, srcUser.SrcChainAddress, testDenom) if err != nil { return err } @@ -122,23 +197,23 @@ func (ibc IBCTestCase) RelayPacketTestNoTimeout(testName string, srcChain Chain, dstIbcDenom = denomTrace.IBCDenom() // don't care about error here, account does not exist on destination chain - dstInitialBalance, _ = dstChain.GetBalance(ctx, user.DstChainAddress, dstIbcDenom) + dstInitialBalance, _ = dstChain.GetBalance(ctx, srcUser.DstChainAddress, dstIbcDenom) fmt.Printf("Initial balances: Src chain: %d\nDst chain: %d\n", srcInitialBalance, dstInitialBalance) testCoin = WalletAmount{ - Address: user.DstChainAddress, + Address: srcUser.DstChainAddress, Denom: testDenom, Amount: 1000000, } // send ibc transfer with both timeouts disabled - txHash, err = srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, user.KeyName, testCoin, &IBCTimeout{Height: 0, NanoSeconds: 0}) + txHash, err = srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, srcUser.KeyName, testCoin, &IBCTimeout{Height: 0, NanoSeconds: 0}) return err } // Startup both chains and relayer - _, _, user, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, preRelayerStart) + _, _, user, _, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, preRelayerStart) if err != nil { return err } @@ -167,8 +242,11 @@ func (ibc IBCTestCase) RelayPacketTestNoTimeout(testName string, srcChain Chain, return err } - if srcFinalBalance != srcInitialBalance-testCoin.Amount { - return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcInitialBalance-testCoin.Amount, srcFinalBalance) + totalFees := srcChain.GetGasFeesInNativeDenom(srcTx.GasWanted) + expectedDifference := testCoin.Amount + totalFees + + if srcFinalBalance != srcInitialBalance-expectedDifference { + return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcInitialBalance-expectedDifference, srcFinalBalance) } if dstFinalBalance != dstInitialBalance+testCoin.Amount { @@ -192,9 +270,9 @@ func (ibc IBCTestCase) RelayPacketTestHeightTimeout(testName string, srcChain Ch var dstIbcDenom string // Query user account balances on both chains and send IBC transfer before starting the relayer - preRelayerStart := func(channels []ChannelOutput, user User) error { + preRelayerStart := func(channels []ChannelOutput, srcUser User, dstUser User) error { var err error - srcInitialBalance, err = srcChain.GetBalance(ctx, user.SrcChainAddress, testDenom) + srcInitialBalance, err = srcChain.GetBalance(ctx, srcUser.SrcChainAddress, testDenom) if err != nil { return err } @@ -204,18 +282,18 @@ func (ibc IBCTestCase) RelayPacketTestHeightTimeout(testName string, srcChain Ch dstIbcDenom = denomTrace.IBCDenom() // don't care about error here, account does not exist on destination chain - dstInitialBalance, _ = dstChain.GetBalance(ctx, user.DstChainAddress, dstIbcDenom) + dstInitialBalance, _ = dstChain.GetBalance(ctx, srcUser.DstChainAddress, dstIbcDenom) fmt.Printf("Initial balances: Src chain: %d\nDst chain: %d\n", srcInitialBalance, dstInitialBalance) testCoin := WalletAmount{ - Address: user.DstChainAddress, + Address: srcUser.DstChainAddress, Denom: testDenom, Amount: 1000000, } // send ibc transfer with a timeout of 10 blocks from now on counterparty chain - txHash, err = srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, user.KeyName, testCoin, &IBCTimeout{Height: 10}) + txHash, err = srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, srcUser.KeyName, testCoin, &IBCTimeout{Height: 10}) if err != nil { return err } @@ -226,7 +304,7 @@ func (ibc IBCTestCase) RelayPacketTestHeightTimeout(testName string, srcChain Ch } // Startup both chains and relayer - _, _, user, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, preRelayerStart) + _, _, user, _, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, preRelayerStart) if err != nil { return err } @@ -281,9 +359,9 @@ func (ibc IBCTestCase) RelayPacketTestTimestampTimeout(testName string, srcChain var dstIbcDenom string // Query user account balances on both chains and send IBC transfer before starting the relayer - preRelayerStart := func(channels []ChannelOutput, user User) error { + preRelayerStart := func(channels []ChannelOutput, srcUser User, dstUser User) error { var err error - srcInitialBalance, err = srcChain.GetBalance(ctx, user.SrcChainAddress, testDenom) + srcInitialBalance, err = srcChain.GetBalance(ctx, srcUser.SrcChainAddress, testDenom) if err != nil { return err } @@ -293,18 +371,18 @@ func (ibc IBCTestCase) RelayPacketTestTimestampTimeout(testName string, srcChain dstIbcDenom = denomTrace.IBCDenom() // don't care about error here, account does not exist on destination chain - dstInitialBalance, _ = dstChain.GetBalance(ctx, user.DstChainAddress, dstIbcDenom) + dstInitialBalance, _ = dstChain.GetBalance(ctx, srcUser.DstChainAddress, dstIbcDenom) fmt.Printf("Initial balances: Src chain: %d\nDst chain: %d\n", srcInitialBalance, dstInitialBalance) testCoin := WalletAmount{ - Address: user.DstChainAddress, + Address: srcUser.DstChainAddress, Denom: testDenom, Amount: 1000000, } // send ibc transfer with a timeout of 10 blocks from now on counterparty chain - txHash, err = srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, user.KeyName, testCoin, &IBCTimeout{NanoSeconds: uint64((10 * time.Second).Nanoseconds())}) + txHash, err = srcChain.SendIBCTransfer(ctx, channels[0].ChannelID, srcUser.KeyName, testCoin, &IBCTimeout{NanoSeconds: uint64((10 * time.Second).Nanoseconds())}) if err != nil { return err } @@ -316,7 +394,7 @@ func (ibc IBCTestCase) RelayPacketTestTimestampTimeout(testName string, srcChain } // Startup both chains and relayer - _, _, user, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, preRelayerStart) + _, _, user, _, rlyCleanup, err := StartChainsAndRelayer(testName, ctx, pool, network, home, srcChain, dstChain, relayerImplementation, preRelayerStart) if err != nil { return err } diff --git a/ibc/test_setup.go b/ibc/test_setup.go index 901b501ef..371c2138f 100644 --- a/ibc/test_setup.go +++ b/ibc/test_setup.go @@ -112,8 +112,8 @@ func StartChainsAndRelayer( srcChain Chain, dstChain Chain, relayerImplementation RelayerImplementation, - preRelayerStart func(channels []ChannelOutput, user User) error, -) (Relayer, []ChannelOutput, User, func(), error) { + preRelayerStart func([]ChannelOutput, User, User) error, +) (Relayer, []ChannelOutput, *User, *User, func(), error) { var relayerImpl Relayer switch relayerImplementation { case CosmosRly: @@ -129,8 +129,8 @@ func StartChainsAndRelayer( // not yet supported } - errResponse := func(err error) (Relayer, []ChannelOutput, User, func(), error) { - return nil, []ChannelOutput{}, User{}, nil, err + errResponse := func(err error) (Relayer, []ChannelOutput, *User, *User, func(), error) { + return nil, []ChannelOutput{}, nil, nil, nil, err } if err := srcChain.Initialize(testName, home, pool, networkID); err != nil { @@ -170,14 +170,14 @@ func StartChainsAndRelayer( } // Fund relayer account on src chain - srcWallet := WalletAmount{ + srcRelayerWalletAmount := WalletAmount{ Address: srcAccount, Denom: srcChainCfg.Denom, Amount: 10000000, } // Fund relayer account on dst chain - dstWallet := WalletAmount{ + dstRelayerWalletAmount := WalletAmount{ Address: dstAccount, Denom: dstChainCfg.Denom, Amount: 10000000, @@ -187,41 +187,74 @@ func StartChainsAndRelayer( if err := srcChain.CreateKey(ctx, userAccountKeyName); err != nil { return errResponse(err) } - userAccountAddressBytes, err := srcChain.GetAddress(userAccountKeyName) + + srcUserAccountAddressBytes, err := srcChain.GetAddress(userAccountKeyName) + if err != nil { + return errResponse(err) + } + + srcUserAccountSrc, err := types.Bech32ifyAddressBytes(srcChainCfg.Bech32Prefix, srcUserAccountAddressBytes) + if err != nil { + return errResponse(err) + } + + srcUserAccountDst, err := types.Bech32ifyAddressBytes(dstChainCfg.Bech32Prefix, srcUserAccountAddressBytes) if err != nil { return errResponse(err) } - userAccountSrc, err := types.Bech32ifyAddressBytes(srcChainCfg.Bech32Prefix, userAccountAddressBytes) + if err := dstChain.CreateKey(ctx, userAccountKeyName); err != nil { + return errResponse(err) + } + + dstUserAccountAddressBytes, err := dstChain.GetAddress(userAccountKeyName) if err != nil { return errResponse(err) } - userAccountDst, err := types.Bech32ifyAddressBytes(dstChainCfg.Bech32Prefix, userAccountAddressBytes) + dstUserAccountSrc, err := types.Bech32ifyAddressBytes(srcChainCfg.Bech32Prefix, dstUserAccountAddressBytes) if err != nil { return errResponse(err) } - user := User{ + dstUserAccountDst, err := types.Bech32ifyAddressBytes(dstChainCfg.Bech32Prefix, dstUserAccountAddressBytes) + if err != nil { + return errResponse(err) + } + + srcUser := User{ KeyName: userAccountKeyName, - SrcChainAddress: userAccountSrc, - DstChainAddress: userAccountDst, + SrcChainAddress: srcUserAccountSrc, + DstChainAddress: srcUserAccountDst, + } + + dstUser := User{ + KeyName: userAccountKeyName, + SrcChainAddress: dstUserAccountSrc, + DstChainAddress: dstUserAccountDst, } // Fund user account on src chain in order to relay from src to dst - userWalletSrc := WalletAmount{ - Address: userAccountSrc, + srcUserWalletAmount := WalletAmount{ + Address: srcUserAccountSrc, Denom: srcChainCfg.Denom, Amount: 10000000000, } + // Fund user account on dst chain in order to relay from dst to src + dstUserWalletAmount := WalletAmount{ + Address: dstUserAccountDst, + Denom: dstChainCfg.Denom, + Amount: 10000000000, + } + // start chains from genesis, wait until they are producing blocks chainsGenesisWaitGroup := errgroup.Group{} chainsGenesisWaitGroup.Go(func() error { - return srcChain.Start(testName, ctx, []WalletAmount{srcWallet, userWalletSrc}) + return srcChain.Start(testName, ctx, []WalletAmount{srcRelayerWalletAmount, srcUserWalletAmount}) }) chainsGenesisWaitGroup.Go(func() error { - return dstChain.Start(testName, ctx, []WalletAmount{dstWallet}) + return dstChain.Start(testName, ctx, []WalletAmount{dstRelayerWalletAmount, dstUserWalletAmount}) }) if err := chainsGenesisWaitGroup.Wait(); err != nil { @@ -241,7 +274,7 @@ func StartChainsAndRelayer( } if preRelayerStart != nil { - if err := preRelayerStart(channels, user); err != nil { + if err := preRelayerStart(channels, srcUser, dstUser); err != nil { return errResponse(err) } } @@ -260,7 +293,7 @@ func StartChainsAndRelayer( } } - return relayerImpl, channels, user, relayerCleanup, nil + return relayerImpl, channels, &srcUser, &dstUser, relayerCleanup, nil } func WaitForBlocks(srcChain Chain, dstChain Chain, blocksToWait int64) error { @@ -309,6 +342,7 @@ func CreateTestNetwork(pool *dockertest.Pool, name string, testName string) (*do // Cleanup will clean up Docker containers, networks, and the other various config files generated in testing func Cleanup(testName string, pool *dockertest.Pool, testDir string) func() { return func() { + showContainerLogs := os.Getenv("SHOW_CONTAINER_LOGS") cont, _ := pool.Client.ListContainers(docker.ListContainersOptions{All: true}) ctx := context.Background() for _, c := range cont { @@ -320,7 +354,9 @@ func Cleanup(testName string, pool *dockertest.Pool, testDir string) func() { stderr := new(bytes.Buffer) _ = pool.Client.Logs(docker.LogsOptions{Context: ctx, Container: c.ID, OutputStream: stdout, ErrorStream: stderr, Stdout: true, Stderr: true, Tail: "50", Follow: false, Timestamps: false}) names := strings.Join(c.Names, ",") - fmt.Printf("{%s} - stdout:\n%s\n{%s} - stderr:\n%s\n", names, stdout, names, stderr) + if showContainerLogs != "" { + fmt.Printf("{%s} - stdout:\n%s\n{%s} - stderr:\n%s\n", names, stdout, names, stderr) + } _ = pool.Client.RemoveContainer(docker.RemoveContainerOptions{ID: c.ID}) } } diff --git a/ibc/test_juno.go b/trophies/test_juno.go similarity index 87% rename from ibc/test_juno.go rename to trophies/test_juno.go index facb739c3..c26ca2865 100644 --- a/ibc/test_juno.go +++ b/trophies/test_juno.go @@ -1,4 +1,4 @@ -package ibc +//go:build exclude import ( "encoding/base64" @@ -219,13 +219,16 @@ func (ibc IBCTestCase) JunoHaltNewGenesis(testName string, _ Chain, _ Chain, rel fmt.Printf("First balance check: Source: %d, Destination: %d\n", srcFinalBalance, dstFinalBalance) - // if srcFinalBalance != srcInitialBalance-testCoin.Amount { - // return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcInitialBalance-testCoin.Amount, srcFinalBalance) - // } + totalFees := srcChain.GetGasFeesInNativeDenom(srcTx.GasWanted) + expectedDifference := testCoin.Amount + totalFees - // if dstFinalBalance != dstInitialBalance+testCoin.Amount { - // return fmt.Errorf("destination balances do not match. expected: %d, actual: %d", dstInitialBalance+testCoin.Amount, dstFinalBalance) - // } + if srcFinalBalance != srcInitialBalance-expectedDifference { + return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcInitialBalance-expectedDifference, srcFinalBalance) + } + + if dstFinalBalance != dstInitialBalance+testCoin.Amount { + return fmt.Errorf("destination balances do not match. expected: %d, actual: %d", dstInitialBalance+testCoin.Amount, dstFinalBalance) + } // IBC is confirmed working on 2.1.0, now use bad contract to halt chain @@ -266,7 +269,8 @@ func (ibc IBCTestCase) JunoHaltNewGenesis(testName string, _ Chain, _ Chain, rel } fmt.Printf("Contract data: %s\n", contractData) - // run increment a bunch of times + // run increment a bunch of times. + // Actual mainnet halt included this, but this test shows they are not necessary to cause halt // for i := 0; i < 5; i++ { // if err := srcChain.ExecuteContract(ctx, userAccountKeyName, contractAddress, "{\"increment\":{}}"); err != nil { // return err @@ -306,12 +310,12 @@ func (ibc IBCTestCase) JunoHaltNewGenesis(testName string, _ Chain, _ Chain, rel newGenesisJson = strings.ReplaceAll(newGenesisJson, fmt.Sprintf("\"initial_height\":%d", 0), fmt.Sprintf("\"initial_height\":%d", haltHeight+2)) - juno3Chain, err := GetChain(testName, "juno", "v3.0.0-alpha", "juno-1", 10, 1) + juno3Chain, err := GetChain(testName, "juno", "v3.0.0", "juno-1", 10, 1) if err != nil { return err } - // write modified genesis file to 2/3 + // write modified genesis file to 2/3 vals and fullnode for i := 3; i < len(junoChainAsCosmosChain.ChainNodes); i++ { if err := junoChainAsCosmosChain.ChainNodes[i].UnsafeResetAll(ctx); err != nil { return err @@ -346,8 +350,8 @@ func (ibc IBCTestCase) JunoHaltNewGenesis(testName string, _ Chain, _ Chain, rel } // check IBC again - - if err = relayer.LinkPath(ctx, testPathName); err != nil { + // note: this requires relayer version with hack to use old RPC for blocks before the halt, and new RPC for blocks after new genesis + if err = relayer.UpdateClients(ctx, testPathName); err != nil { return err } @@ -356,7 +360,7 @@ func (ibc IBCTestCase) JunoHaltNewGenesis(testName string, _ Chain, _ Chain, rel } // wait for relayer to start up - time.Sleep(20 * time.Second) + time.Sleep(60 * time.Second) // send ibc transfer from the user wallet using its fullnode // timeout is nil so that it will use the default timeout @@ -390,15 +394,16 @@ func (ibc IBCTestCase) JunoHaltNewGenesis(testName string, _ Chain, _ Chain, rel return err } - fmt.Printf("Second balance check: Source: %d, Destination: %d\n", srcFinalBalance2, dstFinalBalance2) + totalFees = srcChain.GetGasFeesInNativeDenom(srcTx2.GasWanted) + expectedDifference = testCoin.Amount + totalFees - // if srcFinalBalance2 != srcFinalBalance-testCoin.Amount { - // return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcFinalBalance-testCoin.Amount, srcFinalBalance2) - // } + if srcFinalBalance2 != srcFinalBalance-expectedDifference { + return fmt.Errorf("source balances do not match. expected: %d, actual: %d", srcFinalBalance-expectedDifference, srcFinalBalance2) + } - // if dstFinalBalance2 != dstFinalBalance+testCoin.Amount { - // return fmt.Errorf("destination balances do not match. expected: %d, actual: %d", dstFinalBalance+testCoin.Amount, dstFinalBalance2) - // } + if dstFinalBalance2 != dstFinalBalance+testCoin.Amount { + return fmt.Errorf("destination balances do not match. expected: %d, actual: %d", dstFinalBalance+testCoin.Amount, dstFinalBalance2) + } return nil