mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 04:46:00 +00:00
343cc4fa43
Also implements transactional block persistence. Two issues in the transaction processing code have been discovered that might affect other usages such as the CALL instruction. The main fix gets us past block 49000. You may need to clean up your database.
49 lines
902 B
Nim
49 lines
902 B
Nim
#[
|
|
import
|
|
unittest,
|
|
eth_trie/db,
|
|
../nimbus/db/backends/caching_backend
|
|
|
|
let
|
|
key1 = [0.byte, 0, 1]
|
|
key2 = [0.byte, 0, 2]
|
|
key3 = [0.byte, 0, 3]
|
|
key4 = [0.byte, 0, 4]
|
|
value1 = [1.byte, 0, 1]
|
|
value2 = [1.byte, 0, 2]
|
|
value3 = [1.byte, 0, 3]
|
|
value4 = [1.byte, 0, 4]
|
|
|
|
suite "Caching DB backend":
|
|
test "Basic test":
|
|
let mdb = newMemDB()
|
|
mdb.put(key1, value1)
|
|
mdb.put(key2, value2)
|
|
let cdb = newCachingDB(trieDB(mdb))
|
|
check:
|
|
cdb.get(key1) == @value1
|
|
cdb.get(key2) == @value2
|
|
|
|
cdb.del(key1)
|
|
check:
|
|
key1 notin cdb
|
|
mdb.get(key1) == @value1
|
|
|
|
cdb.put(key3, value3)
|
|
check:
|
|
cdb.get(key3) == @value3
|
|
key3 notin mdb
|
|
|
|
cdb.put(key4, value4)
|
|
cdb.del(key4)
|
|
check(key4 notin cdb)
|
|
|
|
cdb.commit()
|
|
|
|
check:
|
|
key1 notin mdb
|
|
mdb.get(key2) == @value2
|
|
mdb.get(key3) == @value3
|
|
key4 notin mdb
|
|
]#
|