Skip to content

Commit

Permalink
Merge pull request #69 from spencer-tb/name-every-fixtures
Browse files Browse the repository at this point in the history
Fixture Format: Add descriptive name to every fixture test.
  • Loading branch information
spencer-tb authored Mar 7, 2023
2 parents ca781a5 + 7e99929 commit 6636828
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 96 deletions.
23 changes: 16 additions & 7 deletions fillers/eips/eip3651.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,16 @@ def test_warm_coinbase_call_out_of_gas(fork):
to_address(0x400): Account(code=staticcall_code),
}

for i, data in enumerate(
[to_hash(x) for x in range(0x100, 0x400 + 1, 0x100)]
):

opcodes = {
"call": 0x100,
"callcode": 0x200,
"delegatecall": 0x300,
"staticcall": 0x400,
}
for opcode, data in opcodes.items():
tx = Transaction(
ty=0x0,
data=data,
data=to_hash(data),
chain_id=0x0,
nonce=0,
to="0xcccccccccccccccccccccccccccccccccccccccc",
Expand Down Expand Up @@ -152,7 +155,13 @@ def test_warm_coinbase_call_out_of_gas(fork):
}
)

yield StateTest(env=env, pre=pre, post=post, txs=[tx])
yield StateTest(
env=env,
pre=pre,
post=post,
txs=[tx],
tag="opcode_" + opcode,
)


@test_from(fork="shanghai")
Expand Down Expand Up @@ -256,5 +265,5 @@ def test_warm_coinbase_gas_usage(fork):
pre=pre,
post=post,
txs=[tx],
name="warm_coinbase_opcode_" + opcode.lower(),
tag="opcode_" + opcode.lower(),
)
20 changes: 7 additions & 13 deletions fillers/eips/eip3855.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def test_push0(fork):
pre[addr_1] = Account(code=code)
post[addr_1] = Account(storage={0x00: 0x01})

yield StateTest(
env=env, pre=pre, post=post, txs=[tx], name="push0_key_sstore"
)
yield StateTest(env=env, pre=pre, post=post, txs=[tx], tag="key_sstore")

"""
Test case 2: Fill stack with PUSH0, then OR all values and save using
Expand All @@ -60,9 +58,7 @@ def test_push0(fork):
pre[addr_1] = Account(code=code)
post[addr_1] = Account(storage={0x00: 0x01})

yield StateTest(
env=env, pre=pre, post=post, txs=[tx], name="push0_fill_stack"
)
yield StateTest(env=env, pre=pre, post=post, txs=[tx], tag="fill_stack")

"""
Test case 3: Stack overflow by using PUSH0 1025 times
Expand All @@ -74,7 +70,7 @@ def test_push0(fork):
post[addr_1] = Account(storage={0x00: 0x00})

yield StateTest(
env=env, pre=pre, post=post, txs=[tx], name="push0_stack_overflow"
env=env, pre=pre, post=post, txs=[tx], tag="stack_overflow"
)

"""
Expand All @@ -88,7 +84,7 @@ def test_push0(fork):
post[addr_1] = Account(storage={0x00: 0x02, 0x01: 0x00})

yield StateTest(
env=env, pre=pre, post=post, txs=[tx], name="push0_storage_overwrite"
env=env, pre=pre, post=post, txs=[tx], tag="storage_overwrite"
)

"""
Expand Down Expand Up @@ -118,7 +114,7 @@ def test_push0(fork):
post[addr_1] = Account(storage={0x00: 0x01, 0x01: 0xFF})

yield StateTest(
env=env, pre=pre, post=post, txs=[tx], name="push0_during_staticcall"
env=env, pre=pre, post=post, txs=[tx], tag="during_staticcall"
)

del pre[addr_2]
Expand All @@ -141,7 +137,7 @@ def test_push0(fork):
post[addr_1] = Account(storage={0x00: 0x01})

yield StateTest(
env=env, pre=pre, post=post, txs=[tx], name="push0_before_jumpdest"
env=env, pre=pre, post=post, txs=[tx], tag="before_jumpdest"
)

