Transaction Tests ¶
The Transaction Test fixture format tests are included in the fixtures subdirectory transaction_tests
.
These are produced by the TransactionTest
test spec.
Description¶
The transaction test fixture format is used to test client's transaction RLP parsing without executing the transaction on the EVM.
It does so by defining a transaction binary RLP representation, and whether the transaction should be accepted or rejected by the client in each fork.
A single JSON fixture file is composed of a JSON object where each key-value pair is a different Fixture
test object, with the key string representing the test name.
The JSON file path plus the test name are used as the unique test identifier.
The transaction test fixture format could contain multiple test vectors per test object, each represented by an element in the mapping of lists of the result
field.
However tests generated by the execution-spec-tests
repository do not use this feature, as every single test object contains only a single test vector.
Consumption¶
For each Fixture
test object in the JSON fixture file, perform the following steps:
- Obtain the
txbytes
serialized bytes of the transaction to be parsed. -
For each
Fork
key ofresult
in the test:- Assume the fork schedule according to the current
Fork
key. - Using the
txbytes
, attempt to decode the transaction. - If the transaction could not be decoded:
- If the transaction could be decoded:
- Compare the calculated hash with the expected hash contained in the
hash
field, and fail the test if they do not match. - Compare the calculated intrinsic gas with the expected intrinsic gas contained in the
intrinsicGas
field, and fail the test if they do not match. - Compare the calculated sender with the expected sender contained in the
sender
field, and fail the test if they do not match.
- Compare the calculated hash with the expected hash contained in the
- Assume the fork schedule according to the current
Structures¶
Fixture
¶
- txbytes
: Bytes
¶
Serialized bytes of the transaction under test.
- result
: Mapping
[
Fork
,
FixtureResult
]
¶
Mapping of results for verification per fork, where each key-value represents a single possible outcome of the transaction parsed in the given fork.
FixtureResult
¶
- hash
: Hash
| None
¶
Calculated hash of the transaction (Field is missing if the transaction is expected to fail).
- intrinsicGas
: ZeroPaddedHexNumber
¶
Total intrinsic gas cost of the transaction (Field is missing if the transaction is expected to fail).
- sender
: Address
¶
Sender address of the transaction (Field is missing if the transaction is expected to fail).
- exception
: TransactionException
¶
Exception that is expected to be thrown by the transaction parsing (Field is missing if the transaction is expected to succeed).