nimbus-eth1/tests/test_caching_db_backend.nim
Zahary Karadjov 343cc4fa43 Populate the persistent databases with the empty RLP key.
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.
2018-10-05 03:36:48 +03:00

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
]#