make test green

This commit is contained in:
andri lim 2019-04-18 16:10:31 +07:00
parent f3c740498c
commit 1383a87e10
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 5 additions and 2 deletions

View File

@ -193,6 +193,7 @@ proc initComputation(vmState: BaseVMState, tx: Transaction, sender: EthAddress,
let contractAddress = generateAddress(sender, tx.accountNonce)
let msg = newMessage(tx.gasLimit - gasUsed, tx.gasPrice, tx.to, sender, tx.value, data, tx.payload,
contractCreation = false,
options = newMessageOptions(origin = sender, createAddress = contractAddress))
newBaseComputation(vmState, vmState.blockNumber, msg, some(fork))

View File

@ -32,6 +32,7 @@ proc testCode(code: string, initialGas: GasInt, blockNum: UInt256): BaseComputat
value=0.u256,
data = @[],
code=code.hexToSeqByte,
contractCreation = true,
gas=initial_gas,
gasPrice=1) # What is this used for?
# gasPrice=fixture{"exec"}{"gasPrice"}.getHexadecimalInt.u256,

View File

@ -28,7 +28,7 @@ template doTest(fixture: JsonNode, address: byte, action: untyped): untyped =
gasPrice = 1.GasInt
sender: EthAddress
to = initAddress(address)
message = newMessage(gas, gasPrice, to, sender, 0.u256, data, @[])
message = newMessage(gas, gasPrice, to, sender, 0.u256, data, @[], contractCreation = false)
computation = newBaseComputation(vmState, header.blockNumber, message)
echo "Running ", action.astToStr, " - ", test["name"]
`action`(computation)

View File

@ -50,6 +50,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
value = cast[uint64](fexec{"value"}.getHexadecimalInt).u256, # Cast workaround for negative value
data = fexec{"data"}.getStr.hexToSeqByte,
code = code,
contractCreation = toAddress == ZERO_ADDRESS, # assume ZERO_ADDRESS is a contract creation
gas = fexec{"gas"}.getHexadecimalInt,
gasPrice = fexec{"gasPrice"}.getHexadecimalInt,
options = newMessageOptions(origin=fexec{"origin"}.getStr.parseAddress,
@ -57,7 +58,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
var computation = newBaseComputation(vmState, header.blockNumber, message)
computation.executeOpcodes()
if not fixture{"post"}.isNil:
# Success checks
check(not computation.isError)