Skip to content

Commit

Permalink
fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
temaniarpit27 committed Sep 21, 2023
1 parent 735ae74 commit cc2c27d
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 27 deletions.
2 changes: 2 additions & 0 deletions core/blockchain_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type snapshotTestBasic struct {
}

func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Block) {
t.Helper()
// Create a temporary persistent database
datadir := t.TempDir()

Expand Down Expand Up @@ -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) {
t.Helper()
// Iterate over all the remaining blocks and ensure there are no gaps
verifyNoGaps(t, chain, true, blocks)
verifyCutoff(t, chain, true, blocks, basic.expCanonicalBlocks)
Expand Down
2 changes: 2 additions & 0 deletions core/txpool/blobpool/evictheap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func BenchmarkPriceHeapReinit50GB(b *testing.B) { benchmarkPriceHeapReinit(b, 5
func BenchmarkPriceHeapReinit100GB(b *testing.B) { benchmarkPriceHeapReinit(b, 100*1024*1024*1024) }

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

func benchmarkPriceHeapOverflow(b *testing.B, datacap uint64) {
b.Helper()
// Calculate how many unique transactions we can fit into the provided disk
// data cap
blobs := datacap / (params.BlobTxBytesPerFieldElement * params.BlobTxFieldElementsPerBlob)
Expand Down
28 changes: 14 additions & 14 deletions core/txpool/legacypool/legacypool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ func testSetNonce(pool *LegacyPool, addr common.Address, nonce uint64) {
pool.mu.Unlock()
}

func getBalance(pool *LegacyPool, addr common.Address) *big.Int {
bal := big.NewInt(0)
// func getBalance(pool *LegacyPool, addr common.Address) *big.Int {
// bal := big.NewInt(0)

pool.mu.Lock()
bal.Set(pool.currentState.GetBalance(addr))
pool.mu.Unlock()
// pool.mu.Lock()
// bal.Set(pool.currentState.GetBalance(addr))
// pool.mu.Unlock()

return bal
}
// return bal
// }

func TestInvalidTransactions(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -3263,15 +3263,15 @@ func BenchmarkPoolAccountsBatchInsert(b *testing.B) {
// <-done
// }

func newTxs(pool *LegacyPool) *types.Transaction {
key, _ := crypto.GenerateKey()
account := crypto.PubkeyToAddress(key.PublicKey)
tx := transaction(uint64(0), 100000, key)
// func newTxs(pool *LegacyPool) *types.Transaction {
// key, _ := crypto.GenerateKey()
// account := crypto.PubkeyToAddress(key.PublicKey)
// 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 {
nonce uint64
Expand Down
3 changes: 1 addition & 2 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ type TxPool struct {
reservations map[common.Address]SubPool // Map with the account to pool 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
}

// New creates a new transaction pool to gather, sort and filter inbound
Expand Down
4 changes: 2 additions & 2 deletions core/vm/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,11 +929,11 @@ func TestOpMCopy(t *testing.T) {
mem.Resize(uint64(len(data)))
mem.Set(0, uint64(len(data)), data)
// Push stack args
len, _ := uint256.FromHex(tc.len)
length, _ := uint256.FromHex(tc.len)
src, _ := uint256.FromHex(tc.src)
dst, _ := uint256.FromHex(tc.dst)

stack.push(len)
stack.push(length)
stack.push(src)
stack.push(dst)
wantErr := (tc.wantGas == 0)
Expand Down
6 changes: 3 additions & 3 deletions core/vm/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ func (m *Memory) Data() []byte {
// The source and destination may overlap.
// OBS: This operation assumes that any necessary memory expansion has already been performed,
// and this method may panic otherwise.
func (m *Memory) Copy(dst, src, len uint64) {
if len == 0 {
func (m *Memory) Copy(dst, src, length uint64) {
if length == 0 {
return
}
copy(m.store[dst:], m.store[src:src+len])
copy(m.store[dst:], m.store[src:src+length])
}
7 changes: 7 additions & 0 deletions crypto/kzg4844/kzg4844_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func randBlob() Blob {
func TestCKZGWithPoint(t *testing.T) { testKZGWithPoint(t, true) }
func TestGoKZGWithPoint(t *testing.T) { testKZGWithPoint(t, false) }
func testKZGWithPoint(t *testing.T, ckzg bool) {
t.Helper()
if ckzg && !ckzgAvailable {
t.Skip("CKZG unavailable in this test build")
}
Expand All @@ -73,6 +74,7 @@ func testKZGWithPoint(t *testing.T, ckzg bool) {
func TestCKZGWithBlob(t *testing.T) { testKZGWithBlob(t, true) }
func TestGoKZGWithBlob(t *testing.T) { testKZGWithBlob(t, false) }
func testKZGWithBlob(t *testing.T, ckzg bool) {
t.Helper()
if ckzg && !ckzgAvailable {
t.Skip("CKZG unavailable in this test build")
}
Expand All @@ -97,6 +99,7 @@ func testKZGWithBlob(t *testing.T, ckzg bool) {
func BenchmarkCKZGBlobToCommitment(b *testing.B) { benchmarkBlobToCommitment(b, true) }
func BenchmarkGoKZGBlobToCommitment(b *testing.B) { benchmarkBlobToCommitment(b, false) }
func benchmarkBlobToCommitment(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build")
}
Expand All @@ -114,6 +117,7 @@ func benchmarkBlobToCommitment(b *testing.B, ckzg bool) {
func BenchmarkCKZGComputeProof(b *testing.B) { benchmarkComputeProof(b, true) }
func BenchmarkGoKZGComputeProof(b *testing.B) { benchmarkComputeProof(b, false) }
func benchmarkComputeProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build")
}
Expand All @@ -134,6 +138,7 @@ func benchmarkComputeProof(b *testing.B, ckzg bool) {
func BenchmarkCKZGVerifyProof(b *testing.B) { benchmarkVerifyProof(b, true) }
func BenchmarkGoKZGVerifyProof(b *testing.B) { benchmarkVerifyProof(b, false) }
func benchmarkVerifyProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build")
}
Expand All @@ -156,6 +161,7 @@ func benchmarkVerifyProof(b *testing.B, ckzg bool) {
func BenchmarkCKZGComputeBlobProof(b *testing.B) { benchmarkComputeBlobProof(b, true) }
func BenchmarkGoKZGComputeBlobProof(b *testing.B) { benchmarkComputeBlobProof(b, false) }
func benchmarkComputeBlobProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build")
}
Expand All @@ -176,6 +182,7 @@ func benchmarkComputeBlobProof(b *testing.B, ckzg bool) {
func BenchmarkCKZGVerifyBlobProof(b *testing.B) { benchmarkVerifyBlobProof(b, true) }
func BenchmarkGoKZGVerifyBlobProof(b *testing.B) { benchmarkVerifyBlobProof(b, false) }
func benchmarkVerifyBlobProof(b *testing.B, ckzg bool) {
b.Helper()
if ckzg && !ckzgAvailable {
b.Skip("CKZG unavailable in this test build")
}
Expand Down
4 changes: 4 additions & 0 deletions ethclient/gethclient/gethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
)

func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
t.Helper()
// Generate test chain.
genesis, blocks := generateTestChain()
// Create node
Expand Down Expand Up @@ -168,6 +169,7 @@ func TestGethClient(t *testing.T) {
}

func testAccessList(t *testing.T, client *rpc.Client) {
t.Helper()
ec := New(client)
// Test transfer
msg := ethereum.CallMsg{
Expand Down Expand Up @@ -271,6 +273,7 @@ func testGetProof(t *testing.T, client *rpc.Client) {
}

func testGetProofCanonicalizeKeys(t *testing.T, client *rpc.Client) {
t.Helper()
ec := New(client)

// Tests with non-canon input for storage keys.
Expand Down Expand Up @@ -533,6 +536,7 @@ func TestBlockOverridesMarshal(t *testing.T) {
}

func testCallContractWithBlockOverrides(t *testing.T, client *rpc.Client) {
t.Helper()
ec := New(client)
msg := ethereum.CallMsg{
From: testAddr,
Expand Down
2 changes: 2 additions & 0 deletions graphql/graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ func TestWithdrawals(t *testing.T) {
}

func createNode(t *testing.T) *node.Node {
t.Helper()
stack, err := node.New(&node.Config{
HTTPHost: "127.0.0.1",
HTTPPort: 0,
Expand All @@ -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) {
t.Helper()
ethConf := &ethconfig.Config{
Genesis: gspec,
NetworkId: 1337,
Expand Down
1 change: 1 addition & 0 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
t.Helper()
var (
engine = ethash.NewFaker()
cacheConfig = &core.CacheConfig{
Expand Down
2 changes: 1 addition & 1 deletion les/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// all version state data. Otherwise only recent state is available.
stateRecent := uint64(core.DefaultCacheConfig.TriesInMemory - blockSafetyMargin)
stateRecent := core.DefaultCacheConfig.TriesInMemory - blockSafetyMargin
if server.archiveMode {
stateRecent = 0
}
Expand Down
1 change: 1 addition & 0 deletions metrics/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func BenchmarkRegistryGetOrRegisterParallel_32(b *testing.B) {
}

func benchmarkRegistryGetOrRegisterParallel(b *testing.B, amount int) {
b.Helper()
r := NewRegistry()
b.ResetTimer()
var wg sync.WaitGroup
Expand Down
1 change: 1 addition & 0 deletions miner/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ func TestEmptyWorkClique(t *testing.T) {
}

func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consensus.Engine) {
t.Helper()
defer engine.Close()

w, _ := newTestWorker(t, chainConfig, engine, rawdb.NewMemoryDatabase(), 0)
Expand Down
10 changes: 5 additions & 5 deletions p2p/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ func (cap Cap) String() string {
}

// Cmp defines the canonical sorting order of capabilities.
func (cap Cap) Cmp(other Cap) int {
if cap.Name == other.Name {
if cap.Version < other.Version {
func (capacity Cap) Cmp(other Cap) int {
if capacity.Name == other.Name {
if capacity.Version < other.Version {
return -1
}
if cap.Version > other.Version {
if capacity.Version > other.Version {
return 1
}
return 0
}
return strings.Compare(cap.Name, other.Name)
return strings.Compare(capacity.Name, other.Name)
}
3 changes: 3 additions & 0 deletions trie/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func TestNodeIteratorCoverage(t *testing.T) {
}

func testNodeIteratorCoverage(t *testing.T, scheme string) {
t.Helper()
// Create some arbitrary test trie to iterate
db, nodeDb, trie, _ := makeTestTrie(scheme)

Expand Down Expand Up @@ -492,6 +493,7 @@ func TestIteratorContinueAfterSeekError(t *testing.T) {
}

func testIteratorContinueAfterSeekError(t *testing.T, memonly bool, scheme string) {
t.Helper()
// Commit test trie to db, then remove the node containing "bars".
var (
barNodePath []byte
Expand Down Expand Up @@ -660,6 +662,7 @@ func TestNodeIteratorLargeTrie(t *testing.T) {
}

func testIteratorNodeBlob(t *testing.T, scheme string) {
t.Helper()
var (
db = rawdb.NewMemoryDatabase()
triedb = newTestDatabase(db, scheme)
Expand Down
10 changes: 10 additions & 0 deletions trie/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func makeTestTrie(scheme string) (ethdb.Database, *Database, *StateTrie, map[str
// checkTrieContents cross references a reconstructed trie with an expected data
// content map.
func checkTrieContents(t *testing.T, db ethdb.Database, scheme string, root []byte, content map[string][]byte) {
t.Helper()
// Check root availability and trie contents
ndb := newTestDatabase(db, scheme)
trie, err := NewStateTrie(TrieID(common.BytesToHash(root)), ndb)
Expand Down Expand Up @@ -144,6 +145,7 @@ func TestIterativeSync(t *testing.T) {
}

func testIterativeSync(t *testing.T, count int, bypath bool, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme)

Expand Down Expand Up @@ -229,6 +231,7 @@ func TestIterativeDelayedSync(t *testing.T) {
}

func testIterativeDelayedSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme)

Expand Down Expand Up @@ -305,6 +308,7 @@ func TestIterativeRandomSyncIndividual(t *testing.T) {
}

func testIterativeRandomSync(t *testing.T, count int, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme)

Expand Down Expand Up @@ -378,6 +382,7 @@ func TestIterativeRandomDelayedSync(t *testing.T) {
}

func testIterativeRandomDelayedSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme)

Expand Down Expand Up @@ -458,6 +463,7 @@ func TestDuplicateAvoidanceSync(t *testing.T) {
}

func testDuplicateAvoidanceSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme)

Expand Down Expand Up @@ -538,6 +544,7 @@ func TestIncompleteSyncHash(t *testing.T) {
}

func testIncompleteSync(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, _ := makeTestTrie(scheme)

Expand Down Expand Up @@ -634,6 +641,7 @@ func TestSyncOrdering(t *testing.T) {
}

func testSyncOrdering(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme)

Expand Down Expand Up @@ -720,6 +728,7 @@ func testSyncOrdering(t *testing.T, scheme string) {
}

func syncWith(t *testing.T, root common.Hash, db ethdb.Database, srcDb *Database) {
t.Helper()
// Create a destination trie and sync with the scheduler
sched := NewSync(root, db, nil, srcDb.Scheme())

Expand Down Expand Up @@ -779,6 +788,7 @@ func TestSyncMovingTarget(t *testing.T) {
}

func testSyncMovingTarget(t *testing.T, scheme string) {
t.Helper()
// Create a random trie to copy
_, srcDb, srcTrie, srcData := makeTestTrie(scheme)

Expand Down
1 change: 1 addition & 0 deletions trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestMissingNode(t *testing.T) {
}

func testMissingNode(t *testing.T, memonly bool, scheme string) {
t.Helper()
diskdb := rawdb.NewMemoryDatabase()
triedb := newTestDatabase(diskdb, scheme)

Expand Down
1 change: 1 addition & 0 deletions trie/triedb/pathdb/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type tester struct {
}

func newTester(t *testing.T) *tester {
t.Helper()
var (
disk, _ = rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), t.TempDir(), "", false)
db = New(disk, &Config{CleanSize: 256 * 1024, DirtySize: 256 * 1024})
Expand Down
Loading

0 comments on commit cc2c27d

Please sign in to comment.