Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
fix: missed updates from merge
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 2, 2022
1 parent 4992066 commit 7b36e5d
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
name: black
Expand All @@ -21,7 +21,7 @@ repos:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.961
rev: v0.971
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-requests]
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ cd ape-starknet
python3 -m venv venv
source venv/bin/activate

# install brownie into the virtual environment
# install ape-starknet into the virtual environment
python setup.py install

# install the developer dependencies (-e is interactive mode)
pip install -e .[dev]
pip install -e .'[dev]'
```

## Pre-Commit Hooks
Expand Down
20 changes: 20 additions & 0 deletions tests/functional/test_explorer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from ape_starknet.accounts import OPEN_ZEPPELIN_ACCOUNT_CONTRACT_TYPE


def test_get_contract_type_tokens(tokens, explorer):
actual = explorer.get_contract_type(tokens.token_address_map["eth"]["local"])
expected = tokens.contract_type
assert actual == expected


def test_get_contract_type_accounts(account, second_account, explorer):
actual_0 = explorer.get_contract_type(account.address)
actual_1 = explorer.get_contract_type(second_account.address)
assert actual_0 == OPEN_ZEPPELIN_ACCOUNT_CONTRACT_TYPE
assert actual_1 == OPEN_ZEPPELIN_ACCOUNT_CONTRACT_TYPE


def test_get_contract_type_after_deploy(contract, explorer):
actual = explorer.get_contract_type(contract.address)
expected = contract.contract_type
assert actual.abi == expected.abi
22 changes: 22 additions & 0 deletions tests/functional/test_networks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from ape.contracts import ContractInstance


def test_multiple_networks_in_test(
networks, provider, eth_account, eth_contract_container, contract, account
):
starknet_chain_id = provider.chain_id

with networks.ethereum.local.use_provider("test") as eth_provider:
# Verify the chain changed
assert eth_provider.chain_id != starknet_chain_id

# Deploy and interact with a contract on Ethereum
eth_contract = eth_contract_container.deploy(sender=eth_account)
receipt = eth_contract.setNumber(123, sender=eth_account)
assert not receipt.failed
assert isinstance(eth_contract, ContractInstance)
assert eth_contract.myNumber() == 123

# Switch back to Starknet
receipt = contract.increase_balance(account.address, 123, sender=account)
assert not receipt.failed
40 changes: 40 additions & 0 deletions tests/functional/test_receipt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest

AMOUNT_0 = 10
AMOUNT_1 = 2**128 + 42


@pytest.fixture
def receipt(token_contract, account, second_account):
return token_contract.fire_events(second_account.address, AMOUNT_0, AMOUNT_1, sender=account)


def test_decode_logs(receipt, token_contract, account, second_account):
transfer_logs = list(receipt.decode_logs(token_contract.Transfer))
assert len(transfer_logs) == 1
log = transfer_logs[0]
assert log.from_ == int(account.address, 16)
assert log.to == int(second_account.address, 16)
assert log.value == AMOUNT_0

mint_logs = list(receipt.decode_logs(token_contract.Mint))
assert len(mint_logs) == 1
log = mint_logs[0]
assert log.sender == int(account.address, 16)
assert log.amount0 == AMOUNT_0
assert log.amount1 == AMOUNT_1
assert log.to == int(second_account.address, 16)


def test_decode_logs_no_specify_abi(receipt, account, second_account):
logs = list(receipt.decode_logs())
assert len(logs) == 2
transfer_log, mint_log = logs

assert transfer_log.from_ == int(account.address, 16)
assert transfer_log.to == int(second_account.address, 16)
assert transfer_log.value == AMOUNT_0
assert mint_log.sender == int(account.address, 16)
assert mint_log.amount0 == AMOUNT_0
assert mint_log.amount1 == AMOUNT_1
assert mint_log.to == int(second_account.address, 16)

0 comments on commit 7b36e5d

Please sign in to comment.