"""
Expand All @@ -155,6 +151,4 @@ def test_push0(fork):
pre[addr_1] = Account(code=code)
post[addr_1] = Account(storage={0x00: 0x02})

yield StateTest(
env=env, pre=pre, post=post, txs=[tx], name="push0_gas_cost"
)
yield StateTest(env=env, pre=pre, post=post, txs=[tx], tag="gas_cost")
32 changes: 16 additions & 16 deletions fillers/eips/eip3860.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,69 +105,69 @@ def calculate_create_tx_execution_cost(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=MAX_INITCODE_SIZE,
padding_byte=0x01,
name="max_size_ones_initcode",
name="max_size_ones",
)

INITCODE_ZEROS_MAX_LIMIT = Initcode(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=MAX_INITCODE_SIZE,
padding_byte=0x00,
name="max_size_zeros_initcode",
name="max_size_zeros",
)

INITCODE_ONES_OVER_LIMIT = Initcode(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=MAX_INITCODE_SIZE + 1,
padding_byte=0x01,
name="over_limit_ones_initcode",
name="over_limit_ones",
)

INITCODE_ZEROS_OVER_LIMIT = Initcode(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=MAX_INITCODE_SIZE + 1,
padding_byte=0x00,
name="over_limit_zeros_initcode",
name="over_limit_zeros",
)

INITCODE_ZEROS_32_BYTES = Initcode(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=32,
padding_byte=0x00,
name="32_bytes_initcode",
name="32_bytes",
)

INITCODE_ZEROS_33_BYTES = Initcode(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=33,
padding_byte=0x00,
name="33_bytes_initcode",
name="33_bytes",
)

INITCODE_ZEROS_49120_BYTES = Initcode(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=49120,
padding_byte=0x00,
name="49120_bytes_initcode",
name="49120_bytes",
)

INITCODE_ZEROS_49121_BYTES = Initcode(
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
initcode_length=49121,
padding_byte=0x00,
name="49121_bytes_initcode",
name="49121_bytes",
)

EMPTY_INITCODE = Initcode(
deploy_code=bytes(),
name="empty_initcode",
name="empty",
)
EMPTY_INITCODE.bytecode = bytes()
EMPTY_INITCODE.deployment_gas = 0
EMPTY_INITCODE.execution_gas = 0

SINGLE_BYTE_INITCODE = Initcode(
deploy_code=bytes(),
name="single_byte_initcode",
name="single_byte",
)
SINGLE_BYTE_INITCODE.bytecode = Op.STOP
SINGLE_BYTE_INITCODE.deployment_gas = 0
Expand Down Expand Up @@ -225,7 +225,7 @@ def generate_tx_initcode_limit_test_cases(
post=post,
blocks=[block],
genesis_environment=env,
name=f"initcode_tx_{initcode.name}",
tag=f"{initcode.name}",
)


Expand Down Expand Up @@ -315,7 +315,7 @@ def generate_gas_cost_test_cases(
post=post,
blocks=[block],
genesis_environment=env,
name=f"{initcode.name}_tx_exact_intrinsic_gas",
tag=f"{initcode.name}_exact_intrinsic_gas",
)

"""
Expand All @@ -341,7 +341,7 @@ def generate_gas_cost_test_cases(
post=post,
blocks=[block],
genesis_environment=env,
name=f"{initcode.name}_tx_under_intrinsic_gas",
tag=f"{initcode.name}_under_intrinsic_gas",
)

"""
Expand All @@ -367,7 +367,7 @@ def generate_gas_cost_test_cases(
post=post,
blocks=[block],
genesis_environment=env,
name=f"{initcode.name}_tx_under_execution_gas",
tag=f"{initcode.name}_under_execution_gas",
)

"""
Expand All @@ -388,7 +388,7 @@ def generate_gas_cost_test_cases(
post=post,
blocks=[block],
genesis_environment=env,
name=f"{initcode.name}_tx_exact_execution_gas",
tag=f"{initcode.name}_exact_execution_gas",
)


Expand Down Expand Up @@ -602,7 +602,7 @@ def generate_create_opcode_initcode_test_cases(
pre=pre,
post=post,
txs=[tx],
name=f"{opcode}_opcode_{initcode.name}",
tag=f"{initcode.name}",
)


Expand Down
Loading

0 comments on commit 6636828

Please sign in to comment.