Skip to content

Commit

Permalink
Add python test that deploys the contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahakShama committed Feb 27, 2022
1 parent 847cf52 commit 6d86916
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,16 @@ jobs:
- name: Run unit tests
run: yarn test

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install pytest
run: python -m pip install --upgrade pytest

- name: Install cairo lang
run: python -m pip install --upgrade cairo-lang>=0.7.1

- name: Run python unit tests
run: py.test
49 changes: 49 additions & 0 deletions test/starknet/test_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import asyncio
import os
import pytest

from starkware.starknet.testing.contract import StarknetContract
from starkware.starknet.testing.starknet import Starknet

COMPILED_CONTRACTS_DIR = os.path.join("starknet-artifacts", "contracts", "starknet")


@pytest.fixture(scope="session")
def event_loop():
loop = asyncio.get_event_loop()
yield loop
loop.close()


@pytest.fixture(scope="session")
async def starknet() -> Starknet:
return await Starknet.empty()


async def load_compiled_contract_and_deploy(
starknet: Starknet, contract_name: str
) -> StarknetContract:
return await starknet.deploy(
constructor_calldata=[],
contract_def=ContractDefinition.loads(
open(
os.path.join(
COMPILED_CONTRACTS_DIR, f"{contract_name}.cairo", f"{contract_name}.json"
)
).read()
),
)


@pytest.fixture
async def l1_auth_mock_contract(starknet: Starknet) -> StarknetContract:
return load_compiled_contract_and_deploy(starknet=starknet, contract_name="L1AuthMock")


@pytest.fixture
async def l2_auth_mock_contract(starknet: Starknet) -> StarknetContract:
return load_compiled_contract_and_deploy(starknet=starknet, contract_name="L2AuthMock")


def test_fixtures(l1_auth_mock_contract: StarknetContract, l2_auth_mock_contract: StarknetContract):
pass

0 comments on commit 6d86916

Please sign in to comment.