Merge branch 'unittest2-serialised'

This commit is contained in:
Ștefan Talpalaru 2019-11-01 17:56:50 +01:00
commit 66020ea752
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
27 changed files with 158 additions and 122 deletions

6
.gitmodules vendored
View File

@ -111,6 +111,12 @@
[submodule "vendor/news"] [submodule "vendor/news"]
path = vendor/news path = vendor/news
url = https://github.com/tormund/news url = https://github.com/tormund/news
ignore = dirty
branch = master
[submodule "vendor/nim-unittest2"]
path = vendor/nim-unittest2
url = https://github.com/stefantalpalaru/nim-unittest2.git
ignore = dirty
branch = master branch = master
[submodule "vendor/nim-metrics"] [submodule "vendor/nim-metrics"]
path = vendor/nim-metrics path = vendor/nim-metrics

View File

@ -11,6 +11,10 @@
--passL:"-Wl,--stack,8388608" --passL:"-Wl,--stack,8388608"
# https://github.com/nim-lang/Nim/issues/4057 # https://github.com/nim-lang/Nim/issues/4057
--tlsEmulation:off --tlsEmulation:off
@if i386:
# set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag so we can use PAE, if enabled, and access more than 2 GiB of RAM
--passL:"-Wl,--large-address-aware"
@end
@end @end
--threads:on --threads:on

View File

@ -5,7 +5,11 @@
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) # * 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. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import macros, strutils, os, unittest, osproc import macros, strutils, os, unittest2, osproc
import threadpool
# AppVeyor may go out of memory with the default of 4
setMinPoolSize(2)
proc executeMyself(numModules: int): int = proc executeMyself(numModules: int): int =
let appName = getAppFilename() let appName = getAppFilename()

View File

@ -1,5 +1,5 @@
import import
macrocache, strutils, unittest, macrocache, strutils, unittest2,
stew/byteutils, chronicles, stew/ranges, eth/common, stew/byteutils, chronicles, stew/ranges, eth/common,
../nimbus/vm/interpreter/opcode_values, ../nimbus/vm/interpreter/opcode_values,
stew/shims/macros stew/shims/macros
@ -185,7 +185,8 @@ proc generateVMProxy(boa: Assembler): NimNode =
proc `vmProxy`(): bool = proc `vmProxy`(): bool =
let boa = `body` let boa = `body`
runVM(`blockNumber`, `chainDB`, boa) runVM(`blockNumber`, `chainDB`, boa)
check `vmProxy`() {.gcsafe.}:
check `vmProxy`()
when defined(macro_assembler_debug): when defined(macro_assembler_debug):
echo result.toStrLit.strVal echo result.toStrLit.strVal

View File

@ -1,3 +1,5 @@
-d:chronicles_line_numbers -d:chronicles_line_numbers
-d:"chronicles_sinks=textblocks" -d:"chronicles_sinks=textblocks"
# comment this out, to run the tests in a serial manner:
#-d:nimtestParallel

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, json, os, tables, strutils, sets, strformat, times, unittest2, json, os, tables, strutils, sets, strformat, times,
options, options,
eth/[common, rlp, bloom], eth/trie/[db, trie_defs], eth/[common, rlp, bloom], eth/trie/[db, trie_defs],
ethash, stew/endians2, nimcrypto, ethash, stew/endians2, nimcrypto,

View File

@ -5,7 +5,7 @@
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) # * 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. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import unittest, strutils, sequtils, import unittest2, strutils, sequtils,
../nimbus/vm/interpreter ../nimbus/vm/interpreter
proc codeStreamMain*() = proc codeStreamMain*() =
@ -15,11 +15,11 @@ proc codeStreamMain*() =
check(codeStream.len == 1) check(codeStream.len == 1)
# quicktest # quicktest
# @pytest.mark.parametrize("code_bytes", (1010, '1010', True, bytearray(32))) # @pytest.mark.parametrize("code_bytes", (1010, '1010', True, bytearray(32)))
# def test_codeStream_rejects_invalid_code_byte_values(code_bytes): # def test_codeStream_rejects_invalid_code_byte_values(code_bytes):
# with pytest.raises(ValidationError): # with pytest.raises(ValidationError):
# CodeStream(code_bytes) # CodeStream(code_bytes)
test "next returns the correct opcode": test "next returns the correct opcode":
var codeStream = newCodeStream("\x01\x02\x30") var codeStream = newCodeStream("\x01\x02\x30")

