Update tests to use generator

This commit is contained in:
coffeepots 2018-12-06 21:27:25 +00:00
parent 56f7ba7c73
commit e93c299b63
1 changed files with 23 additions and 16 deletions

View File

@ -106,23 +106,30 @@ proc doTests =
echo `resultTitle`, `rpcResult`, " (type: ", `rpcResult`.type.name, ")"
`expectedResult`
suite "Remote Procedure Calls":
# TODO: Currently returning 'block not found' when fetching header in p2p, so cannot perform tests
test "eth_call":
let
blockNum = state.blockheader.blockNumber
callParams = EthCall(value: some(100.u256))
var r = waitFor client.eth_call(callParams, "0x" & blockNum.toHex)
echo r
test "eth_getBalance":
expect ValueError:
# check error is raised on null address
var r = waitFor client.eth_getBalance(ZERO_ADDRESS.toEthAddressStr, "0x0")
let currentBlockNumber = "0x" & state.blockheader.blockNumber.toHex
suite "Remote Procedure Calls":
makeTest(eth_blockNumber):
expected: 0
makeTest(eth_call):
params:
EthCall(value: some(100.u256))
currentBlockNumber
makeTest(eth_getBalance):
params:
ZERO_ADDRESS.toEthAddressStr
"0x0"
expected: balance
makeTest(eth_getStorageAt):
params:
address.toEthAddressStr
0
currentBlockNumber
let blockNum = state.blockheader.blockNumber
var r = waitFor client.eth_getBalance(address.toEthAddressStr, "0x" & blockNum.toHex)
echo r
rpcServer.stop()
rpcServer.close()