2023-11-01 03:32:09 +00:00
|
|
|
# Nimbus
|
2024-03-05 04:54:42 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-11-01 03:32:09 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
|
|
|
|
2022-04-06 05:28:19 +00:00
|
|
|
{.used.}
|
|
|
|
|
|
|
|
import
|
|
|
|
std/os,
|
|
|
|
unittest2,
|
|
|
|
eth/db/kvstore,
|
|
|
|
../../nimbus/db/kvstore_rocksdb,
|
|
|
|
eth/../tests/db/test_kvstore
|
|
|
|
|
2024-03-12 03:04:46 +00:00
|
|
|
suite "KvStore RocksDb Tests":
|
|
|
|
const
|
|
|
|
NS_DEFAULT = "default"
|
|
|
|
NS_OTHER = "other"
|
|
|
|
|
|
|
|
test "RocksStoreRef KvStore interface":
|
2022-04-06 05:28:19 +00:00
|
|
|
let tmp = getTempDir() / "nimbus-test-db"
|
|
|
|
removeDir(tmp)
|
|
|
|
|
|
|
|
let db = RocksStoreRef.init(tmp, "test")[]
|
|
|
|
defer:
|
|
|
|
db.close()
|
|
|
|
|
2023-01-27 14:57:48 +00:00
|
|
|
testKvStore(kvStore db, false, false)
|
2024-03-12 03:04:46 +00:00
|
|
|
|
|
|
|
test "RocksNamespaceRef KvStore interface - default namespace":
|
|
|
|
let tmp = getTempDir() / "nimbus-test-db"
|
|
|
|
removeDir(tmp)
|
|
|
|
|
|
|
|
let db = RocksStoreRef.init(tmp, "test")[]
|
|
|
|
defer:
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
let defaultNs = db.openNamespace(NS_DEFAULT)[]
|
|
|
|
testKvStore(kvStore defaultNs, false, false)
|
|
|
|
|
|
|
|
test "RocksNamespaceRef KvStore interface - multiple namespace":
|
|
|
|
let tmp = getTempDir() / "nimbus-test-db"
|
|
|
|
removeDir(tmp)
|
|
|
|
|
|
|
|
let db = RocksStoreRef.init(tmp, "test",
|
|
|
|
namespaces = @[NS_DEFAULT, NS_OTHER])[]
|
|
|
|
defer:
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
let defaultNs = db.openNamespace(NS_DEFAULT)[]
|
|
|
|
testKvStore(kvStore defaultNs, false, false)
|
|
|
|
|
|
|
|
let otherNs = db.openNamespace(NS_OTHER)[]
|
|
|
|
testKvStore(kvStore otherNs, false, false)
|