Skip to content

Commit

Permalink
test: refactor ibc test
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Jun 4, 2024
1 parent 46f5cad commit a98a68a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions interchaintest/ibc/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package relayer_test
import (
"context"
"cosmossdk.io/math"
"github.com/KYVENetwork/chain/testutil/integration"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
Expand All @@ -21,7 +22,7 @@ import (
TEST CASES - IBC
* Transfer 1_000_000_000 Kyve tokens to Osmosis and back
* Transfer 1 $KYVE to Osmosis and back
*/

Expand Down Expand Up @@ -94,9 +95,9 @@ var _ = Describe("ibc", Ordered, func() {
_ = interchain.Close()
})

It("Transfer 1_000_000_000 Kyve tokens to Osmosis and back", func() {
It("Transfer 1 $KYVE to Osmosis and back", func() {
// ARRANGE
startBalance := math.NewInt(10_000_000_000)
startBalance := math.NewInt(10 * integration.T_KYVE)
var kyveWallet = interchaintest.GetAndFundTestUsers(GinkgoT(), ctx, GinkgoT().Name(), startBalance, kyve)[0].(*cosmos.CosmosWallet)
var osmosisWallet = interchaintest.GetAndFundTestUsers(GinkgoT(), ctx, GinkgoT().Name(), startBalance, osmosis)[0].(*cosmos.CosmosWallet)

Expand All @@ -113,8 +114,8 @@ var _ = Describe("ibc", Ordered, func() {
Expect(err).To(BeNil())

// ACT 1
// Transfer 1_000_000_000 $KYVE to Osmosis
transferAmount := math.NewInt(1_000_000_000)
// Transfer 1 $KYVE to Osmosis
transferAmount := math.NewInt(integration.T_KYVE)
transfer := ibc.WalletAmount{
Address: osmosisWallet.FormattedAddress(),
Denom: kyve.Config().Denom,
Expand All @@ -130,18 +131,18 @@ var _ = Describe("ibc", Ordered, func() {
Expect(err).To(BeNil())

// ASSERT 1
// New balance must be startBalance - transferAmount - fees -> so in total a bit less than 9_000_000_000
// New balance must be startBalance - transferAmount - fees -> so a bit less than 9 $KYVE
kyveBal1, err := kyve.GetBalance(ctx, kyveWallet.FormattedAddress(), kyve.Config().Denom)
Expect(err).To(BeNil())
newBalance := startBalance.Sub(transferAmount)
Expect(kyveBal1.Int64()).To(BeBetween(newBalance.Sub(math.NewInt(100_000)).Int64(), newBalance.Int64()))

osmosisBal1, err := osmosis.GetBalance(ctx, osmosisWallet.FormattedAddress(), ibcDenom)
Expect(err).To(BeNil())
Expect(osmosisBal1).To(Equal(math.NewInt(1_000_000_000)))
Expect(osmosisBal1).To(Equal(math.NewInt(integration.T_KYVE)))

// ACT 2
// Transfer 1_000_000_000 $KYVE back to Kyve
// Transfer 1 $KYVE back to Kyve
transfer = ibc.WalletAmount{
Address: kyveWallet.FormattedAddress(),
Denom: ibcDenom,
Expand Down

0 comments on commit a98a68a

Please sign in to comment.