Skip to content

Commit

Permalink
Move integration-tests utils to pkg to them reusable. (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitryhil authored Sep 25, 2023
1 parent fb8b046 commit 9617a20
Show file tree
Hide file tree
Showing 39 changed files with 709 additions and 629 deletions.
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/simple-state.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

integrationtests "github.com/CoreumFoundation/coreum/v3/integration-tests"
"github.com/CoreumFoundation/coreum/v3/pkg/client"
integrationtests "github.com/CoreumFoundation/coreum/v3/testutil/integration"
)

// SimpleState is a structure used to initizlize the simple state contract
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ require (
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/relayer/v2 v2.4.1
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/google/uuid v1.3.0
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7 // indirect
github.com/samber/lo v1.38.1
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.24.0
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
google.golang.org/grpc v1.57.0
google.golang.org/grpc v1.57.0 // indirect
)

require cosmossdk.io/errors v1.0.0
require cosmossdk.io/errors v1.0.0 // indirect

require (
cloud.google.com/go v0.110.4 // indirect
Expand Down
65 changes: 33 additions & 32 deletions integration-tests/ibc/asset_ft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/CoreumFoundation/coreum-tools/pkg/retry"
integrationtests "github.com/CoreumFoundation/coreum/v3/integration-tests"
"github.com/CoreumFoundation/coreum/v3/pkg/client"
"github.com/CoreumFoundation/coreum/v3/testutil/integration"
assetfttypes "github.com/CoreumFoundation/coreum/v3/x/asset/ft/types"
)

