mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
core: run tests in parallel (#8743)
This commit is contained in:
parent
3ca7fdf7e9
commit
fdab99d0e8
@ -23,6 +23,7 @@ import (
|
||||
|
||||
// Tests disassembling the instructions for valid evm code
|
||||
func TestInstructionIteratorValid(t *testing.T) {
|
||||
t.Parallel()
|
||||
cnt := 0
|
||||
script, _ := hex.DecodeString("61000000")
|
||||
|
||||
@ -41,6 +42,7 @@ func TestInstructionIteratorValid(t *testing.T) {
|
||||
|
||||
// Tests disassembling the instructions for invalid evm code
|
||||
func TestInstructionIteratorInvalid(t *testing.T) {
|
||||
t.Parallel()
|
||||
cnt := 0
|
||||
script, _ := hex.DecodeString("6100")
|
||||
|
||||
@ -56,6 +58,7 @@ func TestInstructionIteratorInvalid(t *testing.T) {
|
||||
|
||||
// Tests disassembling the instructions for empty evm code
|
||||
func TestInstructionIteratorEmpty(t *testing.T) {
|
||||
t.Parallel()
|
||||
cnt := 0
|
||||
script, _ := hex.DecodeString("")
|
||||
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCompiler(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
input, output string
|
||||
}{
|
||||
|
@ -32,6 +32,7 @@ func lexAll(src string) []token {
|
||||
}
|
||||
|
||||
func TestLexer(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
input string
|
||||
tokens []token
|
||||
|
@ -31,6 +31,7 @@ import (
|
||||
|
||||
// Tests that simple header verification works, for both good and bad blocks.
|
||||
func TestHeaderVerification(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create a simple chain to verify
|
||||
var (
|
||||
gspec = &types.Genesis{Config: params.TestChainConfig}
|
||||
@ -72,6 +73,7 @@ func TestHeaderVerification(t *testing.T) {
|
||||
|
||||
// Tests that simple header with seal verification works, for both good and bad blocks.
|
||||
func TestHeaderWithSealVerification(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create a simple chain to verify
|
||||
var (
|
||||
gspec = &types.Genesis{Config: params.TestChainAuraConfig}
|
||||
|
@ -33,6 +33,7 @@ import (
|
||||
// Forks before Shanghai are triggered by the block number,
|
||||
// while Shanghai and later forks are triggered by the block time.
|
||||
func TestCreation(t *testing.T) {
|
||||
t.Parallel()
|
||||
type testcase struct {
|
||||
head uint64
|
||||
time uint64
|
||||
@ -179,6 +180,7 @@ func TestCreation(t *testing.T) {
|
||||
// TestValidation tests that a local peer correctly validates and accepts a remote
|
||||
// fork ID.
|
||||
func TestValidation(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
head uint64
|
||||
id ID
|
||||
@ -258,6 +260,7 @@ func TestValidation(t *testing.T) {
|
||||
// Tests that IDs are properly RLP encoded (specifically important because we
|
||||
// use uint32 to store the hash, but we need to encode it as [4]byte).
|
||||
func TestEncoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
id ID
|
||||
want []byte
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGenesisBlockHashes(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.New()
|
||||
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
|
||||
check := func(network string) {
|
||||
@ -45,6 +46,7 @@ func TestGenesisBlockHashes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGenesisBlockRoots(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
var err error
|
||||
|
||||
@ -73,6 +75,7 @@ func TestGenesisBlockRoots(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCommitGenesisIdempotency(t *testing.T) {
|
||||
t.Parallel()
|
||||
logger := log.New()
|
||||
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
|
||||
tx, err := db.BeginRw(context.Background())
|
||||
@ -94,6 +97,7 @@ func TestCommitGenesisIdempotency(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllocConstructor(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
|
||||
|
@ -41,6 +41,7 @@ import (
|
||||
|
||||
// Tests block header storage and retrieval operations.
|
||||
func TestHeaderStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
require.NoError(t, err)
|
||||
@ -81,6 +82,7 @@ func TestHeaderStorage(t *testing.T) {
|
||||
|
||||
// Tests block body storage and retrieval operations.
|
||||
func TestBodyStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
require.NoError(t, err)
|
||||
@ -149,6 +151,7 @@ func TestBodyStorage(t *testing.T) {
|
||||
|
||||
// Tests block storage and retrieval operations.
|
||||
func TestBlockStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
require := require.New(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
@ -259,6 +262,7 @@ func TestBlockStorage(t *testing.T) {
|
||||
|
||||
// Tests that partial block contents don't get reassembled into full blocks.
|
||||
func TestPartialBlockStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
require.NoError(t, err)
|
||||
@ -305,6 +309,7 @@ func TestPartialBlockStorage(t *testing.T) {
|
||||
|
||||
// Tests block total difficulty storage and retrieval operations.
|
||||
func TestTdStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
require.NoError(t, err)
|
||||
@ -349,6 +354,7 @@ func TestTdStorage(t *testing.T) {
|
||||
|
||||
// Tests that canonical numbers can be mapped to hashes and retrieved.
|
||||
func TestCanonicalMappingStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
require.NoError(t, err)
|
||||
@ -394,6 +400,7 @@ func TestCanonicalMappingStorage(t *testing.T) {
|
||||
|
||||
// Tests that head headers and head blocks can be assigned, individually.
|
||||
func TestHeadStorage2(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, db := memdb.NewTestTx(t)
|
||||
|
||||
blockHead := types.NewBlockWithHeader(&types.Header{Extra: []byte("test block header")})
|
||||
@ -421,6 +428,7 @@ func TestHeadStorage2(t *testing.T) {
|
||||
|
||||
// Tests that head headers and head blocks can be assigned, individually.
|
||||
func TestHeadStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
require.NoError(t, err)
|
||||
@ -444,6 +452,7 @@ func TestHeadStorage(t *testing.T) {
|
||||
|
||||
// Tests that receipts associated with a single block can be stored and retrieved.
|
||||
func TestBlockReceiptStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
require.NoError(t, err)
|
||||
@ -536,6 +545,7 @@ func TestBlockReceiptStorage(t *testing.T) {
|
||||
|
||||
// Tests block storage and retrieval operations with withdrawals.
|
||||
func TestBlockWithdrawalsStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
require := require.New(t)
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
@ -672,6 +682,7 @@ func TestBlockWithdrawalsStorage(t *testing.T) {
|
||||
|
||||
// Tests pre-shanghai body to make sure withdrawals doesn't panic
|
||||
func TestPreShanghaiBodyNoPanicOnWithdrawals(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
const bodyRlp = "f902bef8bef85d0101019471562b71999873db5b286df957af199ec94617f701801ca023f4aad9a71341d2990012a732366c3bc8a4ce9ff54c05546a9487445ac67692a0290d3a1411c2a675a4c12c98af60e34ea4d689f0ddfe0250a9e09c0819dfe3bff85d0201029471562b71999873db5b286df957af199ec94617f701801ca0f824d7edc241758aca948ff34d3797e4e31003f76cc9e05fb9c19e967fc48113a070e1389f0fa23fe765a04b23e98f98db6d630e3a035c1c7c968142ababb85a1df901fbf901f8a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080808080808b7465737420686561646572a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"
|
||||
@ -686,6 +697,7 @@ func TestPreShanghaiBodyNoPanicOnWithdrawals(t *testing.T) {
|
||||
|
||||
// Tests pre-shanghai bodyForStorage to make sure withdrawals doesn't panic
|
||||
func TestPreShanghaiBodyForStorageNoPanicOnWithdrawals(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
const bodyForStorageRlp = "c38002c0"
|
||||
@ -700,6 +712,7 @@ func TestPreShanghaiBodyForStorageNoPanicOnWithdrawals(t *testing.T) {
|
||||
|
||||
// Tests shanghai bodyForStorage to make sure withdrawals are present
|
||||
func TestShanghaiBodyForStorageHasWithdrawals(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
const bodyForStorageRlp = "f83f8002c0f83adc0f82157c94ff000000000000000000000000000000000000008203e8dc1082157d94ff000000000000000000000000000000000000008203e9"
|
||||
@ -715,6 +728,7 @@ func TestShanghaiBodyForStorageHasWithdrawals(t *testing.T) {
|
||||
|
||||
// Tests shanghai bodyForStorage to make sure when no withdrawals the slice is empty (not nil)
|
||||
func TestShanghaiBodyForStorageNoWithdrawals(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
const bodyForStorageRlp = "c48002c0c0c0"
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
|
||||
// Tests that positional lookup metadata can be stored and retrieved.
|
||||
func TestLookupStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
writeTxLookupEntries func(kv.Putter, *types.Block)
|
||||
@ -48,7 +49,9 @@ func TestLookupStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mock.Mock(t)
|
||||
br := m.BlockReader
|
||||
tx, err := m.DB.BeginRw(m.Ctx)
|
||||
|
@ -73,6 +73,7 @@ func getBlock(tb testing.TB, transactions int, uncles int, dataSize int, tmpDir
|
||||
// TestRlpIterator tests that individual transactions can be picked out
|
||||
// from blocks without full unmarshalling/marshalling
|
||||
func TestRlpIterator(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tt := range []struct {
|
||||
txs int
|
||||
uncles int
|
||||
|
@ -63,6 +63,7 @@ func verifySlots(t *testing.T, s *IntraBlockState, addrString string, slotString
|
||||
}
|
||||
|
||||
func TestAccessList(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Some helpers
|
||||
addr := common.HexToAddress
|
||||
slot := common.HexToHash
|
||||
|
@ -438,6 +438,7 @@ func TestCreate2Polymorth(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReorgOverSelfDestruct(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Configure and generate a sample block chain
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
@ -586,6 +587,7 @@ func TestReorgOverSelfDestruct(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReorgOverStateChange(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Configure and generate a sample block chain
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
@ -734,6 +736,7 @@ func (b BucketsStats) Size() uint64 {
|
||||
}
|
||||
|
||||
func TestCreateOnExistingStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Configure and generate a sample block chain
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
@ -824,6 +827,7 @@ func TestCreateOnExistingStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReproduceCrash(t *testing.T) {
|
||||
t.Parallel()
|
||||
// This example was taken from Ropsten contract that used to cause a crash
|
||||
// it is created in the block 598915 and then there are 3 transactions modifying
|
||||
// its storage in the same block:
|
||||
@ -865,6 +869,7 @@ func TestReproduceCrash(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestEip2200Gas(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Configure and generate a sample block chain
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
@ -960,6 +965,7 @@ func TestEip2200Gas(t *testing.T) {
|
||||
|
||||
// Create contract, drop trie, reload trie from disk and add block with contract call
|
||||
func TestWrongIncarnation(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Configure and generate a sample block chain
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
@ -1072,6 +1078,7 @@ func TestWrongIncarnation(t *testing.T) {
|
||||
|
||||
// create acc, deploy to it contract, reorg to state without contract
|
||||
func TestWrongIncarnation2(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Configure and generate a sample block chain
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
@ -1221,6 +1228,7 @@ func TestWrongIncarnation2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChangeAccountCodeBetweenBlocks(t *testing.T) {
|
||||
t.Parallel()
|
||||
contract := libcommon.HexToAddress("0x71dd1027069078091B3ca48093B00E4735B20624")
|
||||
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
@ -1258,6 +1266,7 @@ func TestChangeAccountCodeBetweenBlocks(t *testing.T) {
|
||||
|
||||
// TestCacheCodeSizeSeparately makes sure that we don't store CodeNodes for code sizes
|
||||
func TestCacheCodeSizeSeparately(t *testing.T) {
|
||||
t.Parallel()
|
||||
contract := libcommon.HexToAddress("0x71dd1027069078091B3ca48093B00E4735B20624")
|
||||
//root := libcommon.HexToHash("0xb939e5bcf5809adfb87ab07f0795b05b95a1d64a90f0eddd0c3123ac5b433854")
|
||||
|
||||
@ -1290,6 +1299,7 @@ func TestCacheCodeSizeSeparately(t *testing.T) {
|
||||
|
||||
// TestCacheCodeSizeInTrie makes sure that we dont just read from the DB all the time
|
||||
func TestCacheCodeSizeInTrie(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Skip("switch to TG state readers/writers")
|
||||
contract := libcommon.HexToAddress("0x71dd1027069078091B3ca48093B00E4735B20624")
|
||||
root := libcommon.HexToHash("0xb939e5bcf5809adfb87ab07f0795b05b95a1d64a90f0eddd0c3123ac5b433854")
|
||||
@ -1332,6 +1342,7 @@ func TestCacheCodeSizeInTrie(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRecreateAndRewind(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Configure and generate a sample block chain
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
@ -1531,6 +1542,7 @@ func TestRecreateAndRewind(t *testing.T) {
|
||||
|
||||
}
|
||||
func TestTxLookupUnwind(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
address = crypto.PubkeyToAddress(key.PublicKey)
|
||||
|
@ -2,13 +2,14 @@ package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/dbutils"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv/dbutils"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/holiman/uint256"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
@ -28,6 +29,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMutationDeleteTimestamp(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
acc := make([]*accounts.Account, 10)
|
||||
@ -87,6 +89,7 @@ func TestMutationDeleteTimestamp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMutationCommit(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
numOfAccounts := 5
|
||||
@ -291,6 +294,7 @@ func randomAccount(t *testing.T) (*accounts.Account, libcommon.Address) {
|
||||
*/
|
||||
|
||||
func TestWalkAsOfStatePlain(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
emptyVal := uint256.NewInt(0)
|
||||
@ -451,6 +455,7 @@ func TestWalkAsOfStatePlain(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWalkAsOfUsingFixedBytesStatePlain(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
emptyVal := uint256.NewInt(0)
|
||||
@ -657,6 +662,7 @@ func TestWalkAsOfUsingFixedBytesStatePlain(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWalkAsOfAccountPlain(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
emptyValAcc := accounts.NewAccount()
|
||||
@ -805,6 +811,7 @@ func TestWalkAsOfAccountPlain(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWalkAsOfAccountPlain_WithChunks(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
emptyValAcc := accounts.NewAccount()
|
||||
@ -956,6 +963,7 @@ func TestWalkAsOfAccountPlain_WithChunks(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWalkAsOfStoragePlain_WithChunks(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
numOfAccounts := uint8(4)
|
||||
|
@ -38,6 +38,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSnapshotRandom(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := &quick.Config{MaxCount: 1000}
|
||||
err := quick.Check((*snapshotTest).run, config)
|
||||
if cerr, ok := err.(*quick.CheckError); ok {
|
||||
@ -326,6 +327,7 @@ func (test *snapshotTest) checkEqual(state, checkstate *IntraBlockState) error {
|
||||
}
|
||||
|
||||
func TestTransientStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
state := New(nil)
|
||||
|
||||
key := libcommon.Hash{0x01}
|
||||
|
@ -209,6 +209,7 @@ func (s *StateSuite) TestSnapshotEmpty(c *checker.C) {
|
||||
// use testing instead of checker because checker does not support
|
||||
// printing/logging in tests (-check.vv does not work)
|
||||
func TestSnapshot2(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
w := NewPlainState(tx, 1, nil)
|
||||
state := New(NewPlainState(tx, 1, nil))
|
||||
@ -324,6 +325,7 @@ func compareStateObjects(so0, so1 *stateObject, t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDump(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
w := NewPlainStateWriter(tx, tx, 0)
|
||||
state := New(NewPlainStateReader(tx))
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestEmptyAccount(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 100,
|
||||
@ -31,6 +32,7 @@ func TestEmptyAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEmptyAccount2(t *testing.T) {
|
||||
t.Parallel()
|
||||
encodedAccount := Account{}
|
||||
|
||||
b := make([]byte, encodedAccount.EncodingLengthForStorage())
|
||||
@ -45,6 +47,7 @@ func TestEmptyAccount2(t *testing.T) {
|
||||
// fails if run package tests
|
||||
// account_test.go:57: cant decode the account malformed RLP for Account(c064): prefixLength(1) + dataLength(0) != sliceLength(2) <20>d
|
||||
func TestEmptyAccount_BufferStrangeBehaviour(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{}
|
||||
|
||||
encodedAccount := make([]byte, a.EncodingLengthForStorage())
|
||||
@ -57,6 +60,7 @@ func TestEmptyAccount_BufferStrangeBehaviour(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccountEncodeWithCode(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 2,
|
||||
@ -79,6 +83,7 @@ func TestAccountEncodeWithCode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccountEncodeWithCodeWithStorageSizeHack(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 2,
|
||||
@ -101,6 +106,7 @@ func TestAccountEncodeWithCodeWithStorageSizeHack(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccountEncodeWithoutCode(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 2,
|
||||
@ -123,6 +129,7 @@ func TestAccountEncodeWithoutCode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEncodeAccountWithEmptyBalanceNonNilContractAndNotZeroIncarnation(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 0,
|
||||
@ -143,6 +150,7 @@ func TestEncodeAccountWithEmptyBalanceNonNilContractAndNotZeroIncarnation(t *tes
|
||||
isAccountsEqual(t, a, decodedAccount)
|
||||
}
|
||||
func TestEncodeAccountWithEmptyBalanceAndNotZeroIncarnation(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 0,
|
||||
@ -191,6 +199,7 @@ func isAccountsEqual(t *testing.T, src, dst Account) {
|
||||
}
|
||||
|
||||
func TestIncarnationForEmptyAccount(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 100,
|
||||
@ -216,6 +225,7 @@ func TestIncarnationForEmptyAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEmptyIncarnationForEmptyAccount2(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{}
|
||||
|
||||
encodedAccount := make([]byte, a.EncodingLengthForStorage())
|
||||
@ -235,6 +245,7 @@ func TestEmptyIncarnationForEmptyAccount2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIncarnationWithNonEmptyAccount(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 2,
|
||||
@ -261,6 +272,7 @@ func TestIncarnationWithNonEmptyAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIncarnationWithNoIncarnation(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := Account{
|
||||
Initialised: true,
|
||||
Nonce: 2,
|
||||
|
@ -41,6 +41,7 @@ import (
|
||||
|
||||
// from bcValidBlockTest.json, "SimpleTx"
|
||||
func TestBlockEncoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
blockEnc := common.FromHex("f90260f901f9a083cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a05fe50b260da6308036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67a0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845506eb0780a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4f861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1c0")
|
||||
var block Block
|
||||
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
|
||||
@ -77,6 +78,7 @@ func TestBlockEncoding(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEIP1559BlockEncoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
blockEnc := common.FromHex("f9030bf901fea083cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a05fe50b260da6308036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67a0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845506eb0780a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4843b9aca00f90106f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1b8a302f8a0018080843b9aca008301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000080a0fe38ca4e44a30002ac54af7cf922a6ac2ba11b7d22f548e8ecb3f51f41cb31b0a06de6a5cbae13c0c856e33acf021b51819636cfc009d39eafb9f606d546e305a8c0")
|
||||
var block Block
|
||||
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
|
||||
@ -144,6 +146,7 @@ func TestEIP1559BlockEncoding(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEIP2718BlockEncoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
blockEnc := common.FromHex("f90319f90211a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a0e6e49996c7ec59f7a23d22b83239a60151512c65613bf84a0d7da336399ebc4aa0cafe75574d59780665a97fbfd11365c7545aa8f1abf4e5e12e8243334ef7286bb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000820200832fefd882a410845506eb0796636f6f6c65737420626c6f636b206f6e20636861696ea0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4f90101f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1b89e01f89b01800a8301e24194095e7baea6a6c7c4c2dfeb977efac326af552d878080f838f7940000000000000000000000000000000000000001e1a0000000000000000000000000000000000000000000000000000000000000000001a03dbacc8d0259f2508625e97fdfc57cd85fdd16e5821bc2c10bdd1a52649e8335a0476e10695b183a87b0aa292a7f4b78ef0c3fbe62aa2c42c84e1d9c3da159ef14c0")
|
||||
var block Block
|
||||
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
|
||||
@ -213,6 +216,7 @@ func TestEIP2718BlockEncoding(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUncleHash(t *testing.T) {
|
||||
t.Parallel()
|
||||
uncles := make([]*Header, 0)
|
||||
h := CalcUncleHash(uncles)
|
||||
exp := libcommon.HexToHash("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")
|
||||
@ -277,6 +281,7 @@ func makeBenchBlock() *Block {
|
||||
}
|
||||
|
||||
func TestCanEncodeAndDecodeRawBody(t *testing.T) {
|
||||
t.Parallel()
|
||||
body := &RawBody{
|
||||
Uncles: []*Header{
|
||||
{
|
||||
@ -359,6 +364,7 @@ func TestCanEncodeAndDecodeRawBody(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAuRaHeaderEncoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
difficulty, ok := new(big.Int).SetString("8398142613866510000000000000000000000000000000", 10)
|
||||
require.True(t, ok)
|
||||
|
||||
@ -390,6 +396,7 @@ func TestAuRaHeaderEncoding(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWithdrawalsEncoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
header := Header{
|
||||
ParentHash: libcommon.HexToHash("0x8b00fcf1e541d371a3a1b79cc999a85cc3db5ee5637b5159646e1acd3613fd15"),
|
||||
Coinbase: libcommon.HexToAddress("0x571846e42308df2dad8ed792f44a8bfddf0acb4d"),
|
||||
@ -443,6 +450,7 @@ func TestWithdrawalsEncoding(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlockRawBodyPreShanghai(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
const rawBodyForStorageRlp = "f901f4c0f901f0f901eda00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000808080808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"
|
||||
@ -457,6 +465,7 @@ func TestBlockRawBodyPreShanghai(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlockRawBodyPostShanghaiNoWithdrawals(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
const rawBodyForStorageRlp = "f901f5c0f901f0f901eda00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000808080808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0"
|
||||
@ -472,6 +481,7 @@ func TestBlockRawBodyPostShanghaiNoWithdrawals(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBlockRawBodyPostShanghaiWithdrawals(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
const rawBodyForStorageRlp = "f90230c0f901f0f901eda00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000808080808080a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f83adc0f82157c94ff000000000000000000000000000000000000008203e8dc1082157d94ff000000000000000000000000000000000000008203e9"
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBloom(t *testing.T) {
|
||||
t.Parallel()
|
||||
positive := []string{
|
||||
"testtest",
|
||||
"test",
|
||||
@ -58,6 +59,7 @@ func TestBloom(t *testing.T) {
|
||||
|
||||
// TestBloomExtensively does some more thorough tests
|
||||
func TestBloomExtensively(t *testing.T) {
|
||||
t.Parallel()
|
||||
var exp = libcommon.HexToHash("c8d3ca65cdb4874300a9e39475508f23ed6da09fdbc487f89a2dcf50b09eb263")
|
||||
var b Bloom
|
||||
// Add 100 "random" things
|
||||
|
@ -24,6 +24,7 @@ func genTransactions(n uint64) Transactions {
|
||||
}
|
||||
|
||||
func TestEncodeUint(t *testing.T) {
|
||||
t.Parallel()
|
||||
for i := 0; i < 64000; i++ {
|
||||
bbOld := bytes.NewBuffer(make([]byte, 10))
|
||||
bbNew := bytes.NewBuffer(make([]byte, 10))
|
||||
@ -41,6 +42,7 @@ func TestEncodeUint(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeriveSha(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []DerivableList{
|
||||
Transactions{},
|
||||
genTransactions(1),
|
||||
|
@ -19,10 +19,11 @@ package types
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
)
|
||||
@ -105,6 +106,7 @@ var unmarshalLogTests = map[string]struct {
|
||||
}
|
||||
|
||||
func TestUnmarshalLog(t *testing.T) {
|
||||
t.Parallel()
|
||||
dumper := spew.ConfigState{DisableMethods: true, Indent: " "}
|
||||
for name, test := range unmarshalLogTests {
|
||||
var log *Log
|
||||
@ -135,6 +137,7 @@ func checkError(t *testing.T, testname string, got, want error) bool {
|
||||
}
|
||||
|
||||
func TestFilterLogsTopics(t *testing.T) {
|
||||
t.Parallel()
|
||||
// hashes and addresses to make test more readable
|
||||
var (
|
||||
A libcommon.Hash = [32]byte{1}
|
||||
|
@ -35,6 +35,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDecodeEmptyTypedReceipt(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := []byte{0x80}
|
||||
var r Receipt
|
||||
err := rlp.DecodeBytes(input, &r)
|
||||
@ -44,6 +45,7 @@ func TestDecodeEmptyTypedReceipt(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLegacyReceiptDecoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
encode func(*Receipt) ([]byte, error)
|
||||
@ -78,7 +80,9 @@ func TestLegacyReceiptDecoding(t *testing.T) {
|
||||
receipt.Bloom = CreateBloom(Receipts{receipt})
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
enc, err := tc.encode(receipt)
|
||||
if err != nil {
|
||||
t.Fatalf("Error encoding receipt: %v", err)
|
||||
@ -126,6 +130,7 @@ func encodeAsStoredReceiptRLP(want *Receipt) ([]byte, error) {
|
||||
|
||||
// Tests that receipt data can be correctly derived from the contextual infos
|
||||
func TestDeriveFields(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create a few transactions to have receipts for
|
||||
to2 := libcommon.HexToAddress("0x2")
|
||||
to3 := libcommon.HexToAddress("0x3")
|
||||
@ -262,6 +267,7 @@ func TestDeriveFields(t *testing.T) {
|
||||
// TestTypedReceiptEncodingDecoding reproduces a flaw that existed in the receipt
|
||||
// rlp decoder, which failed due to a shadowing error.
|
||||
func TestTypedReceiptEncodingDecoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
var payload = common.FromHex("f9043eb9010c01f90108018262d4b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010c01f901080182cd14b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010d01f901090183013754b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0b9010d01f90109018301a194b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0")
|
||||
check := func(bundle []*Receipt) {
|
||||
t.Helper()
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
)
|
||||
|
||||
func TestEIP1559Signing(t *testing.T) {
|
||||
t.Parallel()
|
||||
key, _ := crypto.GenerateKey()
|
||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||
|
||||
@ -47,6 +48,7 @@ func TestEIP1559Signing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEIP155Signing(t *testing.T) {
|
||||
t.Parallel()
|
||||
key, _ := crypto.GenerateKey()
|
||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||
|
||||
@ -66,6 +68,7 @@ func TestEIP155Signing(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEIP155ChainId(t *testing.T) {
|
||||
t.Parallel()
|
||||
key, _ := crypto.GenerateKey()
|
||||
addr := crypto.PubkeyToAddress(key.PublicKey)
|
||||
|
||||
@ -98,6 +101,7 @@ func TestEIP155ChainId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEIP155SigningVitalik(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test vectors come from http://vitalik.ca/files/eip155_testvec.txt
|
||||
for i, test := range []struct {
|
||||
txRlp, addr string
|
||||
@ -136,6 +140,7 @@ func TestEIP155SigningVitalik(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChainId(t *testing.T) {
|
||||
t.Parallel()
|
||||
key, _ := defaultTestKey()
|
||||
|
||||
var tx Transaction = NewTransaction(0, libcommon.Address{}, new(uint256.Int), 0, new(uint256.Int), nil)
|
||||
|
@ -105,6 +105,7 @@ var (
|
||||
)
|
||||
|
||||
func TestDecodeEmptyInput(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := []byte{}
|
||||
_, err := DecodeTransaction(input)
|
||||
if !errors.Is(err, io.EOF) {
|
||||
@ -113,6 +114,7 @@ func TestDecodeEmptyInput(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDecodeEmptyTypedTx(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := []byte{0x80}
|
||||
_, err := DecodeTransaction(input)
|
||||
if !errors.Is(err, rlp.EOL) {
|
||||
@ -121,6 +123,7 @@ func TestDecodeEmptyTypedTx(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTransactionSigHash(t *testing.T) {
|
||||
t.Parallel()
|
||||
if emptyTx.SigningHash(nil) != libcommon.HexToHash("c775b99e7ad12f50d819fcd602390467e28141316969f4b57f0626f74fe3b386") {
|
||||
t.Errorf("empty transaction hash mismatch, got %x", emptyTx.SigningHash(nil))
|
||||
}
|
||||
@ -130,6 +133,7 @@ func TestTransactionSigHash(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTransactionEncode(t *testing.T) {
|
||||
t.Parallel()
|
||||
txb, err := rlp.EncodeToBytes(rightvrsTx)
|
||||
if err != nil {
|
||||
t.Fatalf("encode error: %v", err)
|
||||
@ -142,6 +146,7 @@ func TestTransactionEncode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEIP2718TransactionSigHash(t *testing.T) {
|
||||
t.Parallel()
|
||||
if emptyEip2718Tx.SigningHash(big.NewInt(1)) != libcommon.HexToHash("49b486f0ec0a60dfbbca2d30cb07c9e8ffb2a2ff41f29a1ab6737475f6ff69f3") {
|
||||
t.Errorf("empty EIP-2718 transaction hash mismatch, got %x", emptyEip2718Tx.SigningHash(big.NewInt(1)))
|
||||
}
|
||||
@ -233,6 +238,7 @@ func TestEIP2930Signer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEIP2718TransactionEncode(t *testing.T) {
|
||||
t.Parallel()
|
||||
// RLP representation
|
||||
{
|
||||
have, err := rlp.EncodeToBytes(signedEip2718Tx)
|
||||
@ -260,6 +266,7 @@ func TestEIP2718TransactionEncode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
func TestEIP1559TransactionEncode(t *testing.T) {
|
||||
t.Parallel()
|
||||
{
|
||||
var buf bytes.Buffer
|
||||
if err := signedDynFeeTx.MarshalBinary(&buf); err != nil {
|
||||
@ -289,6 +296,7 @@ func defaultTestKey() (*ecdsa.PrivateKey, libcommon.Address) {
|
||||
}
|
||||
|
||||
func TestRecipientEmpty(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, addr := defaultTestKey()
|
||||
tx, err := decodeTx(libcommon.Hex2Bytes("f8498080808080011ca09b16de9d5bdee2cf56c28d16275a4da68cd30273e2525f3959f5d62557489921a0372ebd8fb3345f7db7b5a86d42e24d36e983e259b0664ceb8c227ec9af572f3d"))
|
||||
if err != nil {
|
||||
@ -305,6 +313,7 @@ func TestRecipientEmpty(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRecipientNormal(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, addr := defaultTestKey()
|
||||
|
||||
tx, err := decodeTx(libcommon.Hex2Bytes("f85d80808094000000000000000000000000000000000000000080011ca0527c0d8f5c63f7b9f41324a7c8a563ee1190bcbf0dac8ab446291bdbf32f5c79a0552c4ef0a09a04395074dab9ed34d3fbfb843c2f2546cc30fe89ec143ca94ca6"))
|
||||
@ -325,6 +334,7 @@ func TestRecipientNormal(t *testing.T) {
|
||||
// decreasing order, but at the same time with increasing nonces when issued by
|
||||
// the same account.
|
||||
func TestTransactionPriceNonceSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Generate a batch of accounts to start with
|
||||
keys := make([]*ecdsa.PrivateKey, 25)
|
||||
for i := 0; i < len(keys); i++ {
|
||||
@ -384,6 +394,7 @@ func TestTransactionPriceNonceSort(t *testing.T) {
|
||||
// Tests that if multiple transactions have the same price, the ones seen earlier
|
||||
// are prioritized to avoid network spam attacks aiming for a specific ordering.
|
||||
func TestTransactionTimeSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Generate a batch of accounts to start with
|
||||
keys := make([]*ecdsa.PrivateKey, 5)
|
||||
for i := 0; i < len(keys); i++ {
|
||||
@ -437,6 +448,7 @@ func TestTransactionTimeSort(t *testing.T) {
|
||||
|
||||
// TestTransactionCoding tests serializing/de-serializing to/from rlp and JSON.
|
||||
func TestTransactionCoding(t *testing.T) {
|
||||
t.Parallel()
|
||||
key, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
t.Fatalf("could not generate key: %v", err)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestWithdrawalsHash(t *testing.T) {
|
||||
t.Parallel()
|
||||
w := &Withdrawal{
|
||||
Index: 0,
|
||||
Validator: 0,
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
)
|
||||
|
||||
func TestJumpDestAnalysis(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
code []byte
|
||||
exp uint64
|
||||
|
@ -99,6 +99,7 @@ func testPrecompiled(t *testing.T, addr string, test precompiledTest) {
|
||||
in := libcommon.Hex2Bytes(test.Input)
|
||||
gas := p.RequiredGas(in)
|
||||
t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if res, _, err := RunPrecompiledContract(p, in, gas); err != nil {
|
||||
t.Error(err)
|
||||
} else if common.Bytes2Hex(res) != test.Expected {
|
||||
@ -121,6 +122,7 @@ func testPrecompiledOOG(t *testing.T, addr string, test precompiledTest) {
|
||||
gas := p.RequiredGas(in) - 1
|
||||
|
||||
t.Run(fmt.Sprintf("%s-Gas=%d", test.Name, gas), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, _, err := RunPrecompiledContract(p, in, gas)
|
||||
if err.Error() != "out of gas" {
|
||||
t.Errorf("Expected error [out of gas], got [%v]", err)
|
||||
@ -138,6 +140,7 @@ func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing
|
||||
in := libcommon.Hex2Bytes(test.Input)
|
||||
gas := p.RequiredGas(in)
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, _, err := RunPrecompiledContract(p, in, gas)
|
||||
if err.Error() != test.ExpectedError {
|
||||
t.Errorf("Expected error [%v], got [%v]", test.ExpectedError, err)
|
||||
@ -247,6 +250,7 @@ func BenchmarkPrecompiledBn256Add(b *testing.B) { benchJson("bn256Add", "06", b)
|
||||
|
||||
// Tests OOG
|
||||
func TestPrecompiledModExpOOG(t *testing.T) {
|
||||
t.Parallel()
|
||||
modexpTests, err := loadJson("modexp")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -268,6 +272,7 @@ func TestPrecompiledBlake2F(t *testing.T) { testJson("blake2F", "09", t) }
|
||||
func BenchmarkPrecompiledBlake2F(b *testing.B) { benchJson("blake2F", "09", b) }
|
||||
|
||||
func TestPrecompileBlake2FMalformedInput(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, test := range blake2FMalformedInputTests {
|
||||
testPrecompiledFailure("09", test, t)
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestInterpreterReadonly(t *testing.T) {
|
||||
t.Parallel()
|
||||
rapid.Check(t, func(t *rapid.T) {
|
||||
env := NewEVM(evmtypes.BlockContext{}, evmtypes.TxContext{}, &dummyStatedb{}, params.TestChainConfig, Config{})
|
||||
|
||||
@ -118,6 +119,7 @@ func TestInterpreterReadonly(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadonlyBasicCases(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
testName string
|
||||
readonlySliceTest []bool
|
||||
@ -267,6 +269,7 @@ func TestReadonlyBasicCases(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(testcase.testName+evmsTestcase.suffix, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
readonlySliceTest := testcase.readonlySliceTest
|
||||
|
||||
env := NewEVM(evmtypes.BlockContext{}, evmtypes.TxContext{}, &dummyStatedb{}, params.TestChainConfig, Config{})
|
||||
|
@ -19,11 +19,12 @@ package vm
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
"math"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
@ -37,6 +38,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMemoryGasCost(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
size uint64
|
||||
cost uint64
|
||||
@ -92,6 +94,7 @@ func TestEIP2200(t *testing.T) {
|
||||
i := i
|
||||
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
address := libcommon.BytesToAddress([]byte("contract"))
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
|
||||
@ -137,6 +140,7 @@ var createGasTests = []struct {
|
||||
}
|
||||
|
||||
func TestCreateGas(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, db, _ := temporal.NewTestDB(t, datadir.New(t.TempDir()), nil)
|
||||
for i, tt := range createGasTests {
|
||||
address := libcommon.BytesToAddress([]byte("contract"))
|
||||
|
@ -135,6 +135,7 @@ func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFu
|
||||
}
|
||||
|
||||
func TestByteOp(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []TwoOperandTestcase{
|
||||
{"ABCDEF0908070605040302010000000000000000000000000000000000000000", "00", "AB"},
|
||||
{"ABCDEF0908070605040302010000000000000000000000000000000000000000", "01", "CD"},
|
||||
@ -149,6 +150,7 @@ func TestByteOp(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSHL(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Testcases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-145.md#shl-shift-left
|
||||
tests := []TwoOperandTestcase{
|
||||
{"0000000000000000000000000000000000000000000000000000000000000001", "01", "0000000000000000000000000000000000000000000000000000000000000002"},
|
||||
@ -166,6 +168,7 @@ func TestSHL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSHR(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Testcases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-145.md#shr-logical-shift-right
|
||||
tests := []TwoOperandTestcase{
|
||||
{"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
|
||||
@ -184,6 +187,7 @@ func TestSHR(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSAR(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Testcases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-145.md#sar-arithmetic-shift-right
|
||||
tests := []TwoOperandTestcase{
|
||||
{"0000000000000000000000000000000000000000000000000000000000000001", "00", "0000000000000000000000000000000000000000000000000000000000000001"},
|
||||
@ -208,6 +212,7 @@ func TestSAR(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddMod(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
env = NewEVM(evmtypes.BlockContext{}, evmtypes.TxContext{}, nil, params.TestChainConfig, Config{})
|
||||
stack = stack.New()
|
||||
@ -283,6 +288,7 @@ func TestAddMod(t *testing.T) {
|
||||
|
||||
// TestJsonTestcases runs through all the testcases defined as json-files
|
||||
func TestJsonTestcases(t *testing.T) {
|
||||
t.Parallel()
|
||||
for name := range twoOpMethods {
|
||||
data, err := os.ReadFile(fmt.Sprintf("testdata/testcases_%v.json", name))
|
||||
if err != nil {
|
||||
@ -529,6 +535,7 @@ func BenchmarkOpIsZero(b *testing.B) {
|
||||
}
|
||||
|
||||
func TestOpMstore(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
env = NewEVM(evmtypes.BlockContext{}, evmtypes.TxContext{}, nil, params.TestChainConfig, Config{})
|
||||
stack = stack.New()
|
||||
@ -574,6 +581,7 @@ func BenchmarkOpMstore(bench *testing.B) {
|
||||
}
|
||||
|
||||
func TestOpTstore(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
state = state.New(nil)
|
||||
env = NewEVM(evmtypes.BlockContext{}, evmtypes.TxContext{}, state, params.TestChainConfig, Config{})
|
||||
@ -632,6 +640,7 @@ func BenchmarkOpKeccak256(bench *testing.B) {
|
||||
}
|
||||
|
||||
func TestCreate2Addreses(t *testing.T) {
|
||||
t.Parallel()
|
||||
type testcase struct {
|
||||
origin string
|
||||
salt string
|
||||
@ -706,6 +715,7 @@ func TestCreate2Addreses(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOpMCopy(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test cases from https://eips.ethereum.org/EIPS/eip-5656#test-cases
|
||||
for i, tc := range []struct {
|
||||
dst, src, len string
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMemoryCopy(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test cases from https://eips.ethereum.org/EIPS/eip-5656#test-cases
|
||||
for i, tc := range []struct {
|
||||
dst, src, len uint64
|
||||
|
@ -39,6 +39,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDefaults(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := new(Config)
|
||||
setDefaults(cfg)
|
||||
|
||||
@ -67,6 +68,7 @@ func TestDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEVM(t *testing.T) {
|
||||
t.Parallel()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Fatalf("crashed with: %v", r)
|
||||
@ -87,6 +89,7 @@ func TestEVM(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecute(t *testing.T) {
|
||||
t.Parallel()
|
||||
ret, _, err := Execute([]byte{
|
||||
byte(vm.PUSH1), 10,
|
||||
byte(vm.PUSH1), 0,
|
||||
@ -106,6 +109,7 @@ func TestExecute(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCall(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, tx := memdb.NewTestTx(t)
|
||||
state := state.New(state.NewDbStateReader(tx))
|
||||
address := libcommon.HexToAddress("0xaa")
|
||||
@ -264,6 +268,7 @@ func (d *dummyChain) GetHeader(h libcommon.Hash, n uint64) *types.Header {
|
||||
// TestBlockhash tests the blockhash operation. It's a bit special, since it internally
|
||||
// requires access to a chain reader.
|
||||
func TestBlockhash(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Current head
|
||||
n := uint64(1000)
|
||||
parentHash := libcommon.Hash{}
|
||||
|
Loading…
Reference in New Issue
Block a user