diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ba68267..455051a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/test/starknet/test_contract.py b/test/starknet/test_contract.py new file mode 100644 index 00000000..c4aa6111 --- /dev/null +++ b/test/starknet/test_contract.py @@ -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