-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontract_test.py
28 lines (23 loc) · 911 Bytes
/
contract_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import pytest
from starkware.starknet.testing.starknet import Starknet
# The path to the contract source code.
# CONTRACT_FILE = os.path.join(os.path.dirname(__file__), "contract.cairo")
CONTRACT_FILE = "contract.cairo"
# The testing library uses Python's asyncio. So the following
# decorator and the ``async`` keyword are needed.
@pytest.mark.asyncio
async def test_increase_balance():
# Create a new Starknet class that simulates the StarkNet
# system.
starknet = await Starknet.empty()
# Deploy the contract.
contract = await starknet.deploy(
source=CONTRACT_FILE,
)
# Invoke increase_balance() twice.
await contract.increase_balance(amount=10).execute()
await contract.increase_balance(amount=20).execute()
# Check the result of get_balance().
execution_info = await contract.get_balance().call()
assert execution_info.result == (30,)