View File

@ -1,4 +1,4 @@
import unittest, strutils, tables, ospaths, json, import unittest2, strutils, tables, ospaths, json,
../nimbus/utils/difficulty, stint, times, ../nimbus/utils/difficulty, stint, times,
eth/common, test_helpers, stew/byteutils eth/common, test_helpers, stew/byteutils
@ -41,16 +41,16 @@ proc parseTests(name: string, hex: static[bool]): Tests =
result[title] = t result[title] = t
template runTests(name: string, hex: bool, calculator: typed) = template runTests(name: string, hex: bool, calculator: typed) =
let data = parseTests(name, hex) test name:
for title, t in data: let data = parseTests(name, hex)
var p = BlockHeader( for title, t in data:
difficulty: t.parentDifficulty, var p = BlockHeader(
timestamp: times.fromUnix(t.parentTimestamp), difficulty: t.parentDifficulty,
blockNumber: t.currentBlockNumber - 1, timestamp: times.fromUnix(t.parentTimestamp),
ommersHash: t.parentUncles) blockNumber: t.currentBlockNumber - 1,
ommersHash: t.parentUncles)
let diff = calculator(times.fromUnix(t.currentTimeStamp), p) let diff = calculator(times.fromUnix(t.currentTimeStamp), p)
test name & " " & title:
check diff == t.currentDifficulty check diff == t.currentDifficulty
proc difficultyMain*() = proc difficultyMain*() =

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, macros, strformat, unittest2, macros, strformat,
eth/common/eth_types, eth/common/eth_types,
../nimbus/[vm_types, errors, vm/interpreter] ../nimbus/[vm_types, errors, vm/interpreter]

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, strformat, strutils, tables, json, ospaths, times, os, unittest2, strformat, strutils, tables, json, ospaths, times, os,
stew/byteutils, stew/ranges/typedranges, nimcrypto, options, stew/byteutils, stew/ranges/typedranges, nimcrypto, options,
eth/[rlp, common], eth/trie/[db, trie_defs], chronicles, eth/[rlp, common], eth/trie/[db, trie_defs], chronicles,
./test_helpers, ../nimbus/p2p/executor, test_config, ./test_helpers, ../nimbus/p2p/executor, test_config,

View File

@ -1,4 +1,4 @@
import unittest, ../nimbus/[genesis, config], eth/common, nimcrypto/hash import unittest2, ../nimbus/[genesis, config], eth/common, nimcrypto/hash
proc genesisMain*() = proc genesisMain*() =
suite "Genesis": suite "Genesis":

View File

