Tests: Explain rules of "to" for call/create, use `ZERO_ADDRESS`
The conditions mentioned in the old TODO comment have been checked. All fixtures have either 40 hex digits or empty string for "to". There is a test with all-zeros, and it means send to that account, not contract creation. Empty string means contract creation. This patch does not change the relaxed parsing where fewer than 40 digits is accepted. We should probably be stricter about this. Signed-off-by: Jamie Lokier <jamie@shareable.org>
This commit is contained in:
parent
90a961243e
commit
78233a4edc
|
@ -9,7 +9,7 @@ import
|
||||||
os, macros, json, strformat, strutils, parseutils, os, tables,
|
os, macros, json, strformat, strutils, parseutils, os, tables,
|
||||||
stew/byteutils, net, eth/[common, keys, rlp, p2p], unittest2,
|
stew/byteutils, net, eth/[common, keys, rlp, p2p], unittest2,
|
||||||
testutils/markdown_reports,
|
testutils/markdown_reports,
|
||||||
../nimbus/[config, transaction, utils, errors],
|
../nimbus/[constants, config, transaction, utils, errors],
|
||||||
../nimbus/vm_types2,
|
../nimbus/vm_types2,
|
||||||
../nimbus/db/accounts_cache,
|
../nimbus/db/accounts_cache,
|
||||||
../nimbus/random_keys
|
../nimbus/random_keys
|
||||||
|
@ -221,11 +221,18 @@ proc getFixtureTransaction*(j: JsonNode, dataIndex, gasIndex, valueIndex: int):
|
||||||
var toAddr: EthAddress
|
var toAddr: EthAddress
|
||||||
var contract: bool
|
var contract: bool
|
||||||
|
|
||||||
# TODO: there are a couple fixtures which appear to distinguish between
|
# Fixture transactions with `"to": ""` are contract creations.
|
||||||
# empty and 0 transaction.to; check/verify whether correct conditions.
|
#
|
||||||
|
# Fixture transactions with `"to": "0x..."` or `"to": "..."` where `...` are
|
||||||
|
# 40 hex digits are call/transfer transactions. Even if the digits are all
|
||||||
|
# zeros, because the all-zeros address is a legitimate account.
|
||||||
|
#
|
||||||
|
# There are no other formats. The number of digits if present is always 40,
|
||||||
|
# "0x" prefix is used in some but not all fixtures, and upper case hex digits
|
||||||
|
# occur in a few.
|
||||||
let rawTo = j["to"].getStr
|
let rawTo = j["to"].getStr
|
||||||
if rawTo == "":
|
if rawTo == "":
|
||||||
toAddr = "0x".parseAddress
|
toAddr = ZERO_ADDRESS
|
||||||
contract = true
|
contract = true
|
||||||
else:
|
else:
|
||||||
toAddr = rawTo.parseAddress
|
toAddr = rawTo.parseAddress
|
||||||
|
|
Loading…
Reference in New Issue