Expand All @@ -36,7 +37,7 @@ func TestIBCFailsIfNotEnabled(t *testing.T) {
coreumIssuer := coreumChain.GenAccount()

issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&ibctransfertypes.MsgTransfer{},
Expand Down Expand Up @@ -95,25 +96,25 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
osmosisRecipient1 := osmosisChain.GenAccount()
osmosisRecipient2 := osmosisChain.GenAccount()

gaiaChain.Faucet.FundAccounts(ctx, t, integrationtests.FundedAccount{
gaiaChain.Faucet.FundAccounts(ctx, t, integration.FundedAccount{
Address: gaiaRecipient1,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
}, integrationtests.FundedAccount{
}, integration.FundedAccount{
Address: gaiaRecipient2,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
})

osmosisChain.Faucet.FundAccounts(ctx, t, integrationtests.FundedAccount{
osmosisChain.Faucet.FundAccounts(ctx, t, integration.FundedAccount{
Address: osmosisRecipient1,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
}, integrationtests.FundedAccount{
}, integration.FundedAccount{
Address: osmosisRecipient2,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
})

coreumIssuer := coreumChain.GenAccount()
issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&banktypes.MsgSend{},
&assetfttypes.MsgIssue{},
Expand All @@ -123,7 +124,7 @@ func TestIBCAssetFTSendCommissionAndBurnRate(t *testing.T) {
Amount: issueFee,
})

coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&ibctransfertypes.MsgTransfer{},
&ibctransfertypes.MsgTransfer{},
Expand Down Expand Up @@ -351,13 +352,13 @@ func TestIBCAssetFTWhitelisting(t *testing.T) {
coreumRecipientWhitelisted := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

gaiaChain.Faucet.FundAccounts(ctx, t, integrationtests.FundedAccount{
gaiaChain.Faucet.FundAccounts(ctx, t, integration.FundedAccount{
Address: gaiaRecipient,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
})

issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&assetfttypes.MsgSetWhitelistedLimit{},
Expand Down Expand Up @@ -446,21 +447,21 @@ func TestIBCAssetFTFreezing(t *testing.T) {
coreumSender := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

gaiaChain.Faucet.FundAccounts(ctx, t, integrationtests.FundedAccount{
gaiaChain.Faucet.FundAccounts(ctx, t, integration.FundedAccount{
Address: gaiaRecipient,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
})

issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&banktypes.MsgSend{},
&assetfttypes.MsgFreeze{},
},
Amount: issueFee,
})
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&ibctransfertypes.MsgTransfer{},
&ibctransfertypes.MsgTransfer{},
Expand Down Expand Up @@ -546,13 +547,13 @@ func TestEscrowAddressIsResistantToFreezingAndWhitelisting(t *testing.T) {
coreumIssuer := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

gaiaChain.Faucet.FundAccounts(ctx, t, integrationtests.FundedAccount{
gaiaChain.Faucet.FundAccounts(ctx, t, integration.FundedAccount{
Address: gaiaRecipient,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
})

issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&assetfttypes.MsgFreeze{},
Expand Down Expand Up @@ -630,13 +631,13 @@ func TestIBCGlobalFreeze(t *testing.T) {
coreumRecipient := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

gaiaChain.Faucet.FundAccounts(ctx, t, integrationtests.FundedAccount{
gaiaChain.Faucet.FundAccounts(ctx, t, integration.FundedAccount{
Address: gaiaRecipient,
Amount: gaiaChain.NewCoin(sdkmath.NewInt(1000000)), // coin for the fees
})

issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&assetfttypes.MsgGloballyFreeze{},
Expand All @@ -646,7 +647,7 @@ func TestIBCGlobalFreeze(t *testing.T) {
},
Amount: issueFee,
})
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&ibctransfertypes.MsgTransfer{},
},
Expand Down Expand Up @@ -784,7 +785,7 @@ func TestIBCAssetFTTimedOutTransfer(t *testing.T) {
coreumSender := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&ibctransfertypes.MsgTransfer{},
Expand Down Expand Up @@ -892,15 +893,15 @@ func TestIBCAssetFTRejectedTransfer(t *testing.T) {
coreumSender := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&ibctransfertypes.MsgTransfer{},
&ibctransfertypes.MsgTransfer{},
},
Amount: coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount,
})
gaiaChain.Faucet.FundAccounts(ctx, t, integrationtests.FundedAccount{
gaiaChain.Faucet.FundAccounts(ctx, t, integration.FundedAccount{
Address: gaiaRecipient,
Amount: gaiaChain.NewCoin(sdk.NewIntFromUint64(100000)),
})
Expand Down Expand Up @@ -944,7 +945,7 @@ func TestIBCAssetFTRejectedTransfer(t *testing.T) {

// test that the reverse transfer from gaia to coreum is blocked too

coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{&ibctransfertypes.MsgTransfer{}},
})

Expand Down Expand Up @@ -985,7 +986,7 @@ func TestIBCRejectedTransferWithWhitelistingAndFreezing(t *testing.T) {
moduleAddress := authtypes.NewModuleAddress(ibctransfertypes.ModuleName)

issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&assetfttypes.MsgFreeze{},
Expand All @@ -995,7 +996,7 @@ func TestIBCRejectedTransferWithWhitelistingAndFreezing(t *testing.T) {
},
Amount: issueFee,
})
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&ibctransfertypes.MsgTransfer{},
},
Expand Down Expand Up @@ -1116,7 +1117,7 @@ func TestIBCTimedOutTransferWithWhitelistingAndFreezing(t *testing.T) {
coreumSender := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&assetfttypes.MsgFreeze{},
Expand All @@ -1126,7 +1127,7 @@ func TestIBCTimedOutTransferWithWhitelistingAndFreezing(t *testing.T) {
},
Amount: issueFee,
})
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&ibctransfertypes.MsgTransfer{},
},
Expand Down Expand Up @@ -1283,14 +1284,14 @@ func TestIBCRejectedTransferWithBurnRateAndSendCommission(t *testing.T) {
moduleAddress := authtypes.NewModuleAddress(ibctransfertypes.ModuleName)

issueFee := coreumChain.QueryAssetFTParams(ctx, t).IssueFee.Amount
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&banktypes.MsgSend{},
},
Amount: issueFee,
})
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&ibctransfertypes.MsgTransfer{},
},
Expand Down Expand Up @@ -1378,14 +1379,14 @@ func TestIBCTimedOutTransferWithBurnRateAndSendCommission(t *testing.T) {
coreumSender := coreumChain.GenAccount()
gaiaRecipient := gaiaChain.GenAccount()

coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumIssuer, integration.BalancesOptions{
Messages: []sdk.Msg{
&assetfttypes.MsgIssue{},
&banktypes.MsgSend{},
},
Amount: issueFee,
})
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integrationtests.BalancesOptions{
coreumChain.FundAccountWithOptions(ctx, t, coreumSender, integration.BalancesOptions{
Messages: []sdk.Msg{
&ibctransfertypes.MsgTransfer{},
},
Expand Down Expand Up @@ -1499,10 +1500,10 @@ func TestIBCTimedOutTransferWithBurnRateAndSendCommission(t *testing.T) {
func ibcTransferAndAssertBalanceChanges(
ctx context.Context,
t *testing.T,
srcChainCtx integrationtests.ChainContext,
srcChainCtx integration.ChainContext,
srcSender sdk.AccAddress,
sendCoin sdk.Coin,
dstChainCtx integrationtests.ChainContext,
dstChainCtx integration.ChainContext,
dstChainRecipient sdk.AccAddress,
receiveCoin sdk.Coin,
srcExpectedBalanceChanges map[string]sdkmath.Int,
Expand Down Expand Up @@ -1537,7 +1538,7 @@ func ibcTransferAndAssertBalanceChanges(
func fetchBalanceForMultipleAddresses(
ctx context.Context,
t *testing.T,
chainCtx integrationtests.ChainContext,
chainCtx integration.ChainContext,
denom string,
addresses []string,
) map[string]sdkmath.Int {
Expand Down
Loading

0 comments on commit 9617a20

Please sign in to comment.