@ -7,7 +7,7 @@
import import
os, macros, json, strformat, strutils, parseutils, ospaths, tables, os, macros, json, strformat, strutils, parseutils, ospaths, tables,
stew/byteutils, stew/ranges/typedranges, net, eth/[common, keys, rlp, p2p], stew/byteutils, stew/ranges/typedranges, net, eth/[common, keys, rlp, p2p], unittest2,
../nimbus/[vm_state, constants, config, transaction, utils, errors], ../nimbus/[vm_state, constants, config, transaction, utils, errors],
../nimbus/db/[db_chain, state_db], ../nimbus/db/[db_chain, state_db],
../nimbus/vm/interpreter/[gas_costs, vm_forks], ../nimbus/vm/interpreter/[gas_costs, vm_forks],
@ -143,8 +143,7 @@ func validTest*(folder: string, name: string): bool =
not allowedFailInCurrentBuild(folder, name) not allowedFailInCurrentBuild(folder, name)
proc lacksSupportedForks*(fixtures: JsonNode): bool = proc lacksSupportedForks*(fixtures: JsonNode): bool =
# XXX: Until Nimbus supports Byzantine or newer forks, as opposed # XXX: Until Nimbus supports all forks, some of the GeneralStateTests won't work.
# to Homestead, ~1k of ~2.5k GeneralStateTests won't work.
var fixture: JsonNode var fixture: JsonNode
for label, child in fixtures: for label, child in fixtures:
@ -161,9 +160,12 @@ proc lacksSupportedForks*(fixtures: JsonNode): bool =
result = false result = false
break break
var status = initOrderedTable[string, OrderedTable[string, Status]]()
macro jsonTest*(s: static[string], handler: untyped): untyped = macro jsonTest*(s: static[string], handler: untyped): untyped =
let let
testStatusIMPL = ident("testStatusIMPL") testStatusIMPL = ident("testStatusIMPL")
testName = ident("testName")
# workaround for strformat in quote do: https://github.com/nim-lang/Nim/issues/8220 # workaround for strformat in quote do: https://github.com/nim-lang/Nim/issues/8220
symbol = newIdentNode"symbol" symbol = newIdentNode"symbol"
final = newIdentNode"final" final = newIdentNode"final"
@ -171,8 +173,7 @@ macro jsonTest*(s: static[string], handler: untyped): untyped =
formatted = newStrLitNode"{symbol[final]} {name:<64}{$final}{'\n'}" formatted = newStrLitNode"{symbol[final]} {name:<64}{$final}{'\n'}"
result = quote: result = quote:
var filenames: seq[(string, string, string)] = @[] var filenames: seq[string] = @[]
var status = initOrderedTable[string, OrderedTable[string, Status]]()
for filename in walkDirRec("tests" / "fixtures" / `s`): for filename in walkDirRec("tests" / "fixtures" / `s`):
if not filename.endsWith(".json"): if not filename.endsWith(".json"):
continue continue
@ -182,57 +183,65 @@ macro jsonTest*(s: static[string], handler: untyped): untyped =
status[last] = initOrderedTable[string, Status]() status[last] = initOrderedTable[string, Status]()
status[last][name] = Status.Skip status[last][name] = Status.Skip
if last.validTest(name): if last.validTest(name):
filenames.add((filename, last, name)) filenames.add(filename)
for child in filenames: for fname in filenames:
let (filename, folder, name) = child test fname:
# we set this here because exceptions might be raised in the handler: {.gcsafe.}:
status[folder][name] = Status.Fail let
let fixtures = parseJSON(readFile(filename)) filename = `testName` # the first argument passed to the `test` template
if fixtures.lacksSupportedForks: (folder, name) = filename.splitPath()
status[folder][name] = Status.Skip last = folder.splitPath().tail
continue # we set this here because exceptions might be raised in the handler:
test filename: status[last][name] = Status.Fail
echo folder / name let fixtures = parseJSON(readFile(filename))
`handler`(fixtures, `testStatusIMPL`) if fixtures.lacksSupportedForks:
if `testStatusIMPL` == OK: status[last][name] = Status.Skip
status[folder][name] = Status.OK skip()
else:
when not paralleliseTests:
echo filename
`handler`(fixtures, `testStatusIMPL`)
if `testStatusIMPL` == OK:
status[last][name] = Status.OK
status.sort do (a: (string, OrderedTable[string, Status]), suiteTeardown:
b: (string, OrderedTable[string, Status])) -> int: cmp(a[0], b[0]) status.sort do (a: (string, OrderedTable[string, Status]),
b: (string, OrderedTable[string, Status])) -> int: cmp(a[0], b[0])
let `symbol`: array[Status, string] = ["+", "-", " "] let `symbol`: array[Status, string] = ["+", "-", " "]
var raw = "" var raw = ""
var okCountTotal = 0 var okCountTotal = 0
var failCountTotal = 0 var failCountTotal = 0
var skipCountTotal = 0 var skipCountTotal = 0
raw.add(`s` & "\n") raw.add(`s` & "\n")
raw.add("===\n") raw.add("===\n")
for folder, statuses in status: for folder, statuses in status:
raw.add("## " & folder & "\n") raw.add("## " & folder & "\n")
raw.add("```diff\n") raw.add("```diff\n")
var sortedStatuses = statuses var sortedStatuses = statuses
sortedStatuses.sort do (a: (string, Status), b: (string, Status)) -> int: sortedStatuses.sort do (a: (string, Status), b: (string, Status)) -> int:
cmp(a[0], b[0]) cmp(a[0], b[0])
var okCount = 0 var okCount = 0
var failCount = 0 var failCount = 0
var skipCount = 0 var skipCount = 0
for `name`, `final` in sortedStatuses: for `name`, `final` in sortedStatuses:
raw.add(&`formatted`) raw.add(&`formatted`)
case `final`: case `final`:
of Status.OK: okCount += 1 of Status.OK: okCount += 1
of Status.Fail: failCount += 1 of Status.Fail: failCount += 1
of Status.Skip: skipCount += 1 of Status.Skip: skipCount += 1
raw.add("```\n") raw.add("```\n")
let sum = okCount + failCount + skipCount let sum = okCount + failCount + skipCount
okCountTotal += okCount okCountTotal += okCount
failCountTotal += failCount failCountTotal += failCount
skipCountTotal += skipCount skipCountTotal += skipCount
raw.add("OK: " & $okCount & "/" & $sum & " Fail: " & $failCount & "/" & $sum & " Skip: " & $skipCount & "/" & $sum & "\n") raw.add("OK: " & $okCount & "/" & $sum & " Fail: " & $failCount & "/" & $sum & " Skip: " & $skipCount & "/" & $sum & "\n")
let sumTotal = okCountTotal + failCountTotal + skipCountTotal let sumTotal = okCountTotal + failCountTotal + skipCountTotal
raw.add("\n---TOTAL---\n") raw.add("\n---TOTAL---\n")
raw.add("OK: $1/$4 Fail: $2/$4 Skip: $3/$4\n" % [$okCountTotal, $failCountTotal, $skipCountTotal, $sumTotal]) raw.add("OK: $1/$4 Fail: $2/$4 Skip: $3/$4\n" % [$okCountTotal, $failCountTotal, $skipCountTotal, $sumTotal])
writeFile(`s` & ".md", raw) writeFile(`s` & ".md", raw)
status.clear()
func ethAddressFromHex*(s: string): EthAddress = hexToByteArray(s, result) func ethAddressFromHex*(s: string): EthAddress = hexToByteArray(s, result)
@ -336,4 +345,4 @@ proc setupEthNode*(capabilities: varargs[ProtocolInfo, `protocolInfo`]): Ethereu
result = newEthereumNode(keypair, srvAddress, conf.net.networkId, result = newEthereumNode(keypair, srvAddress, conf.net.networkId,
nil, "nimbus 0.1.0", addAllCapabilities = false) nil, "nimbus 0.1.0", addAllCapabilities = false)
for capability in capabilities: for capability in capabilities:
result.addCapability capability result.addCapability capability

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, sequtils, unittest2, sequtils,
eth/common/eth_types, eth/common/eth_types,
../nimbus/[constants, errors, vm/memory] ../nimbus/[constants, errors, vm/memory]

