test_non_canonical_single_byte()
Documentation for tests/frontier/validation/test_transaction_rlp.py::test_non_canonical_single_byte@ffe48572.
Generate fixtures for these test cases for Bogota with:
fill -v tests/frontier/validation/test_transaction_rlp.py::test_non_canonical_single_byte --fork Bogota
Encode the single-byte nonce payload behind a one-byte string
header (0x8101) instead of as the byte itself; the non-canonical
encoding must be rejected.
Source code in tests/frontier/validation/test_transaction_rlp.py
| @pytest.mark.ported_from(
[
f"{LEGACY_TX_TESTS}/ttWrongRLP/RLPIncorrectByteEncoding00Copier.json",
f"{LEGACY_TX_TESTS}/ttWrongRLP/RLPIncorrectByteEncoding01Copier.json",
f"{LEGACY_TX_TESTS}/ttWrongRLP/RLPIncorrectByteEncoding127Copier.json",
],
)
@pytest.mark.exception_test
def test_non_canonical_single_byte(
transaction_test: TransactionTestFiller,
pre: Alloc,
fork: Fork,
) -> None:
"""
Encode the single-byte nonce payload behind a one-byte string
header (0x8101) instead of as the byte itself; the non-canonical
encoding must be rejected.
"""
fields = signed_tx_fields(pre, fork, nonce=1)
payload = fields["nonce"]
assert len(payload) == 1 and payload[0] < 0x80
rlp = encode_tx(fields, {"nonce": b"\x81" + payload})
transaction_test(
pre=pre,
tx=invalid_tx(
pre, rlp, TransactionException.RLP_LEADING_ZEROS_NONCE_SIZE
),
)
|
Parametrized Test Cases
This test generates 1 parametrized test case across 17 forks.