Add opcode tests (#4)

This commit is contained in:
Mamy Ratsimbazafy 2018-04-06 16:25:01 +02:00 committed by GitHub
parent 078f7abf22
commit 284a026e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 24 deletions

View File

@ -8,7 +8,7 @@ license = "Apache License 2.0"
skipDirs = @["tests"]
requires "nim >= 0.18.1",
"https://github.com/status-im/nim-keccak-tiny.git >= 0.1.0",
"https://github.com/status-im/nim-keccak-tiny.git >= 0.2.0",
"https://github.com/alehander42/nim-rlp#fix-ordinal", #TODO switching to the Status repo throws: "Error: undeclared identifier: 'Range'"
"https://github.com/status-im/nim-ttmath#master"

View File

@ -1,5 +1,8 @@
import
../constants, ../types, ../errors, ../computation, ../vm_state, .. / db / [db_chain, state_db], .. / vm / [stack, gas_meter, message], strformat, ttmath, utils / header
../constants, ../types, ../errors, ../computation, ../vm_state,
../utils/header,
../db/[db_chain, state_db], ../vm/[stack, gas_meter, message],
strformat, ttmath
{.this: computation.}
{.experimental.}

View File

@ -1,5 +1,5 @@
import
../logging, ../constants, ../errors, ../transaction, ../types, ../computation, "../block", ../vm_state, ../vm_state_transactions, ../db/db_chain, ../utils/header
../logging, ../constants, ../errors, ../transaction, ../types, ../computation, ../block_obj, ../vm_state, ../vm_state_transactions, ../db/db_chain, ../utils/header
type
VM* = ref object of RootObj

View File

@ -1,5 +1,7 @@
import
logging, constants, errors, transaction, "block", utils/header
../../../logging, ../../../constants, ../../../errors, ../../../transaction,
../../../block_obj,
../../../utils/header
type
FrontierBlock* = object of Block

View File

@ -1,6 +1,6 @@
import
strformat,
constants, errors, ttmath, vm_state, transaction, utils/header
strformat, ttmath,
../../../constants, ../../../errors, ../../../vm_state, ../../../transaction, ../../../utils/header
proc validateFrontierTransaction*(vmState: BaseVmState, transaction: BaseTransaction) =
let gasCost = transaction.gas * transaction.gasPrice

View File

@ -1,5 +1,6 @@
import
logging, constants, errors, vm_state, utils/header, db/db_chain
../../../logging, ../../../constants, ../../../errors, ../../../vm_state,
../../../utils/header, ../../../db/db_chain
type
FrontierVMState* = ref object of BaseVMState

View File

@ -1,6 +1,9 @@
import
logging, constants, errors, ttmath, "block", vm / [base, stack], db / db_chain, utils / header,
frontier_block, frontier_vm_state, frontier_validation
../../../logging, ../../../constants, ../../../errors,
ttmath,
../../../block_obj,
../../../vm/[base, stack], ../../../db/db_chain, ../../../utils/header,
./frontier_block, ./frontier_vm_state, ./frontier_validation
type

View File

@ -1,6 +1,6 @@
import
strformat, tables,
logging, constants, errors, computation, transaction, types, vm_state, "block", db / db_chain, utils / [state, header]
logging, constants, errors, computation, transaction, types, vm_state, block_obj, db / db_chain, utils / [state, header]
method executeTransaction(vmState: var BaseVMState, transaction: BaseTransaction): (BaseComputation, Header) =
# Execute the transaction in the vm

View File

@ -1,5 +1,7 @@
import ./test_code_stream,
./test_gas_meter,
./test_memory,
./test_stack
./test_stack,
./test_opcode

View File

@ -1,5 +1,9 @@
import
os, macros, json, strformat, strutils, ttmath, utils / [hexadecimal, address, padding], chain, vm_state, constants, db / [db_chain, state_db], vm / forks / frontier / vm, parseutils, ospaths, tables
os, macros, json, strformat, strutils, parseutils, ospaths, tables,
ttmath,
../src/utils/[hexadecimal, address, padding],
../src/[chain, vm_state, constants],
../src/db/[db_chain, state_db], ../src/vm/forks/frontier/vm
type
Status* {.pure.} = enum OK, Fail, Skip

View File

@ -1,7 +1,13 @@
import
unittest, test_helpers,
constants, types, errors, logging, ttmath,
tables, parseutils, chain, vm_state, computation, opcode, opcode_table, utils / [header, padding], vm / [gas_meter, message, code_stream, stack], vm / forks / frontier / vm, db / [db_chain, state_db], db / backends / memory_backend
unittest, ttmath, tables, parseutils,
../src/[constants, types, errors, logging],
../src/[chain, vm_state, computation, opcode, opcode_table],
../src/[utils/header, utils/padding],
../src/vm/[gas_meter, message, code_stream, stack],
../src/vm/forks/frontier/vm,
../src/db/[db_chain, state_db, backends/memory_backend],
test_helpers
proc testCode(code: string, gas: UInt256): BaseComputation =
var vm = newFrontierVM(Header(), newBaseChainDB(newMemoryDB()))