View File

@ -1,8 +1,9 @@
import macro_assembler, unittest import macro_assembler, unittest2
proc opArithMain*() = proc opArithMain*() =
suite "Arithmetic Opcodes": suite "Arithmetic Opcodes":
let (blockNumber, chainDB) = initDatabase() setup:
let (blockNumber, chainDB) = initDatabase()
assembler: assembler:
title: "ADD_1" title: "ADD_1"

View File

@ -1,8 +1,9 @@
import macro_assembler, unittest import macro_assembler, unittest2
proc opBitMain*() = proc opBitMain*() =
suite "Bitwise Opcodes": suite "Bitwise Opcodes":
let (blockNumber, chainDB) = initDatabase() setup:
let (blockNumber, chainDB) = initDatabase()
assembler: # AND OP assembler: # AND OP
title: "AND_1" title: "AND_1"

View File

@ -1,11 +1,12 @@
import import
macro_assembler, unittest, macros, strutils, macro_assembler, unittest2, macros, strutils,
stew/byteutils, eth/common, ../nimbus/db/state_db, stew/byteutils, eth/common, ../nimbus/db/state_db,
../nimbus/db/db_chain, stew/ranges ../nimbus/db/db_chain, stew/ranges
proc opCustomMain*() = proc opCustomMain*() =
suite "Custom Opcodes Test": suite "Custom Opcodes Test":
let (blockNumber, chainDB) = initDatabase() setup:
let (blockNumber, chainDB) = initDatabase()
assembler: # CALLDATASIZE OP assembler: # CALLDATASIZE OP
title: "CALLDATASIZE_1" title: "CALLDATASIZE_1"

