Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

evm: unit tests #619

Merged
merged 33 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f99cca2
evm: unit tests
fedekunze Oct 4, 2021
d813fca
Add unit tests for DynamicFeeTx.Validate()
danburck Oct 4, 2021
2491701
Start get and set signature values tests
danburck Oct 4, 2021
b3bd912
get set values
fedekunze Oct 4, 2021
f646a09
Add tests for GetTo()
danburck Oct 4, 2021
096e697
Add GetNonce test
danburck Oct 4, 2021
67d7010
Add GetValue test
danburck Oct 4, 2021
a8192f7
Start copy test
danburck Oct 4, 2021
5c9f58d
Add WIP newDynamicFeeTx test
danburck Oct 5, 2021
129c256
Add WIP legacy_tx_test
danburck Oct 5, 2021
2d59a12
pair programming session
fedekunze Oct 5, 2021
1f6cbc7
Add TestLegacyTxValidate
danburck Oct 5, 2021
5155423
Add TestLegacyTxSetSignatureValues & GetSignatureValues
danburck Oct 5, 2021
3ceeda8
Add legacyTx tests
danburck Oct 5, 2021
1319d11
Merge main
danburck Oct 5, 2021
4790f09
Merge main, forgot to save one file
danburck Oct 5, 2021
7cc3ed7
Add AccessList tests
danburck Oct 5, 2021
5dde078
Add chain Config (fork order)
danburck Oct 6, 2021
e836864
Add invalid genesis account test
danburck Oct 6, 2021
706dc48
Add params tests
danburck Oct 6, 2021
71e8227
Add WIP tracer test
danburck Oct 6, 2021
fdae8e7
tracer tests
danburck Oct 7, 2021
6d885fe
Add FormatLogs tests
danburck Oct 7, 2021
5da1aa6
Add NewNoOpTracer test
danburck Oct 7, 2021
75fa0fd
Refactor to test suite
danburck Oct 7, 2021
af424f1
Merge branch 'main' into unit-test
fedekunze Oct 8, 2021
ab4dc50
Merge remote-tracking branch 'origin' into unit-test
danburck Oct 8, 2021
23d5014
Refactor Tx Test suits to only use TxDataTestSuite
danburck Oct 8, 2021
8970053
Update link to geth interpreter
danburck Oct 8, 2021
7396836
Merge branch 'unit-test' of github.com:tharsis/ethermint into unit-test
danburck Oct 8, 2021
5bf8cca
Update x/evm/types/params.go
fedekunze Oct 8, 2021
1e2857a
Refactor accessListTx Test suits to use TxDataTestSuite
danburck Oct 8, 2021
77e950f
Merge branch 'unit-test' of github.com:tharsis/ethermint into unit-test
danburck Oct 8, 2021
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
58 changes: 58 additions & 0 deletions x/evm/types/access_list_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package types

import (
"testing"

"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/suite"
"github.com/tharsis/ethermint/tests"
)

type AccessListTestSuite struct {
suite.Suite

addr common.Address
hexAddr string
}

func (suite *AccessListTestSuite) SetupTest() {
suite.addr = tests.GenerateAddress()
suite.hexAddr = suite.addr.Hex()
}

func TestAccessListTestSuite(t *testing.T) {
suite.Run(t, new(AccessListTestSuite))
}

func (suite *AccessListTestSuite) TestTestNewAccessList() {
testCases := []struct {
name string
ethAccessList *ethtypes.AccessList
expAl AccessList
}{
{
"ethAccessList is nil",
nil,
nil,
},
{
"non-empty ethAccessList",
&ethtypes.AccessList{{Address: suite.addr, StorageKeys: []common.Hash{{0}}}},
AccessList{{Address: suite.hexAddr, StorageKeys: []string{common.Hash{}.Hex()}}},
},
}
for _, tc := range testCases {
al := NewAccessList(tc.ethAccessList)

suite.Require().Equal(tc.expAl, al)
}
}

func (suite *AccessListTestSuite) TestAccessListToEthAccessList() {
ethAccessList := ethtypes.AccessList{{Address: suite.addr, StorageKeys: []common.Hash{{0}}}}
al := NewAccessList(&ethAccessList)
actual := al.ToEthAccessList()

suite.Require().Equal(&ethAccessList, actual)
}
20 changes: 19 additions & 1 deletion x/evm/types/chain_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func TestChainConfigValidate(t *testing.T) {
},
true,
},

{
"invalid CatalystBlock",
ChainConfig{
Expand All @@ -258,6 +257,25 @@ func TestChainConfigValidate(t *testing.T) {
},
true,
},
{
"invalid fork order - skip HomesteadBlock",
ChainConfig{
DAOForkBlock: newIntPtr(0),
EIP150Block: newIntPtr(0),
EIP150Hash: defaultEIP150Hash,
EIP155Block: newIntPtr(0),
EIP158Block: newIntPtr(0),
ByzantiumBlock: newIntPtr(0),
ConstantinopleBlock: newIntPtr(0),
PetersburgBlock: newIntPtr(0),
IstanbulBlock: newIntPtr(0),
MuirGlacierBlock: newIntPtr(0),
BerlinBlock: newIntPtr(0),
LondonBlock: newIntPtr(0),
CatalystBlock: newIntPtr(0),
},
true,
},
}

for _, tc := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions x/evm/types/dynamic_fee_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ func (tx *DynamicFeeTx) GetGasPrice() *big.Int {
return tx.GetGasFeeCap()
}

// GetGasTipCap returns the gas price field.
// GetGasTipCap returns the gas tip cap field.
func (tx *DynamicFeeTx) GetGasTipCap() *big.Int {
if tx.GasTipCap == nil {
return nil
}
return tx.GasTipCap.BigInt()
}

// GetGasFeeCap returns the gas price field.
// GetGasFeeCap returns the gas fee cap field.
func (tx *DynamicFeeTx) GetGasFeeCap() *big.Int {
if tx.GasFeeCap == nil {
return nil
Expand Down
Loading