Skip to content

Commit

Permalink
fix ack_err tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 committed Sep 16, 2024
1 parent 7af97f8 commit 970cd4a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
4 changes: 2 additions & 2 deletions tests/eibc_ack_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) {
require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error")))

// We transfered once to enable ibc-transfer from dym to rollapp
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount))
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(bigTransferAmount))

// At the moment, the ack returned and the demand order status became "finalized"
// We will execute the ibc transfer again and try to fulfill the demand order
Expand Down Expand Up @@ -1981,7 +1981,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) {
require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error")))

// We transfered once to enable ibc-transfer from dym to rollapp
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount))
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(bigTransferAmount))

// At the moment, the ack returned and the demand order status became "finalized"
// We will execute the ibc transfer again and try to fulfill the demand order
Expand Down
4 changes: 2 additions & 2 deletions tests/eibc_feemarket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) {
require.NoError(t, err)

// get eibc event
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 50, false)
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false)
require.NoError(t, err)
fmt.Println(eibcEvents)
require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom))
Expand Down Expand Up @@ -1660,7 +1660,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) {
require.NoError(t, err)

// get eibc event
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 50, false)
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false)
require.NoError(t, err)
fmt.Println("Event:", eibcEvents)
require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom))
Expand Down
25 changes: 7 additions & 18 deletions tests/eibc_fulfillment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1688,20 +1688,6 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) {
fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 2 to dym hub:", balance)
require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance))

// get eIbc event
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false)
require.NoError(t, err)
require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING")

// fulfill demand order 1
txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].OrderId, marketMakerAddr, eibcFee)
require.NoError(t, err)
fmt.Println(txhash)
eibcEvent := getEibcEventFromTx(t, dymension, txhash)
if eibcEvent != nil {
fmt.Println("After order fulfillment:", eibcEvent)
}

_, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options)
require.NoError(t, err)

Expand All @@ -1711,16 +1697,19 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) {
require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance))

// get eIbc event
eibcEvents, err = getEIbcEventsWithinBlockRange(ctx, dymension, 50, false)
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 50, false)
fmt.Println(eibcEvents)
require.NoError(t, err)
require.Equal(t, "PENDING", eibcEvents[0].PacketStatus)
require.Equal(t, "PENDING", eibcEvents[1].PacketStatus)

// fulfill demand order 2
txhash, err = dymension.FullfillDemandOrder(ctx, eibcEvents[1].OrderId, marketMakerAddr, eibcFee)
_, err = dymension.FullfillDemandOrder(ctx, eibcEvents[1].OrderId, marketMakerAddr, eibcFee)
require.NoError(t, err)
fmt.Println(txhash)
eibcEvent = getEibcEventFromTx(t, dymension, txhash)
txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee)
require.NoError(t, err)

eibcEvent := getEibcEventFromTx(t, dymension, txhash)
if eibcEvent != nil {
fmt.Println("After order fulfillment:", eibcEvent)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/eibc_not_fulfillment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1)
require.NoError(t, err)

// Get the IBC denom for urax on Hub
Expand Down
2 changes: 1 addition & 1 deletion tests/eibc_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) {
require.NoError(t, err)

// get eibc event
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 80, false)
eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 50, false)
require.NoError(t, err)
fmt.Println("Event:", eibcEvents[0])
require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, gaiaIBCDenom))
Expand Down

0 comments on commit 970cd4a

Please sign in to comment.