View File

@ -1,11 +1,12 @@
import import
macro_assembler, unittest, macros, strutils, macro_assembler, unittest2, macros, strutils,
stew/byteutils, eth/common, ../nimbus/db/state_db, stew/byteutils, eth/common, ../nimbus/db/state_db,
../nimbus/db/db_chain, stew/ranges ../nimbus/db/db_chain, stew/ranges
proc opEnvMain*() = proc opEnvMain*() =
suite "Environmental Information Opcodes": suite "Environmental Information Opcodes":
let (blockNumber, chainDB) = initDatabase() setup:
let (blockNumber, chainDB) = initDatabase()
assembler: # CODECOPY OP assembler: # CODECOPY OP
title: "CODECOPY_1" title: "CODECOPY_1"
@ -176,20 +177,23 @@ proc opEnvMain*() =
"0x5e" "0x5e"
"0x07" "0x07"
var acc: EthAddress suite "Environmental Information Opcodes 2":
hexToByteArray("0xfbe0afcd7658ba86be41922059dd879c192d4c73", acc) setup:
var let (blockNumber, chainDB) = initDatabase()
parent = chainDB.getBlockHeader(blockNumber - 1) var acc: EthAddress
stateDB = newAccountStateDB(chainDB.db, parent.stateRoot, false) hexToByteArray("0xfbe0afcd7658ba86be41922059dd879c192d4c73", acc)
code = hexToSeqByte("0x0102030405060708090A0B0C0D0E0F" & var
"611234600054615566602054603E6000602073471FD3AD3E9EEADEEC4608B92D" & parent = chainDB.getBlockHeader(blockNumber - 1)
"16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b" & stateDB = newAccountStateDB(chainDB.db, parent.stateRoot, false)
"51602001600a5254516040016014525451606001601e52545160800160285254" & code = hexToSeqByte("0x0102030405060708090A0B0C0D0E0F" &
"60a052546016604860003960166000f26000603f556103e756600054600053602002351234") "611234600054615566602054603E6000602073471FD3AD3E9EEADEEC4608B92D" &
"16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b" &
"51602001600a5254516040016014525451606001601e52545160800160285254" &
"60a052546016604860003960166000f26000603f556103e756600054600053602002351234")
stateDB.setCode(acc, code.toRange) stateDB.setCode(acc, code.toRange)
parent.stateRoot = stateDB.rootHash parent.stateRoot = stateDB.rootHash
chainDB.setHead(parent, true) chainDB.setHead(parent, true)
assembler: # EXTCODECOPY OP assembler: # EXTCODECOPY OP
title: "EXTCODECOPY_1" title: "EXTCODECOPY_1"

View File

@ -1,8 +1,9 @@
import macro_assembler, unittest, macros, strutils import macro_assembler, unittest2, macros, strutils
proc opMemoryMain*() = proc opMemoryMain*() =
suite "Memory Opcodes": suite "Memory Opcodes":
let (blockNumber, chainDB) = initDatabase() setup:
let (blockNumber, chainDB) = initDatabase()
assembler: # PUSH1 OP assembler: # PUSH1 OP
title: "PUSH1" title: "PUSH1"

View File

@ -1,11 +1,12 @@
import import
macro_assembler, unittest, macros, strutils, macro_assembler, unittest2, macros, strutils,
stew/byteutils, eth/common, ../nimbus/db/state_db, stew/byteutils, eth/common, ../nimbus/db/state_db,
../nimbus/db/db_chain, stew/ranges ../nimbus/db/db_chain, stew/ranges
proc opMiscMain*() = proc opMiscMain*() =
suite "Misc Opcodes": suite "Misc Opcodes":
let (blockNumber, chainDB) = initDatabase() setup:
let (blockNumber, chainDB) = initDatabase()
assembler: # LOG0 OP assembler: # LOG0 OP
title: "Log0" title: "Log0"

View File

