-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathcli_defi_negative_test.go
80 lines (59 loc) · 2.98 KB
/
cli_defi_negative_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//go:build integration
package integration
import (
cli "github.com/cheqd/cheqd-node/tests/integration/cli"
helpers "github.com/cheqd/cheqd-node/tests/integration/helpers"
sdkmath "cosmossdk.io/math"
"github.com/cheqd/cheqd-node/tests/integration/testdata"
didtypes "github.com/cheqd/cheqd-node/x/did/types"
sdk "github.com/cosmos/cosmos-sdk/types"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Upgrade - Feemarket fees (non-taxable transactions) negative", func() {
It("should fail to submit a non-taxable transaction with insufficient fees (--gas-prices)", func() {
// query feemarket gas price for the base minimal denom
gasPrice, err := cli.QueryFeemarketGasPrice(didtypes.BaseMinimalDenom)
// print the gas price
println("Gas Price: " + gasPrice.String())
// assert no error
Expect(err).To(BeNil())
// define the coins to send, in which case 1,000,000,000 ncheq or 1 cheq
coins := sdk.NewCoin(didtypes.BaseMinimalDenom, sdk.NewInt(1_000_000_000))
// compute gas price, using offset
gasPrice.Price.Amount = gasPrice.Price.Amount.Mul(sdkmath.LegacyNewDec(didtypes.FeeOffset))
// invalidate the gas price, in which case 100 times less than the required
insufficientGasPrice := gasPrice.Price.Amount.Mul(sdkmath.LegacyMustNewDecFromStr("0.01"))
// define feeParams
feeParams := []string{
"--gas", cli.Gas,
"--gas-adjustment", cli.GasAdjustment,
"--gas-prices", insufficientGasPrice.String(),
}
// send the coins, balance assertions are intentionally omitted or out of scope
_, err = cli.SendTokensTx(testdata.BASE_ACCOUNT_1, testdata.BASE_ACCOUNT_2_ADDR, coins.String(), feeParams)
// assert error
Expect(err).ToNot(BeNil())
})
It("should fail to submit a non-taxable transaction with insufficient fees (--fees)", func() {
// query feemarket gas price for the base minimal denom
gasPrice, err := cli.QueryFeemarketGasPrice(didtypes.BaseMinimalDenom)
// print the gas price
println("Gas Price: " + gasPrice.String())
// assert no error
Expect(err).To(BeNil())
// define the coins to send, in which case 1,000,000,000 ncheq or 1 cheq
coins := sdk.NewCoin(didtypes.BaseMinimalDenom, sdk.NewInt(1_000_000_000))
// define static fees, in which case gas price is multiplied by roughly 3 or greater, times the minimal base denom
// consider multiplying in the range of [1.5, 3] times the gas price
gasPrice.Price.Amount = gasPrice.Price.Amount.Mul(sdkmath.LegacyNewDec(3)).Mul(sdkmath.LegacyNewDec(didtypes.BaseFactor))
// invalidate the static fees, in which case 100 times less than the required
insufficientGasPrice := gasPrice.Price.Amount.Mul(sdkmath.LegacyMustNewDecFromStr("0.01"))
// define feeParams
feeParams := helpers.GenerateFees(insufficientGasPrice.String())
// send the coins, balance assertions are intentionally omitted or out of scope
_, err = cli.SendTokensTx(testdata.BASE_ACCOUNT_1, testdata.BASE_ACCOUNT_2_ADDR, coins.String(), feeParams)
// assert error
Expect(err).ToNot(BeNil())
})
})