Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add invariant check at the end of tests #401

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/admc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) {
require.Equal(t, "urax", resp.Metadatas[0].Base)

testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) {
Expand Down Expand Up @@ -414,6 +416,8 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) {

// Minus 0.1% of transfer amount for bridge fee
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) {
Expand Down Expand Up @@ -819,6 +823,8 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) {
require.Equal(t, "urax", resp.Metadatas[0].Base)

testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) {
Expand Down Expand Up @@ -1044,6 +1050,8 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) {

// Minus 0.1% of transfer amount for bridge fee
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) {
Expand Down Expand Up @@ -1276,6 +1284,8 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) {

testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee))

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestADMC_MetaData_NotFound_EVM(t *testing.T) {
Expand Down Expand Up @@ -1475,6 +1485,8 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) {
err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestADMC_MetaData_NotFound_Wasm(t *testing.T) {
Expand Down Expand Up @@ -1674,4 +1686,6 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) {
err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
13 changes: 13 additions & 0 deletions tests/automated_denommetadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestADMC_Hub_to_RA_3rd_Party_EVM send IBC transfer for a non-existing denom from hub to rollapp successfully
Expand Down Expand Up @@ -585,6 +587,9 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestADMC_Hub_to_RA_reserved_Wasm send IBC transfer for a non-existing denom from hub to rollapp with setting {"transferinject":{}} in the memo
Expand Down Expand Up @@ -904,6 +909,8 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestADMC_Hub_to_RA_3rd_Party_Wasm send IBC transfer for a non-existing denom from hub to rollapp successfully
Expand Down Expand Up @@ -1207,6 +1214,8 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

type floatAmountWalletData struct {
Expand Down Expand Up @@ -1410,6 +1419,8 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestADMC_Hub_to_RA_Migrate_Dym_Wasm send IBC transfer DYM hub to rollapp successfully
Expand Down Expand Up @@ -1601,4 +1612,6 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
4 changes: 4 additions & 0 deletions tests/bridging_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ func Test_Non_Rollappchain_Unaffected_EVM(t *testing.T) {

testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount))
testutil.AssertBalance(t, ctx, gaia1, gaiaUserAddr, dymensionIBCDenom, transferAmount)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestChangeBridgeFeeParam_EVM create a prop to change bridge fee and after prop passed, transfer from rollapp to hub should have the new bridge fee.
Expand Down Expand Up @@ -407,4 +409,6 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) {
require.NoError(t, err)

testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
12 changes: 12 additions & 0 deletions tests/eibc_ack_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_AckError_RA_Token_EVM(t *testing.T) {
Expand Down Expand Up @@ -813,6 +815,8 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) {
testutil.WaitForBlocks(ctx, 20, rollapp1)
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount).Sub(bigTransferAmount))
})
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) {
Expand Down Expand Up @@ -1267,6 +1271,8 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) {
testutil.WaitForBlocks(ctx, 20, rollapp1)
testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount))
})
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_AckError_Dym_Wasm(t *testing.T) {
Expand Down Expand Up @@ -1664,6 +1670,8 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) {
Expand Down Expand Up @@ -2043,6 +2051,8 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) {
testutil.WaitForBlocks(ctx, 20, rollapp1)
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount).Sub(bigTransferAmount))
})
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) {
Expand Down Expand Up @@ -2460,4 +2470,6 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) {
testutil.WaitForBlocks(ctx, 20, rollapp1)
testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount))
})
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
3 changes: 3 additions & 0 deletions tests/eibc_corrupted_memo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,7 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) {
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())

}
8 changes: 8 additions & 0 deletions tests/eibc_fee_market_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestEIBCFulfillAlreadyFulfilledDemand_Wasm attempts to change the amount of an order that already got fulfilled
Expand Down Expand Up @@ -651,6 +653,8 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestEIBCUnallowedSigner_EVM attempts to change the amount of an order with an unallowed signer
Expand Down Expand Up @@ -913,6 +917,8 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestEIBCUnallowedSigner_Wasm attempts to change the amount of an order with an unallowed signer
Expand Down Expand Up @@ -1174,4 +1180,6 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
2 changes: 2 additions & 0 deletions tests/eibc_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,6 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
18 changes: 18 additions & 0 deletions tests/eibc_feemarket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) {
Expand Down Expand Up @@ -613,6 +615,8 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) {
Expand Down Expand Up @@ -901,6 +905,9 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) {
Expand Down Expand Up @@ -1197,6 +1204,8 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) {
Expand Down Expand Up @@ -1442,6 +1451,9 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) {
Expand Down Expand Up @@ -1700,6 +1712,8 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) {
Expand Down Expand Up @@ -1920,6 +1934,8 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) {
Expand Down Expand Up @@ -2143,4 +2159,6 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
24 changes: 24 additions & 0 deletions tests/eibc_fulfillment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// TestEIBCFulfillOnOneRollApp tests the case where we have 2 rollapps running, we have pending eIBC packets from both rollapps. one of the packets is fulfilled by the market maker, the other packet is not fulfilled. The test verifies that the funds are transferred correctly and the market maker's balance is updated correctly (after grace period).
Expand Down Expand Up @@ -786,6 +789,9 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub
Expand Down Expand Up @@ -1074,6 +1080,9 @@ func TestEIBCFulfillment_EVM(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCFulfillment_Wasm(t *testing.T) {
Expand Down Expand Up @@ -1369,6 +1378,9 @@ func TestEIBCFulfillment_Wasm(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) {
Expand Down Expand Up @@ -1729,6 +1741,9 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub
Expand Down Expand Up @@ -2134,6 +2149,8 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

// This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub
Expand Down Expand Up @@ -2529,6 +2546,8 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) {
Expand Down Expand Up @@ -2779,6 +2798,8 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) {
}
},
)
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) {
Expand Down Expand Up @@ -3029,4 +3050,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
3 changes: 3 additions & 0 deletions tests/eibc_nobalance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,7 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) {
}
},
)

// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}
Loading
Loading