@ -62,7 +62,8 @@ func makeTestState() (Database, common.Hash, []*testAccount) {
}
if i % 5 == 0 {
for j := byte ( 0 ) ; j < 5 ; j ++ {
obj . SetState ( db , crypto . Keccak256Hash ( [ ] byte { i , i , i , i , i , j , j } ) , crypto . Keccak256Hash ( [ ] byte { i , i , i , i , i , j , j } ) )
hash := crypto . Keccak256Hash ( [ ] byte { i , i , i , i , i , j , j } )
obj . SetState ( db , hash , hash )
}
}
state . updateStateObject ( obj )
@ -401,15 +402,14 @@ func TestIncompleteStateSync(t *testing.T) {
// Create a random state to copy
srcDb , srcRoot , srcAccounts := makeTestState ( )
// isCode reports whether the hash is contract code hash.
isCode := func ( hash common . Hash ) bool {
// isCodeLookup to save some hashing
var isCode = make ( map [ common . Hash ] struct { } )
for _ , acc := range srcAccounts {
if hash == crypto . Keccak256Hash ( acc . code ) {
return true
if len ( acc . code ) > 0 {
isCode [ crypto . Keccak256Hash ( acc . code ) ] = struct { } { }
}
}
return false
}
isCode [ common . BytesToHash ( emptyCodeHash ) ] = struct { } { }
checkTrieConsistency ( srcDb . TrieDB ( ) . DiskDB ( ) . ( ethdb . Database ) , srcRoot )
// Create a destination state and sync with the scheduler
@ -447,15 +447,13 @@ func TestIncompleteStateSync(t *testing.T) {
batch . Write ( )
for _ , result := range results {
added = append ( added , result . Hash )
}
// Check that all known sub-tries added so far are complete or missing entirely.
for _ , hash := range added {
if isCode ( hash ) {
if _ , ok := isCode [ result . Hash ] ; ok {
continue
}
// Can't use checkStateConsistency here because subtrie keys may have odd
// length and crash in LeafKey.
if err := checkTrieConsistency ( dstDb , h ash) ; err != nil {
if err := checkTrieConsistency ( dstDb , result . H ash) ; err != nil {
t . Fatalf ( "state inconsistent: %v" , err )
}
}
@ -467,7 +465,7 @@ func TestIncompleteStateSync(t *testing.T) {
for _ , node := range added [ 1 : ] {
var (
key = node . Bytes ( )
code = isCode ( node )
_ , code = isCode [ node ]
val [ ] byte
)
if code {