Skip to content

Commit

Permalink
test: Added negative feemarket cases (insufficient fees) (#848)
Browse files Browse the repository at this point in the history
* test: Added negative feemarket cases (insufficient fees)

* Distinct values

* Removed redundant

* Update Docker image version

* Upgrade version

* Remove skipping identity tests

* Revert "Upgrade version"

This reverts commit 50a92c4.

* Update mainnet-latest.env

* This is what's causing the breakage

Lots of tests rely on spinning up / down from 2.0.1, this is breaking the intermediate upgrade tests

* Bump legacy version

---------

Co-authored-by: Ankur Banerjee <ankurdotb@users.noreply.github.com>
  • Loading branch information
Eengineer1 and ankurdotb authored Jan 28, 2025
1 parent 68249e0 commit 4e31daf
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ jobs:
tar -xvf cheqd-noded-"${LEGACY_VERSION}"-linux-amd64.tar.gz -C ${{ env.RUNNER_BIN_DIR }}
sudo chmod +x ${{ env.RUNNER_BIN_DIR }}/cheqd-noded
env:
LEGACY_VERSION: 2.0.1
LEGACY_VERSION: 3.0.1

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
- name: Run integration tests on upgraded network
working-directory: ./tests/integration
run: |
ginkgo -r --tags integration --race --randomize-suites --keep-going --trace --skip-file cli_defi_test.go --junit-report ../../report-upgraded-integration.xml
ginkgo -r --tags integration --race --randomize-suites --keep-going --trace --skip-file cli_defi_test.go --skip-file cli_defi_negative_test.go --junit-report ../../report-upgraded-integration.xml
- name: Upload post-upgrade integration tests result
uses: actions/upload-artifact@v4
Expand All @@ -286,7 +286,7 @@ jobs:
- name: Run pricing integration tests after successful param change proposal
working-directory: ./tests/integration
run: |
ginkgo -r --tags integration --race --randomize-suites --keep-going --trace --skip-file cli_diddoc_test.go --skip-file cli_diddoc_negative_test.go --skip-file cli_resource_test.go --skip-file cli_resource_negative_test.go --skip-file cli_defi_test.go --junit-report ../../report-pricing-change.xml
ginkgo -r --tags integration --race --randomize-suites --keep-going --trace --skip-file cli_diddoc_test.go --skip-file cli_diddoc_negative_test.go --skip-file cli_resource_test.go --skip-file cli_resource_negative_test.go --skip-file cli_defi_test.go --skip-file cli_defi_negative_test.go --junit-report ../../report-pricing-change.xml
- name: Upload pricing change tests result
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion docker/localnet/mainnet-latest.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
### REQUIRED: Node/network selection ###
###############################################################
# Define cheqd-noded image source. Change if using your own build.
BUILD_IMAGE_VERSION=2.0.1
BUILD_IMAGE_VERSION=3.0.1

BUILD_IMAGE="ghcr.io/cheqd/cheqd-node:$BUILD_IMAGE_VERSION"
4 changes: 1 addition & 3 deletions docker/persistent-chains/docker-compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
CHEQD_NETWORK=mainnet

# Define cheqd-noded software release version
# Current MAINNET recommended version: 0.6.7
# Current TESTNET recommended version: 0.6.7
DOCKER_IMAGE_VERSION=v1.0.0
DOCKER_IMAGE_VERSION=3.0.1

###############################################################
### OPTIONAL: Host-side port mappings ###
Expand Down
80 changes: 80 additions & 0 deletions tests/integration/cli_defi_negative_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,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())
})
})

0 comments on commit 4e31daf

Please sign in to comment.