Skip to content

Commit

Permalink
Merge pull request #936 from ethereum/jsign-sstore-test
Browse files Browse the repository at this point in the history
verkle: add extra SSTORE test
  • Loading branch information
jsign authored Nov 7, 2024
2 parents b08a60a + dfeacd5 commit 281da6b
Showing 1 changed file with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
)
def test_storage_slot_write(blockchain_test: BlockchainTestFiller, fork: str, slot_num):
"""
Test that storage slot writes work as expected.
Test that executes a SSTORE with a non-zero value.
"""
env = Environment(
fee_recipient="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
Expand All @@ -59,14 +59,15 @@ def test_storage_slot_write(blockchain_test: BlockchainTestFiller, fork: str, sl
pre = {
TestAddress: Account(balance=1000000000000000000000),
}
slot_value = 0x42
tx = Transaction(
ty=0x0,
chain_id=0x01,
nonce=0,
to=None,
gas_limit=100000000,
gas_price=10,
data=Op.SSTORE(slot_num, 0x42),
data=Op.SSTORE(slot_num, slot_value),
)
blocks = [Block(txs=[tx])]

Expand All @@ -75,7 +76,51 @@ def test_storage_slot_write(blockchain_test: BlockchainTestFiller, fork: str, sl
post = {
contract_address: Account(
storage={
slot_num: 0x42,
slot_num: slot_value,
},
),
}

blockchain_test(
genesis_environment=env,
pre=pre,
post=post,
blocks=blocks,
)


@pytest.mark.valid_from("Verkle")
def test_storage_slot_zero_nonzero_zero(blockchain_test: BlockchainTestFiller, fork: str):
"""
Test that executes in the same tx a SSTORE looping from abscent to zero.
"""
env = Environment(
fee_recipient="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
difficulty=0x20000,
gas_limit=10000000000,
number=1,
timestamp=1000,
)
pre = {
TestAddress: Account(balance=1000000000000000000000),
}
tx = Transaction(
ty=0x0,
chain_id=0x01,
nonce=0,
to=None,
gas_limit=100000000,
gas_price=10,
data=Op.SSTORE(0x88, 0x42) + Op.SSTORE(0x88, 0x00),
)
blocks = [Block(txs=[tx])]

contract_address = compute_create_address(address=TestAddress, nonce=tx.nonce)

post = {
contract_address: Account(
storage={
0x88: 0x00,
},
),
}
Expand Down

0 comments on commit 281da6b

Please sign in to comment.