Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
Fix test NoDelegateCall
Browse files Browse the repository at this point in the history
  • Loading branch information
obatirou committed Nov 12, 2024
1 parent a0d22f1 commit 43d3c04
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cairo_zero/kakarot/precompiles/precompiles_helpers.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace PrecompilesHelpers {
let range_check_ptr = [ap - 2];
let authorized = [ap - 1];

// Ensure that calls to CAIRO_CALL_PRECOMPILE or CAIRO_CALL_PRECOMPILE are not made through
// Ensure that calls to CAIRO_CALL_PRECOMPILE or CAIRO_MULTICALL_PRECOMPILE are not made through
// a delegatecall / callcode.
let is_delegatecall_protected_ = is_delegatecall_protected(precompile_address);
if (is_delegatecall_protected_ != FALSE) {
Expand Down
5 changes: 2 additions & 3 deletions cairo_zero/tests/src/kakarot/precompiles/test_precompiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ def test_should_deploy_account_when_sender_starknet_address_zero(
assert bytes(return_data) == b""
assert gas_used == CAIRO_PRECOMPILE_GAS

SyscallHandler.mock_deploy.assert_called_once()
return
assert SyscallHandler.mock_deploy.call_count == 1

@SyscallHandler.patch(
"Kakarot_authorized_cairo_precompiles_callers",
Expand All @@ -121,7 +120,7 @@ def test_should_deploy_account_when_sender_starknet_address_zero(
@SyscallHandler.patch(
"Kakarot_evm_to_starknet_address", CALLER_ADDRESS, 0x1234
)
@SyscallHandler.mock_deploy(lambda *_: [0])
@SyscallHandler.patch("deploy", lambda *_: [0])
@pytest.mark.parametrize(
"address, caller_address, input_data, expected_return_data, expected_reverted",
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from kakarot_scripts.constants import NETWORK
from kakarot_scripts.utils.kakarot import deploy, eth_send_transaction
from kakarot_scripts.utils.starknet import get_contract, invoke
from tests.utils.errors import cairo_error
from tests.utils.errors import cairo_error, evm_error

CALL_CAIRO_PRECOMPILE = 0x75004

Expand Down Expand Up @@ -101,9 +101,7 @@ async def test_should_fail_when_called_with_delegatecall(
async def test_should_fail_when_called_with_callcode(
self, cairo_counter_caller
):
with cairo_error(
"EVM tx reverted, reverting SN tx because of previous calls to cairo precompiles"
):
with evm_error("CairoLib: call_contract failed with"):
await cairo_counter_caller.incrementCairoCounterCallcode()

@pytest.mark.skipif(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from kakarot_scripts.utils.kakarot import deploy, eth_send_transaction
from kakarot_scripts.utils.starknet import get_contract, invoke
from tests.utils.errors import cairo_error
from tests.utils.errors import cairo_error, evm_error


@pytest_asyncio.fixture(scope="module")
Expand Down Expand Up @@ -124,7 +124,5 @@ async def test_should_fail_when_called_with_delegatecall(
async def test_should_fail_when_called_with_callcode(
self, multicall_cairo_counter_caller
):
with cairo_error(
"EVM tx reverted, reverting SN tx because of previous calls to cairo precompiles"
):
with evm_error("CairoLib: call_contract failed with"):
await multicall_cairo_counter_caller.incrementCairoCounterCallcode()
9 changes: 7 additions & 2 deletions tests/end_to_end/Security/test_dual_vm_token_hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
logger.setLevel(logging.INFO)


@pytest_asyncio.fixture(scope="function")
@pytest_asyncio.fixture(scope="package")
async def starknet_token(owner):
address = await deploy_starknet(
"StarknetToken", int(1e18), owner.starknet_contract.address
"StarknetToken",
"MyToken",
"MTK",
18,
int(2**256 - 1),
owner.starknet_contract.address,
)
return get_contract_starknet("StarknetToken", address=address)

Expand Down

0 comments on commit 43d3c04

Please sign in to comment.