Skip to content

Commit 26a9ea5

Browse files
authored
core, rpc: speed up tests ethereum#28461 (#1008)
1 parent e1772ce commit 26a9ea5

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

core/state/statedb_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,23 +366,21 @@ func (test *snapshotTest) run() bool {
366366
state, _ = New(types.EmptyRootHash, NewDatabase(db))
367367
snapshotRevs = make([]int, len(test.snapshots))
368368
sindex = 0
369+
checkstates = make([]*StateDB, len(test.snapshots))
369370
)
370371
for i, action := range test.actions {
371372
if len(test.snapshots) > sindex && i == test.snapshots[sindex] {
372373
snapshotRevs[sindex] = state.Snapshot()
374+
checkstates[sindex] = state.Copy()
373375
sindex++
374376
}
375377
action.fn(action, state)
376378
}
377379
// Revert all snapshots in reverse order. Each revert must yield a state
378380
// that is equivalent to fresh state with all actions up the snapshot applied.
379381
for sindex--; sindex >= 0; sindex-- {
380-
checkstate, _ := New(types.EmptyRootHash, state.Database())
381-
for _, action := range test.actions[:test.snapshots[sindex]] {
382-
action.fn(action, checkstate)
383-
}
384382
state.RevertToSnapshot(snapshotRevs[sindex])
385-
if err := test.checkEqual(state, checkstate); err != nil {
383+
if err := test.checkEqual(state, checkstates[sindex]); err != nil {
386384
test.err = fmt.Errorf("state mismatch after revert to snapshot %d\n%v", sindex, err)
387385
return false
388386
}

rpc/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ func TestClientSubscriptionChannelClose(t *testing.T) {
595595

596596
for i := 0; i < 100; i++ {
597597
ch := make(chan int, 100)
598-
sub, err := client.Subscribe(context.Background(), "nftest", ch, "someSubscription", maxClientSubscriptionBuffer-1, 1)
598+
sub, err := client.Subscribe(context.Background(), "nftest", ch, "someSubscription", 100, 1)
599599
if err != nil {
600600
t.Fatal(err)
601601
}

0 commit comments

Comments
 (0)