Skip to content

Commit

Permalink
Add tests that deleted account stays deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
carver committed Jan 30, 2020
1 parent f5c9341 commit 16a9b34
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/core/vm/test_vm_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,52 @@ def test_revert_selfdestruct(state, read_storage_before_snapshot):
assert state.get_storage(ADDRESS, 1) == 2


def test_delete_after_create_in_same_block(state):
# create account with storage in one "transaction"
state.set_storage(ADDRESS, 0, 1)
state.lock_changes()

# delete account in next "transaction"
state.delete_account(ADDRESS)
state.lock_changes()

# deleted account should not exist
assert not state.account_exists(ADDRESS)

state.persist()

# deleted account should not exist, even after persisting
assert not state.account_exists(ADDRESS)


def test_delete_and_revive_in_same_block(state):
# create account with storage in one "transaction"
state.set_storage(ADDRESS, 0, 1)
state.lock_changes()

# delete account in next "transaction"
state.delete_account(ADDRESS)
assert state.get_storage(ADDRESS, 0) == 0
state.lock_changes()
assert state.get_storage(ADDRESS, 0) == 0

# delete account in next "transaction"
state.set_storage(ADDRESS, 2, 3)
state.lock_changes()

# make sure original value stays deleted
assert state.get_storage(ADDRESS, 0) == 0
# but new value is saved
assert state.get_storage(ADDRESS, 2) == 3

state.persist()

# make sure original value stays deleted
assert state.get_storage(ADDRESS, 0) == 0
# but new value is saved
assert state.get_storage(ADDRESS, 2) == 3


def test_lock_state(state):
assert state.get_storage(ADDRESS, 1, from_journal=False) == 0

Expand Down

0 comments on commit 16a9b34

Please sign in to comment.