@ -6,17 +6,11 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, json, os, tables, strformat, strutils, unittest2, json, os, tables, strformat, strutils,
eth/[common, rlp], stew/byteutils, eth/trie/db, eth/[common, rlp], stew/byteutils, eth/trie/db,
./test_helpers, ../nimbus/db/[db_chain, storage_types], ../nimbus/[tracer, vm_types], ./test_helpers, ../nimbus/db/[db_chain, storage_types], ../nimbus/[tracer, vm_types],
../nimbus/p2p/chain ../nimbus/p2p/chain
proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus)
proc persistBlockJsonMain*() =
suite "persist block json tests":
jsonTest("PersistBlockTests", testFixture)
# use tracerTestGen.nim to generate additional test data # use tracerTestGen.nim to generate additional test data
proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) = proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) =
var var
@ -43,3 +37,8 @@ proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus) =
chainDB.setHead(parent, true) chainDB.setHead(parent, true)
let validationResult = chain.persistBlocks(headers, bodies) let validationResult = chain.persistBlocks(headers, bodies)
check validationResult == ValidationResult.OK check validationResult == ValidationResult.OK
proc persistBlockJsonMain*() =
suite "persist block json tests":
jsonTest("PersistBlockTests", testFixture)

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, ../nimbus/vm/precompiles, json, stew/byteutils, test_helpers, ospaths, tables, unittest2, ../nimbus/vm/precompiles, json, stew/byteutils, test_helpers, ospaths, tables,
strformat, strutils, eth/trie/db, eth/common, ../nimbus/db/[db_chain, state_db], strformat, strutils, eth/trie/db, eth/common, ../nimbus/db/[db_chain, state_db],
../nimbus/[constants, vm_types, vm_state], ../nimbus/vm/[computation, message], macros ../nimbus/[constants, vm_types, vm_state], ../nimbus/vm/[computation, message], macros

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, unittest2,
eth/common/eth_types, eth/common/eth_types,
../nimbus/[constants, errors, vm/interpreter] ../nimbus/[constants, errors, vm/interpreter]

View File

@ -5,19 +5,20 @@
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) # * 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. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import unittest, strutils, eth/trie/[hexary, db], import unittest2, strutils, eth/trie/[hexary, db],
../nimbus/db/state_db, stew/byteutils, eth/common, ../nimbus/db/state_db, stew/byteutils, eth/common,
stew/ranges stew/ranges
proc stateDBMain*() = proc stateDBMain*() =
suite "Account State DB": suite "Account State DB":
var setup:
memDB = newMemoryDB() var
trie = initHexaryTrie(memDB) memDB = newMemoryDB()
stateDB = newAccountStateDB(memDB, trie.rootHash, true) trie = initHexaryTrie(memDB)
address: EthAddress stateDB = newAccountStateDB(memDB, trie.rootHash, true)
address: EthAddress
hexToByteArray("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", address) hexToByteArray("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", address)
test "accountExists and isDeadAccount": test "accountExists and isDeadAccount":
check stateDB.accountExists(address) == false check stateDB.accountExists(address) == false

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, json, os, tables, strformat, strutils, unittest2, json, os, tables, strformat, strutils,
eth/common, stew/byteutils, eth/trie/db, eth/common, stew/byteutils, eth/trie/db,
./test_helpers, ../nimbus/db/db_chain, ../nimbus/[tracer, vm_types] ./test_helpers, ../nimbus/db/db_chain, ../nimbus/[tracer, vm_types]

View File

@ -1,5 +1,5 @@
import import
unittest, json, os, tables, strformat, strutils, unittest2, json, os, tables, strformat, strutils,
eth/[common, rlp], eth/[common, rlp],
./test_helpers, ../nimbus/[transaction, utils, errors] ./test_helpers, ../nimbus/[transaction, utils, errors]

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
unittest, strformat, strutils, sequtils, tables, json, ospaths, times, unittest2, strformat, strutils, sequtils, tables, json, ospaths, times,
stew/byteutils, stew/ranges/typedranges, eth/[rlp, common], eth/trie/db, stew/byteutils, stew/ranges/typedranges, eth/[rlp, common], eth/trie/db,
./test_helpers, ../nimbus/vm/interpreter, ./test_helpers, ../nimbus/vm/interpreter,
../nimbus/[constants, errors, vm_state, vm_types, utils], ../nimbus/[constants, errors, vm_state, vm_types, utils],

1
vendor/nim-unittest2 vendored Submodule

@ -0,0 +1 @@
Subproject commit 30c7d332d8ebab28d3240018f48f145ff20af239