Skip to content

test_valid_tx_invalid_auth_signature()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_valid_tx_invalid_auth_signature@343274cc.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_valid_tx_invalid_auth_signature --fork Amsterdam

Test sending a transaction to set the code of an account using synthetic signatures, the transaction is valid but the authorization should not go through.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
@pytest.mark.xdist_group(name="bigmem")
@pytest.mark.parametrize(
    "v,r,s",
    [
        # V
        pytest.param(2, 1, 1, id="v=2"),
        pytest.param(27, 1, 1, id="v=27"),  # Type-0 transaction valid value
        pytest.param(28, 1, 1, id="v=28"),  # Type-0 transaction valid value
        pytest.param(29, 1, 1, id="v=29"),  # Type-0 replay-protected
        # transaction valid value (chain_id=2)
        pytest.param(35, 1, 1, id="v=35"),  # Type-0 replay-protected
        # transaction valid value
        pytest.param(36, 1, 1, id="v=36"),  # Type-0 replay-protected
        # transaction valid value
        pytest.param(2**8 - 1, 1, 1, id="v=2**8-1"),
        # R
        pytest.param(1, 0, 1, id="r=0"),
        pytest.param(0, SECP256K1N - 1, 1, id="r=SECP256K1N-1"),
        pytest.param(0, SECP256K1N, 1, id="r=SECP256K1N"),
        pytest.param(0, SECP256K1N + 1, 1, id="r=SECP256K1N+1"),
        pytest.param(1, 2**256 - 1, 1, id="r=2**256-1"),
        # S
        pytest.param(1, 1, 0, id="s=0"),
        pytest.param(0, 1, SECP256K1N_OVER_2 - 1, id="s=SECP256K1N_OVER_2-1"),
        pytest.param(0, 1, SECP256K1N_OVER_2, id="s=SECP256K1N_OVER_2"),
        pytest.param(0, 1, SECP256K1N_OVER_2 + 1, id="s=SECP256K1N_OVER_2+1"),
        pytest.param(0, 1, SECP256K1N - 1, id="s=SECP256K1N-1"),
        pytest.param(0, 1, SECP256K1N, id="s=SECP256K1N"),
        pytest.param(0, 1, SECP256K1N + 1, id="s=SECP256K1N+1"),
        pytest.param(0, 1, 2**256 - 1, id="s=2**256-1"),
        # All Values
        pytest.param(0, 0, 0, id="v=r=s=0"),
        pytest.param(
            2**8 - 1, 2**256 - 1, 2**256 - 1, id="v=2**8-1,r=s=2**256-1"
        ),
    ],
)
@pytest.mark.eels_base_coverage
def test_valid_tx_invalid_auth_signature(
    state_test: StateTestFiller,
    pre: Alloc,
    chain_config: ChainConfig,
    v: int,
    r: int,
    s: int,
) -> None:
    """
    Test sending a transaction to set the code of an account using synthetic
    signatures, the transaction is valid but the authorization should not go
    through.
    """
    success_slot = 1

    callee_code = Op.SSTORE(success_slot, 1) + Op.STOP
    callee_address = pre.deploy_contract(callee_code)

    authorization_tuple = AuthorizationTuple(
        address=0,
        nonce=0,
        chain_id=chain_config.chain_id,
        v=v,
        r=r,
        s=s,
    )

    tx = Transaction(
        to=callee_address,
        value=0,
        authorization_list=[authorization_tuple],
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            callee_address: Account(
                storage={success_slot: 1},
            ),
        },
    )

Parametrized Test Cases

This test generates 22 parametrized test cases across 3 forks.