fix linters

This commit is contained in:
Arpit Temani 2023-09-21 10:50:01 +05:30
parent 735ae740fa
commit cc2c27dbd3
20 changed files with 64 additions and 27 deletions

View file

@ -58,6 +58,7 @@ type snapshotTestBasic struct {
} }
func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Block) { func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Block) {
t.Helper()
// Create a temporary persistent database // Create a temporary persistent database
datadir := t.TempDir() datadir := t.TempDir()
@ -129,6 +130,7 @@ func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Blo
} }
func (basic *snapshotTestBasic) verify(t *testing.T, chain *BlockChain, blocks []*types.Block) { func (basic *snapshotTestBasic) verify(t *testing.T, chain *BlockChain, blocks []*types.Block) {
t.Helper()
// Iterate over all the remaining blocks and ensure there are no gaps // Iterate over all the remaining blocks and ensure there are no gaps
verifyNoGaps(t, chain, true, blocks) verifyNoGaps(t, chain, true, blocks)
verifyCutoff(t, chain, true, blocks, basic.expCanonicalBlocks) verifyCutoff(t, chain, true, blocks, basic.expCanonicalBlocks)

View file

@ -184,6 +184,7 @@ func BenchmarkPriceHeapReinit50GB(b *testing.B) { benchmarkPriceHeapReinit(b, 5
func BenchmarkPriceHeapReinit100GB(b *testing.B) { benchmarkPriceHeapReinit(b, 100*1024*1024*1024) } func BenchmarkPriceHeapReinit100GB(b *testing.B) { benchmarkPriceHeapReinit(b, 100*1024*1024*1024) }
func benchmarkPriceHeapReinit(b *testing.B, datacap uint64) { func benchmarkPriceHeapReinit(b *testing.B, datacap uint64) {
b.Helper()
// Calculate how many unique transactions we can fit into the provided disk // Calculate how many unique transactions we can fit into the provided disk
// data cap // data cap
blobs := datacap / (params.BlobTxBytesPerFieldElement * params.BlobTxFieldElementsPerBlob) blobs := datacap / (params.BlobTxBytesPerFieldElement * params.BlobTxFieldElementsPerBlob)
@ -244,6 +245,7 @@ func BenchmarkPriceHeapOverflow50GB(b *testing.B) { benchmarkPriceHeapOverflow(
func BenchmarkPriceHeapOverflow100GB(b *testing.B) { benchmarkPriceHeapOverflow(b, 100*1024*1024*1024) } func BenchmarkPriceHeapOverflow100GB(b *testing.B) { benchmarkPriceHeapOverflow(b, 100*1024*1024*1024) }
func benchmarkPriceHeapOverflow(b *testing.B, datacap uint64) { func benchmarkPriceHeapOverflow(b *testing.B, datacap uint64) {
b.Helper()
// Calculate how many unique transactions we can fit into the provided disk // Calculate how many unique transactions we can fit into the provided disk
// data cap // data cap
blobs := datacap / (params.BlobTxBytesPerFieldElement * params.BlobTxFieldElementsPerBlob) blobs := datacap / (params.BlobTxBytesPerFieldElement * params.BlobTxFieldElementsPerBlob)

View file

@ -349,15 +349,15 @@ func testSetNonce(pool *LegacyPool, addr common.Address, nonce uint64) {
pool.mu.Unlock() pool.mu.Unlock()
} }
func getBalance(pool *LegacyPool, addr common.Address) *big.Int { // func getBalance(pool *LegacyPool, addr common.Address) *big.Int {
bal := big.NewInt(0) // bal := big.NewInt(0)
pool.mu.Lock() // pool.mu.Lock()
bal.Set(pool.currentState.GetBalance(addr)) // bal.Set(pool.currentState.GetBalance(addr))
pool.mu.Unlock() // pool.mu.Unlock()
return bal // return bal
} // }
func TestInvalidTransactions(t *testing.T) { func TestInvalidTransactions(t *testing.T) {
t.Parallel() t.Parallel()
@ -3263,15 +3263,15 @@ func BenchmarkPoolAccountsBatchInsert(b *testing.B) {
// <-done // <-done
// } // }
func newTxs(pool *LegacyPool) *types.Transaction { // func newTxs(pool *LegacyPool) *types.Transaction {
key, _ := crypto.GenerateKey() // key, _ := crypto.GenerateKey()
account := crypto.PubkeyToAddress(key.PublicKey) // account := crypto.PubkeyToAddress(key.PublicKey)
tx := transaction(uint64(0), 100000, key) // tx := transaction(uint64(0), 100000, key)
pool.currentState.AddBalance(account, big.NewInt(1_000_000_000)) // pool.currentState.AddBalance(account, big.NewInt(1_000_000_000))
return tx // return tx
} // }
type acc struct { type acc struct {
nonce uint64 nonce uint64

View file

@ -70,7 +70,6 @@ type TxPool struct {
reservations map[common.Address]SubPool // Map with the account to pool reservations reservations map[common.Address]SubPool // Map with the account to pool reservations
reserveLock sync.Mutex // Lock protecting the account reservations reserveLock sync.Mutex // Lock protecting the account reservations
subs event.SubscriptionScope // Subscription scope to unscubscribe all on shutdown
quit chan chan error // Quit channel to tear down the head updater quit chan chan error // Quit channel to tear down the head updater
} }

View file

@ -929,11 +929,11 @@ func TestOpMCopy(t *testing.T) {
mem.Resize(uint64(len(data))) mem.Resize(uint64(len(data)))
mem.Set(0, uint64(len(data)), data) mem.Set(0, uint64(len(data)), data)
// Push stack args // Push stack args
len, _ := uint256.FromHex(tc.len) length, _ := uint256.FromHex(tc.len)
src, _ := uint256.FromHex(tc.src) src, _ := uint256.FromHex(tc.src)
dst, _ := uint256.FromHex(tc.dst) dst, _ := uint256.FromHex(tc.dst)
stack.push(len) stack.push(length)
stack.push(src) stack.push(src)
stack.push(dst) stack.push(dst)
wantErr := (tc.wantGas == 0) wantErr := (tc.wantGas == 0)

View file

@ -109,9 +109,9 @@ func (m *Memory) Data() []byte {
// The source and destination may overlap. // The source and destination may overlap.
// OBS: This operation assumes that any necessary memory expansion has already been performed, // OBS: This operation assumes that any necessary memory expansion has already been performed,
// and this method may panic otherwise. // and this method may panic otherwise.
func (m *Memory) Copy(dst, src, len uint64) { func (m *Memory) Copy(dst, src, length uint64) {
if len == 0 { if length == 0 {
return return
} }
copy(m.store[dst:], m.store[src:src+len]) copy(m.store[dst:], m.store[src:src+length])
} }

View file

@ -48,6 +48,7 @@ func randBlob() Blob {
func TestCKZGWithPoint(t *testing.T) { testKZGWithPoint(t, true) } func TestCKZGWithPoint(t *testing.T) { testKZGWithPoint(t, true) }
func TestGoKZGWithPoint(t *testing.T) { testKZGWithPoint(t, false) } func TestGoKZGWithPoint(t *testing.T) { testKZGWithPoint(t, false) }
func testKZGWithPoint(t *testing.T, ckzg bool) { func testKZGWithPoint(t *testing.T, ckzg bool) {
t.Helper()
if ckzg && !ckzgAvailable { if ckzg && !ckzgAvailable {
t.Skip("CKZG unavailable in this test build") t.Skip("CKZG unavailable in this test build")
} }
@ -73,6 +74,7 @@ func testKZGWithPoint(t *testing.T, ckzg bool) {
func TestCKZGWithBlob(t *testing.T) { testKZGWithBlob(t, true) } func TestCKZGWithBlob(t *testing.T) { testKZGWithBlob(t, true) }
func TestGoKZGWithBlob(t *testing.T) { testKZGWithBlob(t, false) } func TestGoKZGWithBlob(t *testing.T) { testKZGWithBlob(t, false) }
func testKZGWithBlob(t *testing.T, ckzg bool) { func testKZGWithBlob(t *testing.T, ckzg bool) {
t.Helper()
if ckzg && !ckzgAvailable { if ckzg && !ckzgAvailable {
t.Skip("CKZG unavailable in this test build") t.Skip("CKZG unavailable in this test build")
} }
@ -97,6 +99,7 @@ func testKZGWithBlob(t *testing.T, ckzg bool) {
func BenchmarkCKZGBlobToCommitment(b *testing.B) { benchmarkBlobToCommitment(b, true) } func BenchmarkCKZGBlobToCommitment(b *testing.B) { benchmarkBlobToCommitment(b, true) }
func BenchmarkGoKZGBlobToCommitment(b *testing.B) { benchmarkBlobToCommitment(b, false) } func BenchmarkGoKZGBlobToCommitment(b *testing.B) { benchmarkBlobToCommitment(b, false) }
func benchmarkBlobToCommitment(b *testing.B, ckzg bool) { func benchmarkBlobToCommitment(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable { if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build") b.Skip("CKZG unavailable in this test build")
} }
@ -114,6 +117,7 @@ func benchmarkBlobToCommitment(b *testing.B, ckzg bool) {
func BenchmarkCKZGComputeProof(b *testing.B) { benchmarkComputeProof(b, true) } func BenchmarkCKZGComputeProof(b *testing.B) { benchmarkComputeProof(b, true) }
func BenchmarkGoKZGComputeProof(b *testing.B) { benchmarkComputeProof(b, false) } func BenchmarkGoKZGComputeProof(b *testing.B) { benchmarkComputeProof(b, false) }
func benchmarkComputeProof(b *testing.B, ckzg bool) { func benchmarkComputeProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable { if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build") b.Skip("CKZG unavailable in this test build")
} }
@ -134,6 +138,7 @@ func benchmarkComputeProof(b *testing.B, ckzg bool) {
func BenchmarkCKZGVerifyProof(b *testing.B) { benchmarkVerifyProof(b, true) } func BenchmarkCKZGVerifyProof(b *testing.B) { benchmarkVerifyProof(b, true) }
func BenchmarkGoKZGVerifyProof(b *testing.B) { benchmarkVerifyProof(b, false) } func BenchmarkGoKZGVerifyProof(b *testing.B) { benchmarkVerifyProof(b, false) }
func benchmarkVerifyProof(b *testing.B, ckzg bool) { func benchmarkVerifyProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable { if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build") b.Skip("CKZG unavailable in this test build")
} }
@ -156,6 +161,7 @@ func benchmarkVerifyProof(b *testing.B, ckzg bool) {
func BenchmarkCKZGComputeBlobProof(b *testing.B) { benchmarkComputeBlobProof(b, true) } func BenchmarkCKZGComputeBlobProof(b *testing.B) { benchmarkComputeBlobProof(b, true) }
func BenchmarkGoKZGComputeBlobProof(b *testing.B) { benchmarkComputeBlobProof(b, false) } func BenchmarkGoKZGComputeBlobProof(b *testing.B) { benchmarkComputeBlobProof(b, false) }
func benchmarkComputeBlobProof(b *testing.B, ckzg bool) { func benchmarkComputeBlobProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable { if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build") b.Skip("CKZG unavailable in this test build")
} }
@ -176,6 +182,7 @@ func benchmarkComputeBlobProof(b *testing.B, ckzg bool) {
func BenchmarkCKZGVerifyBlobProof(b *testing.B) { benchmarkVerifyBlobProof(b, true) } func BenchmarkCKZGVerifyBlobProof(b *testing.B) { benchmarkVerifyBlobProof(b, true) }
func BenchmarkGoKZGVerifyBlobProof(b *testing.B) { benchmarkVerifyBlobProof(b, false) } func BenchmarkGoKZGVerifyBlobProof(b *testing.B) { benchmarkVerifyBlobProof(b, false) }
func benchmarkVerifyBlobProof(b *testing.B, ckzg bool) { func benchmarkVerifyBlobProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable { if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build") b.Skip("CKZG unavailable in this test build")
} }

View file

@ -47,6 +47,7 @@ var (
) )
func newTestBackend(t *testing.T) (*node.Node, []*types.Block) { func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
t.Helper()
// Generate test chain. // Generate test chain.
genesis, blocks := generateTestChain() genesis, blocks := generateTestChain()
// Create node // Create node
@ -168,6 +169,7 @@ func TestGethClient(t *testing.T) {
} }
func testAccessList(t *testing.T, client *rpc.Client) { func testAccessList(t *testing.T, client *rpc.Client) {
t.Helper()
ec := New(client) ec := New(client)
// Test transfer // Test transfer
msg := ethereum.CallMsg{ msg := ethereum.CallMsg{
@ -271,6 +273,7 @@ func testGetProof(t *testing.T, client *rpc.Client) {
} }
func testGetProofCanonicalizeKeys(t *testing.T, client *rpc.Client) { func testGetProofCanonicalizeKeys(t *testing.T, client *rpc.Client) {
t.Helper()
ec := New(client) ec := New(client)
// Tests with non-canon input for storage keys. // Tests with non-canon input for storage keys.
@ -533,6 +536,7 @@ func TestBlockOverridesMarshal(t *testing.T) {
} }
func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) { func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) {
t.Helper()
ec := New(client) ec := New(client)
msg := ethereum.CallMsg{ msg := ethereum.CallMsg{
From: testAddr, From: testAddr,

View file

@ -423,6 +423,7 @@ func TestWithdrawals(t *testing.T) {
} }
func createNode(t *testing.T) *node.Node { func createNode(t *testing.T) *node.Node {
t.Helper()
stack, err := node.New(&node.Config{ stack, err := node.New(&node.Config{
HTTPHost: "127.0.0.1", HTTPHost: "127.0.0.1",
HTTPPort: 0, HTTPPort: 0,
@ -437,6 +438,7 @@ func createNode(t *testing.T) *node.Node {
} }
func newGQLService(t *testing.T, stack *node.Node, shanghai bool, gspec *core.Genesis, genBlocks int, genfunc func(i int, gen *core.BlockGen)) (*handler, []*types.Block) { func newGQLService(t *testing.T, stack *node.Node, shanghai bool, gspec *core.Genesis, genBlocks int, genfunc func(i int, gen *core.BlockGen)) (*handler, []*types.Block) {
t.Helper()
ethConf := &ethconfig.Config{ ethConf := &ethconfig.Config{
Genesis: gspec, Genesis: gspec,
NetworkId: 1337, NetworkId: 1337,

View file

@ -387,6 +387,7 @@ type testBackend struct {
} }
func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i int, b *core.BlockGen)) *testBackend { func newTestBackend(t *testing.T, n int, gspec *core.Genesis, generator func(i int, b *core.BlockGen)) *testBackend {
t.Helper()
var ( var (
engine = ethash.NewFaker() engine = ethash.NewFaker()
cacheConfig = &core.CacheConfig{ cacheConfig = &core.CacheConfig{

View file

@ -1012,7 +1012,7 @@ func (p *clientPeer) Handshake(td *big.Int, head common.Hash, headNum uint64, ge
// If local ethereum node is running in archive mode, advertise ourselves we have // If local ethereum node is running in archive mode, advertise ourselves we have
// all version state data. Otherwise only recent state is available. // all version state data. Otherwise only recent state is available.
stateRecent := uint64(core.DefaultCacheConfig.TriesInMemory - blockSafetyMargin) stateRecent := core.DefaultCacheConfig.TriesInMemory - blockSafetyMargin
if server.archiveMode { if server.archiveMode {
stateRecent = 0 stateRecent = 0
} }

View file

@ -24,6 +24,7 @@ func BenchmarkRegistryGetOrRegisterParallel_32(b *testing.B) {
} }
func benchmarkRegistryGetOrRegisterParallel(b *testing.B, amount int) { func benchmarkRegistryGetOrRegisterParallel(b *testing.B, amount int) {
b.Helper()
r := NewRegistry() r := NewRegistry()
b.ResetTimer() b.ResetTimer()
var wg sync.WaitGroup var wg sync.WaitGroup

View file

@ -407,6 +407,7 @@ func TestEmptyWorkClique(t *testing.T) {
} }
func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consensus.Engine) { func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consensus.Engine) {
t.Helper()
defer engine.Close() defer engine.Close()
w, _ := newTestWorker(t, chainConfig, engine, rawdb.NewMemoryDatabase(), 0) w, _ := newTestWorker(t, chainConfig, engine, rawdb.NewMemoryDatabase(), 0)

View file

@ -79,15 +79,15 @@ func (cap Cap) String() string {
} }
// Cmp defines the canonical sorting order of capabilities. // Cmp defines the canonical sorting order of capabilities.
func (cap Cap) Cmp(other Cap) int { func (capacity Cap) Cmp(other Cap) int {
if cap.Name == other.Name { if capacity.Name == other.Name {
if cap.Version < other.Version { if capacity.Version < other.Version {
return -1 return -1
} }
if cap.Version > other.Version { if capacity.Version > other.Version {
return 1 return 1
} }
return 0 return 0
} }
return strings.Compare(cap.Name, other.Name) return strings.Compare(capacity.Name, other.Name)
} }

View file

@ -140,6 +140,7 @@ func TestNodeIteratorCoverage(t *testing.T) {
} }
func testNodeIteratorCoverage(t *testing.T, scheme string) { func testNodeIteratorCoverage(t *testing.T, scheme string) {
t.Helper()
// Create some arbitrary test trie to iterate // Create some arbitrary test trie to iterate
db, nodeDb, trie, _ := makeTestTrie(scheme) db, nodeDb, trie, _ := makeTestTrie(scheme)
@ -492,6 +493,7 @@ func TestIteratorContinueAfterSeekError(t *testing.T) {
} }
func testIteratorContinueAfterSeekError(t *testing.T, memonly bool, scheme string) { func testIteratorContinueAfterSeekError(t *testing.T, memonly bool, scheme string) {
t.Helper()
// Commit test trie to db, then remove the node containing "bars". // Commit test trie to db, then remove the node containing "bars".
var ( var (
barNodePath []byte barNodePath []byte
@ -660,6 +662,7 @@ func TestNodeIteratorLargeTrie(t *testing.T) {
} }
func testIteratorNodeBlob(t *testing.T, scheme string) { func testIteratorNodeBlob(t *testing.T, scheme string) {
t.Helper()
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
triedb = newTestDatabase(db, scheme) triedb = newTestDatabase(db, scheme)

View file

@ -72,6 +72,7 @@ func makeTestTrie(scheme string) (ethdb.Database, *Database, *StateTrie, map[str
// checkTrieContents cross references a reconstructed trie with an expected data // checkTrieContents cross references a reconstructed trie with an expected data
// content map. // content map.
func checkTrieContents(t *testing.T, db ethdb.Database, scheme string, root []byte, content map[string][]byte) { func checkTrieContents(t *testing.T, db ethdb.Database, scheme string, root []byte, content map[string][]byte) {
t.Helper()
// Check root availability and trie contents // Check root availability and trie contents
ndb := newTestDatabase(db, scheme) ndb := newTestDatabase(db, scheme)
trie, err := NewStateTrie(TrieID(common.BytesToHash(root)), ndb) trie, err := NewStateTrie(TrieID(common.BytesToHash(root)), ndb)
@ -144,6 +145,7 @@ func TestIterativeSync(t *testing.T) {
} }
func testIterativeSync(t *testing.T, count int, bypath bool, scheme string) { func testIterativeSync(t *testing.T, count int, bypath bool, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme) _, srcDb, srcTrie, srcData := makeTestTrie(scheme)
@ -229,6 +231,7 @@ func TestIterativeDelayedSync(t *testing.T) {
} }
func testIterativeDelayedSync(t *testing.T, scheme string) { func testIterativeDelayedSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme) _, srcDb, srcTrie, srcData := makeTestTrie(scheme)
@ -305,6 +308,7 @@ func TestIterativeRandomSyncIndividual(t *testing.T) {
} }
func testIterativeRandomSync(t *testing.T, count int, scheme string) { func testIterativeRandomSync(t *testing.T, count int, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme) _, srcDb, srcTrie, srcData := makeTestTrie(scheme)
@ -378,6 +382,7 @@ func TestIterativeRandomDelayedSync(t *testing.T) {
} }
func testIterativeRandomDelayedSync(t *testing.T, scheme string) { func testIterativeRandomDelayedSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme) _, srcDb, srcTrie, srcData := makeTestTrie(scheme)
@ -458,6 +463,7 @@ func TestDuplicateAvoidanceSync(t *testing.T) {
} }
func testDuplicateAvoidanceSync(t *testing.T, scheme string) { func testDuplicateAvoidanceSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme) _, srcDb, srcTrie, srcData := makeTestTrie(scheme)
@ -538,6 +544,7 @@ func TestIncompleteSyncHash(t *testing.T) {
} }
func testIncompleteSync(t *testing.T, scheme string) { func testIncompleteSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, _ := makeTestTrie(scheme) _, srcDb, srcTrie, _ := makeTestTrie(scheme)
@ -634,6 +641,7 @@ func TestSyncOrdering(t *testing.T) {
} }
func testSyncOrdering(t *testing.T, scheme string) { func testSyncOrdering(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme) _, srcDb, srcTrie, srcData := makeTestTrie(scheme)
@ -720,6 +728,7 @@ func testSyncOrdering(t *testing.T, scheme string) {
} }
func syncWith(t *testing.T, root common.Hash, db ethdb.Database, srcDb *Database) { func syncWith(t *testing.T, root common.Hash, db ethdb.Database, srcDb *Database) {
t.Helper()
// Create a destination trie and sync with the scheduler // Create a destination trie and sync with the scheduler
sched := NewSync(root, db, nil, srcDb.Scheme()) sched := NewSync(root, db, nil, srcDb.Scheme())
@ -779,6 +788,7 @@ func TestSyncMovingTarget(t *testing.T) {
} }
func testSyncMovingTarget(t *testing.T, scheme string) { func testSyncMovingTarget(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy // Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme) _, srcDb, srcTrie, srcData := makeTestTrie(scheme)

View file

@ -86,6 +86,7 @@ func TestMissingNode(t *testing.T) {
} }
func testMissingNode(t *testing.T, memonly bool, scheme string) { func testMissingNode(t *testing.T, memonly bool, scheme string) {
t.Helper()
diskdb := rawdb.NewMemoryDatabase() diskdb := rawdb.NewMemoryDatabase()
triedb := newTestDatabase(diskdb, scheme) triedb := newTestDatabase(diskdb, scheme)

View file

@ -96,6 +96,7 @@ type tester struct {
} }
func newTester(t *testing.T) *tester { func newTester(t *testing.T) *tester {
t.Helper()
var ( var (
disk, _ = rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false) disk, _ = rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false)
db = New(disk, &Config{CleanSize: 256 * 1024, DirtySize: 256 * 1024}) db = New(disk, &Config{CleanSize: 256 * 1024, DirtySize: 256 * 1024})

View file

@ -55,6 +55,7 @@ func BenchmarkSearch512Layers(b *testing.B) { benchmarkSearch(b, 0, 512) }
func BenchmarkSearch1Layer(b *testing.B) { benchmarkSearch(b, 127, 128) } func BenchmarkSearch1Layer(b *testing.B) { benchmarkSearch(b, 127, 128) }
func benchmarkSearch(b *testing.B, depth int, total int) { func benchmarkSearch(b *testing.B, depth int, total int) {
b.Helper()
var ( var (
npath []byte npath []byte
nhash common.Hash nhash common.Hash

View file

@ -103,6 +103,7 @@ func TestEncodeDecodeHistory(t *testing.T) {
} }
func checkHistory(t *testing.T, db ethdb.KeyValueReader, freezer *rawdb.ResettableFreezer, id uint64, root common.Hash, exist bool) { func checkHistory(t *testing.T, db ethdb.KeyValueReader, freezer *rawdb.ResettableFreezer, id uint64, root common.Hash, exist bool) {
t.Helper()
blob := rawdb.ReadStateHistoryMeta(freezer, id) blob := rawdb.ReadStateHistoryMeta(freezer, id)
if exist && len(blob) == 0 { if exist && len(blob) == 0 {
t.Fatalf("Failed to load trie history, %d", id) t.Fatalf("Failed to load trie history, %d", id)
@ -119,6 +120,7 @@ func checkHistory(t *testing.T, db ethdb.KeyValueReader, freezer *rawdb.Resettab
} }
func checkHistoriesInRange(t *testing.T, db ethdb.KeyValueReader, freezer *rawdb.ResettableFreezer, from, to uint64, roots []common.Hash, exist bool) { func checkHistoriesInRange(t *testing.T, db ethdb.KeyValueReader, freezer *rawdb.ResettableFreezer, from, to uint64, roots []common.Hash, exist bool) {
t.Helper()
for i, j := from, 0; i <= to; i, j = i+1, j+1 { for i, j := from, 0; i <= to; i, j = i+1, j+1 {
checkHistory(t, db, freezer, i, roots[j], exist) checkHistory(t, db, freezer, i, roots[j], exist)
} }