@@ -25,6 +25,7 @@ import (
25
25
"math"
26
26
"math/rand"
27
27
"reflect"
28
+ "slices"
28
29
"strings"
29
30
"sync"
30
31
"testing"
@@ -615,7 +616,7 @@ func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
615
616
checkeq ("GetCode" , state .GetCode (addr ), checkstate .GetCode (addr ))
616
617
checkeq ("GetCodeHash" , state .GetCodeHash (addr ), checkstate .GetCodeHash (addr ))
617
618
checkeq ("GetCodeSize" , state .GetCodeSize (addr ), checkstate .GetCodeSize (addr ))
618
- // Check created -flag
619
+ // Check newContract -flag
619
620
if obj := state .getStateObject (addr ); obj != nil {
620
621
checkeq ("IsNewContract" , obj .newContract , checkstate .getStateObject (addr ).newContract )
621
622
}
@@ -659,6 +660,23 @@ func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
659
660
return fmt .Errorf ("got GetLogs(common.Hash{}) == %v, want GetLogs(common.Hash{}) == %v" ,
660
661
state .GetLogs (common.Hash {}, 0 , common.Hash {}), checkstate .GetLogs (common.Hash {}, 0 , common.Hash {}))
661
662
}
663
+ if ! maps .Equal (state .journal .dirties , checkstate .journal .dirties ) {
664
+ getKeys := func (dirty map [common.Address ]int ) string {
665
+ var keys []common.Address
666
+ out := new (strings.Builder )
667
+ for key := range dirty {
668
+ keys = append (keys , key )
669
+ }
670
+ slices .SortFunc (keys , common .Address .Cmp )
671
+ for i , key := range keys {
672
+ fmt .Fprintf (out , " %d. %v\n " , i , key )
673
+ }
674
+ return out .String ()
675
+ }
676
+ have := getKeys (state .journal .dirties )
677
+ want := getKeys (checkstate .journal .dirties )
678
+ return fmt .Errorf ("dirty-journal set mismatch.\n have:\n %v\n want:\n %v\n " , have , want )
679
+ }
662
680
return nil
663
681
}
664
682
0 commit comments