-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixtures for debugging EF tests, and sha3_d0g0v0_Shanghai test (#702
) Time spent on this PR: 0.3 ## Pull request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? No fixture available for deploying raw bytecode (not from compilation artifacts) or setting a bytecode (without running it as in deploy). ## What is the new behavior? Added fixtures: - `deploy_eoa(private_key)` to deploy an EOA - `deploy_bytecode(bytecode)` to deploy a given raw bytecode - `create_account_with_bytecode(bytecode)` to create a CA with the given bytecode ## Other information Also added a first EF test (sha3_d0g0v0_Shanghai), currently failing due to the `return_data` shorted than the `retSize`.
- Loading branch information
1 parent
47cdfdf
commit 0c6e7a6
Showing
6 changed files
with
171 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,7 @@ markers = [ | |
"UniswapV2Factory", | ||
"Utils", | ||
"Safe", | ||
"EF_TEST", | ||
] | ||
|
||
[tool.isort] | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import logging | ||
|
||
import pytest | ||
from starkware.starknet.testing.contract import StarknetContract | ||
|
||
from tests.utils.helpers import hex_string_to_bytes_array | ||
|
||
logger = logging.getLogger() | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.EF_TEST | ||
class TestSha3: | ||
@pytest.mark.skip( | ||
"TODO: need to fix when return_data is shorter than retSize in CallHelper.finalize_calling_context" | ||
) | ||
async def test_sha3_d0g0v0_Shanghai( | ||
self, | ||
owner, | ||
create_account_with_bytecode, | ||
kakarot: StarknetContract, | ||
): | ||
called_contract = await create_account_with_bytecode("0x600060002060005500") | ||
caller_contract = await create_account_with_bytecode( | ||
"0x604060206010600f6000600435610100016001600003f100" | ||
) | ||
|
||
res = await kakarot.eth_send_transaction( | ||
origin=int(owner.address, 16), | ||
to=int(caller_contract.evm_contract_address, 16), | ||
gas_limit=1_000_000, | ||
gas_price=0, | ||
value=0, | ||
data=hex_string_to_bytes_array( | ||
# In the original EF test, the called contract is supposed to be set in genesis | ||
# at address 0x000000000000000000000000000000000000010{i} while the payload of | ||
# the tx uses {i}, hence we sub 0x100 to the real deployed called_address | ||
f"0x693c6139{int(called_contract.evm_contract_address, 16) - 0x100:064x}" | ||
), | ||
).execute(caller_address=owner.starknet_address) | ||
sha3 = called_contract.storage(0).call() | ||
assert res == sha3 |
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