Skip to content

Commit

Permalink
Remove skipping of certain tests (#1470)
Browse files Browse the repository at this point in the history
* Remove skip 'test_get_declare_transaction'

* Remove skip 'test_get_invoke_transaction'

* Remove skip 'test_get_deploy_account_transaction'

* Remove skip 'test_get_block_by_hash'

* Remove skip 'test_multicall'

* Remove skipping of several tests

* Remove skipping of several tests

* Remove skipping of several tests

* Remove skipping of several tests

* Remove skipping of several tests

* Remove ledger from CI

* Update 'max_fee' in 'test_declare_v2'

* Skip ledger tests

* Update 'max_fee' in 'test_declaring_contracts'

* Add copy of map contract

* Add copy of account contract

* Add second copy of map contract

* Fix 'lib.cairo'

* Fix import

* Fix import

* Fix 'test_compute_sierra_class_hash'

* Revert "Remove ledger from CI"

This reverts commit a2efffa.

* Revert "Skip ledger tests"

This reverts commit 376e6fe.

* Rename 'account_copy.cario' -> 'account_copy1.cairo'

* Fix imports in 'lib.cairo'

* Revert "Fix 'test_compute_sierra_class_hash'"

This reverts commit 82a21e4.

* Reapply "Remove ledger from CI"

This reverts commit ec492e6.

* Reapply "Skip ledger tests"

This reverts commit dd560e7.

* Revert "Reapply "Skip ledger tests""

This reverts commit c88cb42.

* Revert "Reapply "Remove ledger from CI""

This reverts commit 203de83.

* Remove unnecessary line

* Rename copy fizture names

* Fix lint

* Rename contracts
  • Loading branch information
kkawula authored Sep 6, 2024
1 parent 688fd8f commit 40f59e8
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 56 deletions.
3 changes: 0 additions & 3 deletions starknet_py/tests/e2e/block_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ async def test_block_with_tx_hashes_pending(account):
assert isinstance(blk.transactions, list)


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_block_with_tx_hashes_latest(account):
blk = await account.client.get_block_with_tx_hashes(block_number="latest")
Expand Down Expand Up @@ -64,7 +62,6 @@ async def test_get_block_with_txs_pending(account):
assert isinstance(blk.transactions, list)


# TODO (#1419): Fix contract redeclaration
@pytest.mark.asyncio
async def test_get_block_with_txs_latest(account, map_class_hash):
# pylint: disable=unused-argument
Expand Down
28 changes: 0 additions & 28 deletions starknet_py/tests/e2e/client/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
)


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_declare_transaction(
client, declare_transaction_hash, class_hash, account
Expand All @@ -55,8 +53,6 @@ async def test_get_declare_transaction(
assert transaction.sender_address == account.address


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_invoke_transaction(
client,
Expand All @@ -69,8 +65,6 @@ async def test_get_invoke_transaction(
assert transaction.hash == invoke_transaction_hash


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_deploy_account_transaction(client, deploy_account_transaction_hash):
transaction = await client.get_transaction(deploy_account_transaction_hash)
Expand All @@ -89,8 +83,6 @@ async def test_get_transaction_raises_on_not_received(client):
await client.get_transaction(tx_hash=0x9999)


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_block_by_hash(
client,
Expand All @@ -104,8 +96,6 @@ async def test_get_block_by_hash(
assert len(block.transactions) != 0


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_block_by_number(
client,
Expand All @@ -119,8 +109,6 @@ async def test_get_block_by_number(
assert len(block.transactions) != 0


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_storage_at(client, contract_address):
storage = await client.get_storage_at(
Expand All @@ -132,8 +120,6 @@ async def test_get_storage_at(client, contract_address):
assert storage == 1897


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_transaction_receipt(
client, invoke_transaction_hash, block_with_invoke_number
Expand All @@ -145,8 +131,6 @@ async def test_get_transaction_receipt(
assert receipt.type == TransactionType.INVOKE


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_estimate_fee_invoke(account, contract_address):
invoke_tx = await account.sign_invoke_v1(
Expand All @@ -169,8 +153,6 @@ async def test_estimate_fee_invoke(account, contract_address):
assert estimate_fee.data_gas_consumed > 0


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_estimate_fee_invoke_v3(account, contract_address):
invoke_tx = await account.sign_invoke_v3(
Expand Down Expand Up @@ -228,8 +210,6 @@ async def test_estimate_fee_deploy_account(client, deploy_account_transaction):
assert estimate_fee.data_gas_consumed > 0


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_estimate_fee_for_multiple_transactions(
client, deploy_account_transaction, contract_address, account
Expand Down Expand Up @@ -260,8 +240,6 @@ async def test_estimate_fee_for_multiple_transactions(
assert estimated_fee.data_gas_consumed > 0


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_call_contract(client, contract_address):
call = Call(
Expand Down Expand Up @@ -292,8 +270,6 @@ async def test_add_transaction(map_contract, client, account):
assert transaction_receipt.type == TransactionType.INVOKE


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_class_hash_at(client, contract_address, class_hash):
received_class_hash = await client.get_class_hash_at(
Expand All @@ -302,8 +278,6 @@ async def test_get_class_hash_at(client, contract_address, class_hash):
assert received_class_hash == class_hash


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_get_class_by_hash(client, class_hash):
contract_class = await client.get_class_by_hash(class_hash=class_hash)
Expand Down Expand Up @@ -501,8 +475,6 @@ async def test_state_update_storage_diffs(
assert isinstance(state_update, BlockStateUpdate)


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.run_on_devnet
@pytest.mark.asyncio
async def test_state_update_deployed_contracts(
Expand Down
6 changes: 0 additions & 6 deletions starknet_py/tests/e2e/client/full_node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def _parse_event_name(event: str) -> str:
EVENT_TWO_PARSED_NAME = _parse_event_name("AnotherPutCalled")


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.run_on_devnet
@pytest.mark.asyncio
async def test_node_get_declare_transaction_by_block_number_and_index(
Expand All @@ -57,8 +55,6 @@ async def test_node_get_declare_transaction_by_block_number_and_index(
assert tx.version == 2


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.run_on_devnet
@pytest.mark.asyncio
async def test_get_class_at(
Expand Down Expand Up @@ -496,8 +492,6 @@ async def test_simulate_transactions_invoke(account, deployed_balance_contract):
assert simulated_txs[0].transaction_trace.execution_resources is not None


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_simulate_transactions_two_txs(account, deployed_balance_contract):
assert isinstance(deployed_balance_contract, Contract)
Expand Down
4 changes: 1 addition & 3 deletions starknet_py/tests/e2e/docs/code_examples/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ async def test_from_address(account, contract_address):
# docs-end: from_address


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_declare_v2(account):
compiled_contract = load_contract(
Expand All @@ -66,7 +64,7 @@ async def test_declare_v2(account):
account,
compiled_contract=compiled_contract["sierra"],
compiled_contract_casm=compiled_contract["casm"],
max_fee=int(1e15),
max_fee=int(1e18),
)
# docs-end: declare_v2
await declare_result.wait_for_acceptance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ async def test_trace_transaction(client):
# docs-end: trace_transaction


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_simulate_transactions(
account, deployed_balance_contract, deploy_account_transaction
Expand Down
16 changes: 11 additions & 5 deletions starknet_py/tests/e2e/docs/guide/test_declaring_contracts.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import sys

import pytest

from starknet_py.net.client_models import ResourceBounds


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.skipif(
"--contract_dir=v2" not in sys.argv,
reason="Contract exists only in v2 directory",
)
@pytest.mark.asyncio
async def test_declaring_contracts(account, map_compiled_contract_and_class_hash):
(compiled_contract, class_hash) = map_compiled_contract_and_class_hash
async def test_declaring_contracts(
account, map_compiled_contract_and_class_hash_copy_1
):
(compiled_contract, class_hash) = map_compiled_contract_and_class_hash_copy_1

# docs: start
# Account.sign_declare_v2 and Account.sign_declare_v3 take string containing a compiled contract (sierra)
Expand All @@ -18,7 +24,7 @@ async def test_declaring_contracts(account, map_compiled_contract_and_class_hash
compiled_contract=compiled_contract,
compiled_class_hash=class_hash,
l1_resource_bounds=ResourceBounds(
max_amount=5000, max_price_per_unit=int(1e12)
max_amount=int(1e5), max_price_per_unit=int(1e13)
),
)

Expand Down
2 changes: 0 additions & 2 deletions starknet_py/tests/e2e/docs/guide/test_multicall.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import pytest


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.asyncio
async def test_multicall(account, deployed_balance_contract):
# pylint: disable=import-outside-toplevel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import sys

import pytest

from starknet_py.tests.e2e.fixtures.misc import load_contract


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.skipif(
"--contract_dir=v2" not in sys.argv,
reason="Contract exists only in v2 directory",
)
@pytest.mark.asyncio
async def test_simple_declare_and_deploy(account):
# pylint: disable=import-outside-toplevel
# docs: start
from starknet_py.contract import Contract

# docs: end
compiled_contract = load_contract("Account")
compiled_contract = load_contract("AccountCopy1")
constructor_args = {"public_key": 0x123}

# docs: start
Expand Down
11 changes: 7 additions & 4 deletions starknet_py/tests/e2e/docs/quickstart/test_using_account.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import os
import sys

import pytest

directory = os.path.dirname(__file__)


# TODO (#1419): Fix contract redeclaration
@pytest.mark.skip(reason="Redeclaration occurred")
@pytest.mark.skipif(
"--contract_dir=v2" not in sys.argv,
reason="Contract exists only in v2 directory",
)
@pytest.mark.asyncio
async def test_using_account(account, map_compiled_contract_and_class_hash):
(compiled_contract, class_hash) = map_compiled_contract_and_class_hash
async def test_using_account(account, map_compiled_contract_and_class_hash_copy_2):
(compiled_contract, class_hash) = map_compiled_contract_and_class_hash_copy_2
# pylint: disable=import-outside-toplevel, duplicate-code, too-many-locals
# docs: start
from starknet_py.contract import Contract
Expand Down
20 changes: 20 additions & 0 deletions starknet_py/tests/e2e/fixtures/contracts_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,26 @@ def map_compiled_contract_and_class_hash() -> Tuple[str, int]:
)


@pytest.fixture(scope="package")
def map_compiled_contract_and_class_hash_copy_1() -> Tuple[str, int]:
contract = load_contract("MapCopy1")

return (
contract["sierra"],
compute_casm_class_hash(create_casm_class(contract["casm"])),
)


@pytest.fixture(scope="package")
def map_compiled_contract_and_class_hash_copy_2() -> Tuple[str, int]:
contract = load_contract("MapCopy2")

return (
contract["sierra"],
compute_casm_class_hash(create_casm_class(contract["casm"])),
)


@pytest.fixture(scope="package")
def map_compiled_contract_casm() -> str:
contract = load_contract("Map")
Expand Down
36 changes: 36 additions & 0 deletions starknet_py/tests/e2e/mock/contracts_v2/src/account_copy_1.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#[starknet::contract]
mod AccountCopy1 {
use openzeppelin::account::AccountComponent;
use openzeppelin::introspection::src5::SRC5Component;

component!(path: AccountComponent, storage: account, event: AccountEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);

// This embeds all of the methods from the many AccountComponent implementations
// and also includes `supports_interface` from `SRC5Impl`
#[abi(embed_v0)]
impl AccountMixinImpl = AccountComponent::AccountMixinImpl<ContractState>;
impl AccountInternalImpl = AccountComponent::InternalImpl<ContractState>;

#[storage]
struct Storage {
#[substorage(v0)]
account: AccountComponent::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
AccountEvent: AccountComponent::Event,
#[flat]
SRC5Event: SRC5Component::Event
}

#[constructor]
fn constructor(ref self: ContractState, public_key: felt252) {
self.account.initializer(public_key);
}
}
3 changes: 3 additions & 0 deletions starknet_py/tests/e2e/mock/contracts_v2/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ mod test_option;
mod token_bridge;
mod l1_l2;
mod map;
mod map_copy_1;
mod map_copy_2;
mod simple_storage_with_event;
mod balance;
mod account;
mod account_copy_1;
25 changes: 25 additions & 0 deletions starknet_py/tests/e2e/mock/contracts_v2/src/map_copy_1.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#[starknet::interface]
trait IMap<TMapState> {
fn put(ref self: TMapState, key: felt252, value: felt252);
fn get(self: @TMapState, key: felt252) -> felt252;
}


#[starknet::contract]
mod MapCopy1 {
#[storage]
struct Storage {
storage: LegacyMap::<felt252, felt252>,
}

#[abi(embed_v0)]
impl Map of super::IMap<ContractState> {
fn put(ref self: ContractState, key: felt252, value: felt252) {
self.storage.write(key, value);
}

fn get(self: @ContractState, key: felt252) -> felt252 {
self.storage.read(key)
}
}
}
Loading

0 comments on commit 40f59e8

Please sign in to comment.