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

Decrease the gas required for the module's integration tests to pass. #1020

Merged
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
44 changes: 24 additions & 20 deletions integration-tests/modules/assetft_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,9 @@ func TestAssetFTExtensionMint(t *testing.T) {
Amount: sdkmath.NewInt(1 * 500_000), // add 500k for each message with extenstion transfer
})

chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: sdkmath.NewInt(1_000_000),
})

codeID, err := chain.Wasm.DeployWASMContract(
ctx, chain.TxFactoryAuto(), issuer, testcontracts.AssetExtensionWasm,
Expand Down Expand Up @@ -1006,11 +1006,12 @@ func TestAssetFTExtensionSendingToSmartContractIsDenied(t *testing.T) {
ctx, chain := integrationtests.NewCoreumTestingContext(t)

issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)

chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

clientCtx := chain.ClientContext

Expand Down Expand Up @@ -1046,7 +1047,6 @@ func TestAssetFTExtensionSendingToSmartContractIsDenied(t *testing.T) {
chain.TxFactoryAuto(),
issueMsg,
)

requireT.NoError(err)
denom := assetfttypes.BuildDenom(issueMsg.Subunit, issuer)

Expand Down Expand Up @@ -1115,9 +1115,10 @@ func TestAssetFTExtensionAttachingToSmartContractCallIsDenied(t *testing.T) {
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

codeID, err := chain.Wasm.DeployWASMContract(
ctx, chain.TxFactoryAuto(), issuer, testcontracts.AssetExtensionWasm,
Expand Down Expand Up @@ -1195,9 +1196,10 @@ func TestAssetFTExtensionIssuingSmartContractIsAllowedToSendAndReceive(t *testin
recipient := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(50000000000))),
)
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.MulRaw(2).
Add(sdkmath.NewInt(1_000_000)),
})
chain.FundAccountWithOptions(ctx, t, recipient, integration.BalancesOptions{
Amount: sdkmath.NewInt(500_000),
})
Expand Down Expand Up @@ -1308,9 +1310,10 @@ func TestAssetFTExtensionAttachingToSmartContractInstantiationIsDenied(t *testin
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

codeID, err := chain.Wasm.DeployWASMContract(
ctx, chain.TxFactory().WithSimulateAndExecute(true), issuer, testcontracts.AssetExtensionWasm,
Expand Down Expand Up @@ -1384,9 +1387,10 @@ func TestAssetFTExtensionMintingAndSendingOnBehalfOfIssuingSmartContractIsPossib
recipient := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

codeID, err := chain.Wasm.DeployWASMContract(
ctx, chain.TxFactoryAuto(), admin, testcontracts.AssetExtensionWasm,
Expand Down
116 changes: 69 additions & 47 deletions integration-tests/modules/assetft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,9 +1146,10 @@ func TestAssetFTMint(t *testing.T) {
},
})

chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

// Issue an unmintable fungible token
issueMsg := &assetfttypes.MsgIssue{
Expand Down Expand Up @@ -1813,9 +1814,10 @@ func TestAssetFTFeesAreChargedWhenSmartContractExecutesAuthZTransfer(t *testing.
granter := chain.GenAccount()
receiver := chain.GenAccount()

chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})
chain.FundAccountWithOptions(ctx, t, granter, integration.BalancesOptions{
Messages: []sdk.Msg{
&authztypes.MsgGrant{},
Expand Down Expand Up @@ -1991,9 +1993,10 @@ func TestAssetFTFeesAreNotChargedWhenTokensAreTransferredFromSmartContractUsingA
grantee := chain.GenAccount()
receiver := chain.GenAccount()

chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

// Issue a fungible token
issueMsg := &assetfttypes.MsgIssue{
Expand Down Expand Up @@ -2705,9 +2708,10 @@ func TestAssetFTClawbackSmartContract(t *testing.T) {
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

clientCtx := chain.ClientContext

Expand Down Expand Up @@ -3795,9 +3799,10 @@ func TestAssetFTSendingToNonWhitelistedSmartContractIsDenied(t *testing.T) {
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

clientCtx := chain.ClientContext

Expand Down Expand Up @@ -3869,9 +3874,10 @@ func TestAssetFTAttachingToNonWhitelistedSmartContractCallIsDenied(t *testing.T)
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

txf := chain.TxFactoryAuto()

Expand Down Expand Up @@ -3935,9 +3941,10 @@ func TestAssetFTAttachingToNonWhitelistedSmartContractInstantiationIsDenied(t *t
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

txf := chain.TxFactoryAuto()

Expand Down Expand Up @@ -5455,11 +5462,16 @@ func TestAssetFTSendCommissionAndBurnRateWithSmartContract(t *testing.T) {
issuer := chain.GenAccount()
admin := chain.GenAccount()

chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)

clientCtx := chain.ClientContext
txf := chain.TxFactoryAuto()
Expand Down Expand Up @@ -5673,7 +5685,10 @@ func TestAssetFTSendCommissionAndBurnRateWithSmartContractInstantiation(t *testi
recipient := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t, integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))))
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

clientCtx := chain.ClientContext
txf := chain.TxFactoryAuto()
Expand Down Expand Up @@ -5735,9 +5750,10 @@ func TestAssetFTSendingToSmartContractIsDenied(t *testing.T) {
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

clientCtx := chain.ClientContext

Expand Down Expand Up @@ -5831,9 +5847,10 @@ func TestAssetFTAttachingToSmartContractCallIsDenied(t *testing.T) {
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

txf := chain.TxFactoryAuto()

Expand Down Expand Up @@ -5897,9 +5914,10 @@ func TestAssetFTAttachingToSmartContractInstantiationIsDenied(t *testing.T) {
issuer := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(issuer, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, issuer, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

txf := chain.TxFactoryAuto()

Expand Down Expand Up @@ -5960,9 +5978,10 @@ func TestAssetFTIssuingSmartContractIsAllowedToSendAndReceive(t *testing.T) {
recipient := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})
chain.FundAccountWithOptions(ctx, t, recipient, integration.BalancesOptions{
Messages: []sdk.Msg{
&banktypes.MsgSend{},
Expand Down Expand Up @@ -6060,9 +6079,10 @@ func TestAssetFTMintingAndSendingOnBehalfOfIssuingSmartContractIsPossibleEvenIfS
recipient := chain.GenAccount()

requireT := require.New(t)
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

// instantiate new contract
initialPayload, err := json.Marshal(struct{}{})
Expand Down Expand Up @@ -6208,9 +6228,10 @@ func TestAssetFTSendingTokensFromRegularAccountBySmartContractUsingAuthZIsDenied
},
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount,
})
chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(admin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, admin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

// issue token
issueMsg := &assetfttypes.MsgIssue{
Expand Down Expand Up @@ -6574,9 +6595,10 @@ func TestAssetFTTransferAdminMint(t *testing.T) {
},
})

chain.Faucet.FundAccounts(ctx, t,
integration.NewFundedAccount(wasmAdmin, chain.NewCoin(sdkmath.NewInt(5000000000))),
)
chain.FundAccountWithOptions(ctx, t, wasmAdmin, integration.BalancesOptions{
Amount: chain.QueryAssetFTParams(ctx, t).IssueFee.Amount.
Add(sdkmath.NewInt(1_000_000)),
})

// Issue an unmintable fungible token
issueMsg := &assetfttypes.MsgIssue{
Expand Down
Loading