Skip to content

Commit 06d4470

Browse files
committed
core: fix broken tests due to API changes + linter
1 parent 1909942 commit 06d4470

18 files changed

Lines changed: 55 additions & 182 deletions

‎core/blockchain_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
144144
}
145145
return err
146146
}
147-
statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.stateCache)
147+
statedb, err := state.New(blockchain.GetBlockByHash(block.ParentHash()).Root(), blockchain.stateCache, nil)
148148
if err != nil {
149149
return err
150150
}

‎core/state/iterator_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestNodeIteratorCoverage(t *testing.T) {
2929
// Create some arbitrary test state to iterate
3030
db, root, _ := makeTestState()
3131

32-
state, err := New(root, db)
32+
state, err := New(root, db, nil)
3333
if err != nil {
3434
t.Fatalf("failed to create state trie at %x: %v", root, err)
3535
}

‎core/state/snapshot/difflayer.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ func (dl *diffLayer) StorageList(accountHash common.Hash) []common.Hash {
478478

479479
storageMap := dl.storageData[accountHash]
480480
storageList := make([]common.Hash, 0, len(storageMap))
481-
for k, _ := range storageMap {
481+
for k := range storageMap {
482482
storageList = append(storageList, k)
483483
}
484484
sort.Sort(hashes(storageList))

‎core/state/snapshot/difflayer_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func TestInsertAndMerge(t *testing.T) {
167167
merged := (child.flatten()).(*diffLayer)
168168
{ // Check that slot value is present
169169
got, _ := merged.Storage(acc, slot)
170-
if exp := []byte{0x01}; bytes.Compare(got, exp) != 0 {
170+
if exp := []byte{0x01}; !bytes.Equal(got, exp) {
171171
t.Errorf("merged slot value wrong, got %x, exp %x", got, exp)
172172
}
173173
}

‎core/state/snapshot/disklayer_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func TestDiskPartialMerge(t *testing.T) {
310310
t.Helper()
311311
blob, err := base.AccountRLP(account)
312312
if bytes.Compare(account[:], genMarker) > 0 && err != ErrNotCoveredYet {
313-
t.Fatalf("test %d: post-marker (%x) account access (%x) succeded: %x", i, genMarker, account, blob)
313+
t.Fatalf("test %d: post-marker (%x) account access (%x) succeeded: %x", i, genMarker, account, blob)
314314
}
315315
if bytes.Compare(account[:], genMarker) <= 0 && !bytes.Equal(blob, data) {
316316
t.Fatalf("test %d: pre-marker (%x) account access (%x) mismatch: have %x, want %x", i, genMarker, account, blob, data)
@@ -326,7 +326,7 @@ func TestDiskPartialMerge(t *testing.T) {
326326
t.Helper()
327327
blob, err := base.Storage(account, slot)
328328
if bytes.Compare(append(account[:], slot[:]...), genMarker) > 0 && err != ErrNotCoveredYet {
329-
t.Fatalf("test %d: post-marker (%x) storage access (%x:%x) succeded: %x", i, genMarker, account, slot, blob)
329+
t.Fatalf("test %d: post-marker (%x) storage access (%x:%x) succeeded: %x", i, genMarker, account, slot, blob)
330330
}
331331
if bytes.Compare(append(account[:], slot[:]...), genMarker) <= 0 && !bytes.Equal(blob, data) {
332332
t.Fatalf("test %d: pre-marker (%x) storage access (%x:%x) mismatch: have %x, want %x", i, genMarker, account, slot, blob, data)
@@ -386,7 +386,7 @@ func TestDiskPartialMerge(t *testing.T) {
386386
t.Helper()
387387
blob := rawdb.ReadAccountSnapshot(db, account)
388388
if bytes.Compare(account[:], genMarker) > 0 && blob != nil {
389-
t.Fatalf("test %d: post-marker (%x) account database access (%x) succeded: %x", i, genMarker, account, blob)
389+
t.Fatalf("test %d: post-marker (%x) account database access (%x) succeeded: %x", i, genMarker, account, blob)
390390
}
391391
if bytes.Compare(account[:], genMarker) <= 0 && !bytes.Equal(blob, data) {
392392
t.Fatalf("test %d: pre-marker (%x) account database access (%x) mismatch: have %x, want %x", i, genMarker, account, blob, data)
@@ -406,7 +406,7 @@ func TestDiskPartialMerge(t *testing.T) {
406406
t.Helper()
407407
blob := rawdb.ReadStorageSnapshot(db, account, slot)
408408
if bytes.Compare(append(account[:], slot[:]...), genMarker) > 0 && blob != nil {
409-
t.Fatalf("test %d: post-marker (%x) storage database access (%x:%x) succeded: %x", i, genMarker, account, slot, blob)
409+
t.Fatalf("test %d: post-marker (%x) storage database access (%x:%x) succeeded: %x", i, genMarker, account, slot, blob)
410410
}
411411
if bytes.Compare(append(account[:], slot[:]...), genMarker) <= 0 && !bytes.Equal(blob, data) {
412412
t.Fatalf("test %d: pre-marker (%x) storage database access (%x:%x) mismatch: have %x, want %x", i, genMarker, account, slot, blob, data)

‎core/state/snapshot/generate.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (gs *generatorStats) Log(msg string, marker []byte) {
9393
// and generation is continued in the background until done.
9494
func generateSnapshot(diskdb ethdb.KeyValueStore, triedb *trie.Database, cache int, root common.Hash, wiper chan struct{}) *diskLayer {
9595
// Wipe any previously existing snapshot from the database if no wiper is
96-
// currenty in progress.
96+
// currently in progress.
9797
if wiper == nil {
9898
wiper = wipeSnapshot(diskdb, true)
9999
}

‎core/state/snapshot/iteration.md‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎core/state/snapshot/iterator_binary.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type binaryAccountIterator struct {
3535
}
3636

3737
// newBinaryAccountIterator creates a simplistic account iterator to step over
38-
// all the accounts in a slow, but eaily verifyable way.
38+
// all the accounts in a slow, but eaily verifiable way.
3939
func (dl *diffLayer) newBinaryAccountIterator() AccountIterator {
4040
parent, ok := dl.parent.(*diffLayer)
4141
if !ok {

‎core/state/snapshot/iterator_fast.go‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (its weightedAccountIterators) Len() int { return len(its) }
4141
// Less implements sort.Interface, returning which of two iterators in the stack
4242
// is before the other.
4343
func (its weightedAccountIterators) Less(i, j int) bool {
44-
// Order the iterators primarilly by the account hashes
44+
// Order the iterators primarily by the account hashes
4545
hashI := its[i].it.Hash()
4646
hashJ := its[j].it.Hash()
4747

@@ -131,7 +131,7 @@ func (fi *fastAccountIterator) init() {
131131
// determine which.
132132
//
133133
// This whole else-block can be avoided, if we instead
134-
// do an inital priority-sort of the iterators. If we do that,
134+
// do an initial priority-sort of the iterators. If we do that,
135135
// then we'll only wind up here if a lower-priority (preferred) iterator
136136
// has the same value, and then we will always just continue.
137137
// However, it costs an extra sort, so it's probably not better
@@ -233,16 +233,8 @@ func (fi *fastAccountIterator) next(idx int) bool {
233233
// The elem we're placing it next to has the same value,
234234
// so whichever winds up on n+1 will need further iteraton
235235
clash = n + 1
236-
if cur.priority < fi.iterators[n+1].priority {
237-
// We can drop the iterator here
238-
return true
239-
}
240-
// We need to move it one step further
241-
return false
242-
// TODO benchmark which is best, this works too:
243-
//clash = n
244-
//return true
245-
// Doing so should finish the current search earlier
236+
237+
return cur.priority < fi.iterators[n+1].priority
246238
})
247239
fi.move(idx, index)
248240
if clash != -1 {

‎core/state/snapshot/iterator_test.go‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,19 @@ func (ti *testIterator) Seek(common.Hash) {
6767

6868
func (ti *testIterator) Next() bool {
6969
ti.values = ti.values[1:]
70-
if len(ti.values) == 0 {
71-
return false
72-
}
73-
return true
70+
return len(ti.values) > 0
7471
}
7572

7673
func (ti *testIterator) Error() error {
77-
panic("implement me")
74+
return nil
7875
}
7976

8077
func (ti *testIterator) Hash() common.Hash {
8178
return common.BytesToHash([]byte{ti.values[0]})
8279
}
8380

8481
func (ti *testIterator) Account() []byte {
85-
panic("implement me")
82+
return nil
8683
}
8784

8885
func (ti *testIterator) Release() {}

0 commit comments

Comments
 (0)