Skip to content

Commit

Permalink
fix(tests): fix local_node script for MacOS and other minor adjustmen…
Browse files Browse the repository at this point in the history
…ts (evmos#1925)

* fix local node script for MacOS

* adjust package name for v16 upgrade logic

* adjust comments in p256.go

* adjust comment in upgrades.go

* address linters

* fix tests

---------

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
  • Loading branch information
MalteHerrmann and fedekunze authored Oct 23, 2023
1 parent 56b90ed commit 900ae78
Show file tree
Hide file tree
Showing 47 changed files with 110 additions and 22 deletions.
2 changes: 2 additions & 0 deletions app/ante/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
testutiltx "github.com/evmos/evmos/v15/testutil/tx"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
2 changes: 2 additions & 0 deletions app/ante/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"testing"
"time"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/cosmos/cosmos-sdk/client"
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ func (app *Evmos) setupUpgradeHandlers() {
),
)

// v15 upgrade handler
// v16 upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(
v16.UpgradeName,
v16.CreateUpgradeHandler(
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v16/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)
package v15
package v16

const (
// UpgradeName is the shared upgrade plan name for mainnet
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)
package v15
package v16

import (
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -11,7 +11,7 @@ import (
evmkeeper "github.com/evmos/evmos/v15/x/evm/keeper"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v15.0.0
// CreateUpgradeHandler creates an SDK upgrade handler for v16.0.0
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand Down
2 changes: 1 addition & 1 deletion local_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then
sed -i '' 's/enabled = false/enabled = true/g' "$APP_TOML"
sed -i '' 's/enable = false/enable = true/g' "$APP_TOML"
# Don't enable memiavl by default
grep -q -F '[memiavl]' "$APP_TOML" && sed -i '/\[memiavl\]/,/^\[/ s/enable = true/enable = false/' "$APP_TOML"
grep -q -F '[memiavl]' "$APP_TOML" && sed -i '' '/\[memiavl\]/,/^\[/ s/enable = true/enable = false/' "$APP_TOML"
else
sed -i 's/prometheus = false/prometheus = true/' "$CONFIG"
sed -i 's/prometheus-retention-time = "0"/prometheus-retention-time = "1000000000000"/g' "$APP_TOML"
Expand Down
2 changes: 2 additions & 0 deletions precompiles/distribution/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
evmosutil "github.com/evmos/evmos/v15/testutil"
testutiltx "github.com/evmos/evmos/v15/testutil/tx"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 2 additions & 0 deletions precompiles/distribution/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"github.com/evmos/evmos/v15/precompiles/distribution"
"github.com/evmos/evmos/v15/x/evm/statedb"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

tmtypes "github.com/cometbft/cometbft/types"
Expand Down
2 changes: 2 additions & 0 deletions precompiles/ics20/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
erc20types "github.com/evmos/evmos/v15/x/erc20/types"
inflationtypes "github.com/evmos/evmos/v15/x/inflation/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

Expand Down
3 changes: 3 additions & 0 deletions precompiles/ics20/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import (
"github.com/evmos/evmos/v15/x/evm/statedb"
evmtypes "github.com/evmos/evmos/v15/x/evm/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/stretchr/testify/suite"
)

Expand Down
1 change: 1 addition & 0 deletions precompiles/ics20/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
feemarkettypes "github.com/evmos/evmos/v15/x/feemarket/types"
inflationtypes "github.com/evmos/evmos/v15/x/inflation/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

Expand Down
3 changes: 3 additions & 0 deletions precompiles/p256/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (

"github.com/cometbft/cometbft/crypto"
"github.com/ethereum/go-ethereum/common"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/evmos/evmos/v15/precompiles/p256"
Expand Down
24 changes: 13 additions & 11 deletions precompiles/p256/p256.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ import (
var _ vm.PrecompiledContract = &Precompile{}

const (
// P256VerifyGas is the secp256r1 elliptic curve signature verifier gas price
// VerifyGas is the secp256r1 elliptic curve signature verifier gas price.
VerifyGas uint64 = 3450
// Required input length is 160 bytes
// VerifyInputLength defines the required input length (160 bytes).
VerifyInputLength = 160
)

// PrecompileAddress defines the hex address of the p256 precompiled contract.
const PrecompileAddress = "0x0000000000000000000000000000000000000013"

// Precompile secp256r1 (P256) signature verification
// implemented as a native contract as per EIP-7212
// implemented as a native contract as per EIP-7212.
// See https://eips.ethereum.org/EIPS/eip-7212 for details
type Precompile struct{}

Expand All @@ -46,20 +46,22 @@ func (Precompile) Address() common.Address {
return common.BytesToAddress([]byte{19})
}

// RequiredGas returns the static gas required to execute the precompiled contract
// RequiredGas returns the static gas required to execute the precompiled contract.
func (p Precompile) RequiredGas(_ []byte) uint64 {
return VerifyGas
}

// Run executes the P256 signature verification using ECDSA.
// Run executes the p256 signature verification using ECDSA.
//
// Input data: 160 bytes of data including:
// - 32 bytes of the signed data hash
// - 32 bytes of the r component of the signature
// - 32 bytes of the s component of the signature
// - 32 bytes of the x coordinate of the public key
// - 32 bytes of the y coordinate of the public key
// - 32 bytes of the signed data hash
// - 32 bytes of the r component of the signature
// - 32 bytes of the s component of the signature
// - 32 bytes of the x coordinate of the public key
// - 32 bytes of the y coordinate of the public key
//
// Output data: 32 bytes of result data and error
// - If the signature verification process succeeds, it returns 1 in 32 bytes format
// - If the signature verification process succeeds, it returns 1 in 32 bytes format
func (p *Precompile) Run(_ *vm.EVM, contract *vm.Contract, _ bool) (bz []byte, err error) {
input := contract.Input
// Check the input length
Expand Down
2 changes: 2 additions & 0 deletions precompiles/p256/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
"errors"
"testing"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/cometbft/cometbft/crypto"
Expand Down
2 changes: 2 additions & 0 deletions precompiles/staking/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"math/big"
"time"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"cosmossdk.io/math"
Expand Down
4 changes: 4 additions & 0 deletions precompiles/staking/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import (
"github.com/evmos/evmos/v15/precompiles/staking"
"github.com/evmos/evmos/v15/x/evm/statedb"
evmtypes "github.com/evmos/evmos/v15/x/evm/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/stretchr/testify/suite"
)

Expand Down
1 change: 1 addition & 0 deletions precompiles/staking/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/big"
"time"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"cosmossdk.io/math"
Expand Down
2 changes: 2 additions & 0 deletions precompiles/vesting/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import (
testutiltx "github.com/evmos/evmos/v15/testutil/tx"
vestingtypes "github.com/evmos/evmos/v15/x/vesting/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

Expand Down
2 changes: 2 additions & 0 deletions precompiles/vesting/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import (
evmtypes "github.com/evmos/evmos/v15/x/evm/types"
"github.com/stretchr/testify/suite"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

Expand Down
1 change: 1 addition & 0 deletions precompiles/vesting/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
inflationtypes "github.com/evmos/evmos/v15/x/inflation/types"
vestingtypes "github.com/evmos/evmos/v15/x/vesting/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

Expand Down
3 changes: 2 additions & 1 deletion rpc/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ func (s *websocketsServer) Start() {

go func() {
var err error
/* #nosec G114 -- http functions have no support for timeouts */
if s.certFile == "" || s.keyFile == "" {
//#nosec G114 -- http functions have no support for timeouts
err = http.ListenAndServe(s.wsAddr, ws)
} else {
//#nosec G114 -- http functions have no support for timeouts
err = http.ListenAndServeTLS(s.wsAddr, s.certFile, s.keyFile, ws)
}

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/ledger/evmosd_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import (
evmoskeyring "github.com/evmos/evmos/v15/crypto/keyring"
feemarkettypes "github.com/evmos/evmos/v15/x/feemarket/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"
)

Expand Down
1 change: 1 addition & 0 deletions tests/integration/ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
)

Expand Down
2 changes: 2 additions & 0 deletions x/claims/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"math"
"time"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
3 changes: 3 additions & 0 deletions x/claims/keeper/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import (
"testing"

"github.com/ethereum/go-ethereum/common"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand Down
2 changes: 2 additions & 0 deletions x/epochs/keeper/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package keeper_test
import (
"testing"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
2 changes: 2 additions & 0 deletions x/erc20/keeper/ibc_callbacks_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/evmos/evmos/v15/utils"
claimstypes "github.com/evmos/evmos/v15/x/claims/types"
"github.com/evmos/evmos/v15/x/erc20/types"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
)

Expand Down
3 changes: 3 additions & 0 deletions x/erc20/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

abci "github.com/cometbft/cometbft/abci/types"
Expand Down
2 changes: 2 additions & 0 deletions x/erc20/keeper/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package keeper_test
import (
"testing"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/cosmos/cosmos-sdk/client"
Expand Down
6 changes: 3 additions & 3 deletions x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
const invalidAddress = "0x0000"

// expGasConsumed is the gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee)
const expGasConsumed = 6932
const expGasConsumed = 7064

// expGasConsumedWithFeeMkt is the gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) with enabled feemarket
const expGasConsumedWithFeeMkt = 6926
const expGasConsumedWithFeeMkt = 7058

func (suite *KeeperTestSuite) TestQueryAccount() {
var (
Expand Down Expand Up @@ -937,7 +937,7 @@ func (suite *KeeperTestSuite) TestTraceTx() {
},
expPass: true,
traceResponse: "{\"gas\":34828,\"failed\":false,\"returnValue\":\"0000000000000000000000000000000000000000000000000000000000000001\",\"structLogs\":[{\"pc\":0,\"op\":\"PUSH1\",\"gas\":",
expFinalGas: 20492, // gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) + gas consumed in malleate func
expFinalGas: 22076, // gas consumed in traceTx setup (GetProposerAddr + CalculateBaseFee) + gas consumed in malleate func
},
{
msg: "invalid chain id",
Expand Down
3 changes: 3 additions & 0 deletions x/evm/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import (
"math/big"

"cosmossdk.io/math"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

"github.com/ethereum/go-ethereum/common"
Expand Down
2 changes: 2 additions & 0 deletions x/evm/keeper/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (

"github.com/evmos/evmos/v15/utils"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

sdkmath "cosmossdk.io/math"
Expand Down
3 changes: 3 additions & 0 deletions x/feemarket/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import (
"strings"

sdkmath "cosmossdk.io/math"

//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/ginkgo/v2"
//nolint:revive // dot imports are fine for Ginkgo
. "github.com/onsi/gomega"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
Loading

0 comments on commit 900ae78

Please sign in to comment.