Skip to content

Test SWAPN

Documentation for tests/amsterdam/eip8024_dupn_swapn_exchange/test_swapn.py@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8024_dupn_swapn_exchange/test_swapn.py --fork Amsterdam

SWAPN instruction tests.

Tests for SWAPN instruction in EIP-8024: Stack Access Instructions.

Test Functions Overview

Name Type Cases (Amsterdam) Description
test_endofcode_behavior state_test 1 Test SWAPN when the immediate byte is beyond the end of code.
test_swapn_basic state_test 8 Test SWAPN with various stack indices (17-235).
test_swapn_gas_cost_boundary state_test 5 Test SWAPN at the gas cost boundary.
test_swapn_invalid_immediate_aborts state_test 37 Test SWAPN with invalid immediate values (90 < x < 128) aborts.
test_swapn_jump_to_immediate_byte_0x5b_succeeds state_test 1 Test that jumping to 0x5b after SWAPN succeeds (backward compat).
test_swapn_jump_to_valid_immediate_fails state_test 1 Test jumping to a valid immediate byte fails.
test_swapn_preserves_other_stack_items state_test 1 Test SWAPN only swaps the specified items, leaving others unchanged.
test_swapn_stack_underflow state_test 1 Test SWAPN causes transaction failure on stack underflow.
test_swapn_valid_immediates state_test 6 Test SWAPN with valid immediate values (0-90 and 128-255).
test_swapn_with_dup1_and_push state_test 1 Test SWAPN swapping top and bottom after building stack with DUP1.