-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix withdrawals is Option and improve block serde
- Loading branch information
1 parent
03ff3fa
commit 0a12daa
Showing
4 changed files
with
103 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
from src.utils.uint256 import int_to_uint256 | ||
from tests.utils.models import Account, to_int | ||
from tests.utils.models import Account, Block, to_int | ||
|
||
|
||
class TestSerde: | ||
|
||
def test_block(self, cairo_run, block): | ||
cairo_run("test_block", block=block) | ||
|
||
def test_account(self, cairo_run, account): | ||
result = cairo_run("test_account", account=account) | ||
# Storage needs to handle differently because of the hashing of the keys | ||
assert { | ||
k: int_to_uint256(to_int(v)) for k, v in result["storage"].items() | ||
} == account.storage | ||
result["storage"] = {} | ||
account.storage = {} | ||
|
||
assert Account.model_validate(result) == account | ||
result = cairo_run("test_block", block=block) | ||
assert Block.model_validate(result) == block | ||
|
||
def test_state(self, cairo_run, state): | ||
cairo_run("test_state", state=state) | ||
result = cairo_run("test_state", state=state) | ||
assert [int(key, 16) for key in result["accounts"].keys()] == list( | ||
state.accounts.keys() | ||
) | ||
for result, account in zip( | ||
result["accounts"].values(), state.accounts.values() | ||
): | ||
# Storage needs to be handled differently because of the hashing of the keys | ||
assert { | ||
k: int_to_uint256(to_int(v)) | ||
for k, v in result["storage"].items() | ||
if v is not None | ||
} == account.storage | ||
result["storage"] = {} | ||
account.storage = {} | ||
assert Account.model_validate(result) == account |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters