fix test_generalstate_json -> add a call to accounts_cache.persist

This commit is contained in:
jangko 2020-06-01 11:49:56 +07:00
parent 9cce8d695b
commit 46e9c11d3f
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 10 additions and 6 deletions

View File

@ -96,7 +96,10 @@ proc testFixtureIndexes(tester: Tester, testStatusIMPL: var TestStatus) =
vmState.mutateStateDB: vmState.mutateStateDB:
setupStateDB(tester.pre, db) setupStateDB(tester.pre, db)
#vmState.accountDB.updateOriginalRoot() # this is an important step when using accounts_cache
# it will affect the account storage's location
# during the next call to `getComittedStorage`
db.persist()
defer: defer:
let obtainedHash = "0x" & `$`(vmState.readOnlyStateDB.rootHash).toLowerAscii let obtainedHash = "0x" & `$`(vmState.readOnlyStateDB.rootHash).toLowerAscii
@ -128,6 +131,12 @@ proc testFixtureIndexes(tester: Tester, testStatusIMPL: var TestStatus) =
if db.isEmptyAccount(miner): if db.isEmptyAccount(miner):
db.deleteAccount(miner) db.deleteAccount(miner)
# this is an important step when using accounts_cache
# it will affect the account storage's location
# during the next call to `getComittedStorage`
# and the result of rootHash
db.persist()
proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus, proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
trace = false, debugMode = false, supportedForks: set[Fork] = supportedForks) = trace = false, debugMode = false, supportedForks: set[Fork] = supportedForks) =
var tester: Tester var tester: Tester

View File

@ -149,11 +149,6 @@ proc setupStateDB*(wantedState: JsonNode, stateDB: var AccountsCache) =
stateDB.setCode(account, code) stateDB.setCode(account, code)
stateDB.setBalance(account, balance) stateDB.setBalance(account, balance)
# this is an important step when using accounts_cache
# it will affect the account storage's location
# during the next call to `getComittedStorage`
stateDB.persist()
proc verifyStateDB*(wantedState: JsonNode, stateDB: ReadOnlyStateDB) = proc verifyStateDB*(wantedState: JsonNode, stateDB: ReadOnlyStateDB) =
for ac, accountData in wantedState: for ac, accountData in wantedState:
let account = ethAddressFromHex(ac) let account = ethAddressFromHex(ac)