Skip to content

Commit ef4992d

Browse files
authored
Migrate tests from integration to testnet (#1398)
* Move integration tests to testnet * Update development guide * Update template and `Environment variables` section in docs * Remove integration fixtures * Remove integration environment variables from `checks.yml`
1 parent bc7cc01 commit ef4992d

File tree

8 files changed

+64
-178
lines changed

8 files changed

+64
-178
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,18 +219,15 @@ jobs:
219219
# ---------------------------------------------------------- #
220220

221221
run-tests-on-networks:
222-
name: Tests on networks (testnet and integration)
222+
name: Tests on networks (testnet)
223223
needs: setup-tests
224224
runs-on: ubuntu-latest
225225
strategy:
226226
fail-fast: false
227227
env:
228-
SEPOLIA_INTEGRATION_RPC_URL: ${{ secrets.SEPOLIA_INTEGRATION_RPC_URL }}
229228
SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }}
230229
SEPOLIA_ACCOUNT_ADDRESS: ${{ secrets.SEPOLIA_ACCOUNT_ADDRESS }}
231230
SEPOLIA_ACCOUNT_PRIVATE_KEY: ${{ secrets.SEPOLIA_ACCOUNT_PRIVATE_KEY }}
232-
SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY: ${{ secrets.SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY }}
233-
SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS: ${{ secrets.SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS }}
234231
steps:
235232
- uses: actions/checkout@v4
236233

docs/development.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ To install `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-
2323
Environment variables
2424
^^^^^^^^^^^^^^^^^^^^^
2525

26-
In order to be able to run tests on testnet and integration networks (``starknet_py/tests/e2e/tests_on_networks/``), you must set some environmental variables:
26+
In order to be able to run tests on testnet network (``starknet_py/tests/e2e/tests_on_networks/``), you must set some environmental variables:
2727

28-
- ``SEPOLIA_INTEGRATION_RPC_URL``
2928
- ``SEPOLIA_RPC_URL``
30-
- ``SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY``
31-
- ``SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS``
3229
- ``SEPOLIA_ACCOUNT_PRIVATE_KEY``
3330
- ``SEPOLIA_ACCOUNT_ADDRESS``
3431

starknet_py/net/full_node_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,6 @@ async def get_class_by_hash(
574574
)
575575
return cast(DeprecatedContractClass, DeprecatedContractClassSchema().load(res))
576576

577-
# Only RPC methods
578-
579577
async def get_transaction_by_block_id(
580578
self,
581579
index: int,

starknet_py/tests/e2e/fixtures/constants.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ def _get_env_lambda(env_name):
3535
"0x06524771cb912945bf2db355b5a12355ca2e2ff05e15ee35366336a602293f2d"
3636
)
3737

38-
# -------------------------------- SEPOLIA INTEGRATION -------------------------------------
39-
40-
SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY = _get_env_lambda(
41-
"SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY"
42-
)
43-
44-
SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS = _get_env_lambda(
45-
"SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS"
46-
)
47-
48-
SEPOLIA_INTEGRATION_RPC_URL = _get_env_lambda("SEPOLIA_INTEGRATION_RPC_URL")
49-
5038
# -----------------------------------------------------------------------------
5139

5240
DEVNET_PRE_DEPLOYED_ACCOUNT_ADDRESS = (
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
SEPOLIA_INTEGRATION_RPC_URL=URL
21
SEPOLIA_RPC_URL=URL
3-
SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY=0x1234567890
4-
SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS=0x9876543210
52
SEPOLIA_ACCOUNT_PRIVATE_KEY=0xabcdef
63
SEPOLIA_ACCOUNT_ADDRESS=0xfedcba

starknet_py/tests/e2e/tests_on_networks/client_test.py

Lines changed: 27 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
PendingStarknetBlockWithReceipts,
2121
ResourceBoundsMapping,
2222
StarknetBlockWithReceipts,
23+
Transaction,
2324
TransactionExecutionStatus,
2425
TransactionFinalityStatus,
2526
TransactionReceipt,
@@ -208,23 +209,21 @@ async def test_estimate_message_fee_invalid_eth_address_assertion_error(
208209
(
209210
(
210211
"0xbe1259ff905cadbbaa62514388b71bdefb8aacc1",
211-
"0x2137",
212+
"0x1234",
212213
), # valid `from_address`, invalid `to_address`
213214
(
214215
"0xDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
215-
"0x073314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82",
216+
"0x06524771cb912945bf2db355b5a12355ca2e2ff05e15ee35366336a602293f2d",
216217
), # invalid `from_address` (passes through assert), valid `to_address`
217218
),
218219
)
219220
@pytest.mark.asyncio
220221
async def test_estimate_message_fee_throws(
221-
client_sepolia_integration, from_address, to_address
222+
client_sepolia_testnet, from_address, to_address
222223
):
223-
client = client_sepolia_integration
224-
225224
with pytest.raises(ClientError):
226-
_ = await client.estimate_message_fee(
227-
block_number=123123,
225+
_ = await client_sepolia_testnet.estimate_message_fee(
226+
block_number=80000,
228227
from_address=from_address,
229228
to_address=to_address,
230229
entry_point_selector="0x3248",
@@ -235,78 +234,57 @@ async def test_estimate_message_fee_throws(
235234

236235

237236
@pytest.mark.asyncio
238-
async def test_get_tx_receipt_reverted(client_sepolia_integration):
239-
client = client_sepolia_integration
237+
async def test_get_tx_receipt_reverted(client_sepolia_testnet):
240238
reverted_tx_hash = (
241-
"0x01b2d9e5a725069ae40e3149813ffe05b8c4405e253e9f8ab29d0a3b2e279927"
239+
"0x00fecca6a328dd11f40b79c30fe22d23bc6975d1a0923a95b90aff4016a84333"
242240
)
243241

244-
res = await client.get_transaction_receipt(tx_hash=reverted_tx_hash)
242+
res = await client_sepolia_testnet.get_transaction_receipt(tx_hash=reverted_tx_hash)
245243

246244
assert res.execution_status == TransactionExecutionStatus.REVERTED
247245
assert res.finality_status == TransactionFinalityStatus.ACCEPTED_ON_L1
248246
assert "Got an exception while executing a hint" in res.revert_reason
249247

250248

251249
@pytest.mark.parametrize(
252-
"block_number, transaction_index",
250+
"block_number, index, expected_hash",
253251
[
254-
# declare: https://integration-sepolia.starkscan.co/tx/0x0544a629990d2bed8ccf11910b30f2f1e18228ed5be06660bea20cae13b2aced
255-
(9707, 0),
256-
# deploy_account: https://integration-sepolia.starkscan.co/tx/0x012debae2435ea43c06610a31ccf8e7ea5de9aec43dac7c7aa86905b4ccdec49
257-
(9708, 6),
258-
# invoke: https://integration-sepolia.starkscan.co/tx/0x069125fd85a199a5d06445e1ece5067781aa46c745e3e2993c696c60bbd5992c
259-
(9708, 0),
260-
# l1_handler: https://integration-sepolia.starkscan.co/tx/0x0117be3e303704f0acb630149250a78a262ecff8bef3ee8a53a02f18b472f873
261-
(9708, 7),
252+
(81116, 0, 0x38FC01353196AEEBA62C74A8C8479FFF94AAA8CD4C3655782D49D755BBE63A8),
253+
(81116, 26, 0x3F873FE2CC884A88B8D4378EAC1786145F7167D61B0A9442DA15B0181582522),
254+
(80910, 23, 0x67C1E282F64DAD5682B1F377A5FDA1778311D894B2EE47A06058790A8B08460),
262255
],
263256
)
264257
@pytest.mark.asyncio
265258
async def test_get_transaction_by_block_id_and_index(
266-
client_sepolia_integration, block_number, transaction_index
259+
client_sepolia_testnet, block_number, index, expected_hash
267260
):
268-
client = client_sepolia_integration
269-
270-
tx = await client.get_transaction_by_block_id(
271-
block_number=block_number, index=transaction_index
261+
tx = await client_sepolia_testnet.get_transaction_by_block_id(
262+
block_number=block_number, index=index
272263
)
273264

274-
assert tx.hash is not None
275-
276-
receipt = await client.get_transaction_receipt(tx_hash=tx.hash)
277-
278-
assert receipt.finality_status is not None
279-
assert receipt.execution_status is not None
280-
281-
282-
@pytest.mark.asyncio
283-
async def test_get_block(client_sepolia_integration):
284-
client = client_sepolia_integration
285-
res = await client.get_block(block_number="latest")
286-
287-
for tx in res.transactions:
288-
assert tx.hash is not None
265+
assert isinstance(tx, Transaction)
266+
assert tx.hash == expected_hash
289267

290268

291269
@pytest.mark.asyncio
292-
async def test_get_l1_message_hash(client_sepolia_integration):
293-
tx_hash = "0x065b2b6543e49f2f8a22541e9141f506752d984b4d8c690526001025109cee30"
294-
l1_message_hash = await client_sepolia_integration.get_l1_message_hash(tx_hash)
270+
async def test_get_l1_message_hash(client_sepolia_testnet):
271+
tx_hash = "0x067d959200d65d4ad293aa4b0da21bb050a1f669bce37d215c6edbf041269c07"
272+
l1_message_hash = await client_sepolia_testnet.get_l1_message_hash(tx_hash)
295273
assert (
296274
hex(l1_message_hash)
297-
== "0x4aed43247e106a0687258bfc835131e5dee15c24fb18222d382dbff470df0f9e"
275+
== "0x2e350fa9d830482605cb68be4fdb9f0cb3e1f95a0c51623ac1a5d1bd997c2090"
298276
)
299277

300278

301279
@pytest.mark.asyncio
302280
async def test_get_l1_message_hash_raises_on_incorrect_transaction_type(
303-
client_sepolia_integration,
281+
client_sepolia_testnet,
304282
):
305-
tx_hash = "0x044a5565cde76c445db6205d208f584879d9e6e8f8b6b2ebb58e658680320cfa"
283+
tx_hash = "0x38FC01353196AEEBA62C74A8C8479FFF94AAA8CD4C3655782D49D755BBE63A8"
306284
with pytest.raises(
307285
TypeError, match=f"Transaction {tx_hash} is not a result of L1->L2 interaction."
308286
):
309-
await client_sepolia_integration.get_l1_message_hash(tx_hash)
287+
await client_sepolia_testnet.get_l1_message_hash(tx_hash)
310288

311289

312290
@pytest.mark.asyncio
@@ -399,13 +377,6 @@ async def test_get_chain_id_sepolia_testnet(client_sepolia_testnet):
399377
assert chain_id == hex(StarknetChainId.SEPOLIA.value)
400378

401379

402-
@pytest.mark.asyncio
403-
async def test_get_chain_id_sepolia_integration(client_sepolia_integration):
404-
chain_id = await client_sepolia_integration.get_chain_id()
405-
assert isinstance(chain_id, str)
406-
assert chain_id == hex(StarknetChainId.SEPOLIA_INTEGRATION.value)
407-
408-
409380
@pytest.mark.asyncio
410381
async def test_get_events_sepolia_testnet(client_sepolia_testnet):
411382
events_chunk = await client_sepolia_testnet.get_events(
@@ -425,21 +396,6 @@ async def test_get_events_sepolia_testnet(client_sepolia_testnet):
425396
assert events_chunk.events[0].keys is not None
426397

427398

428-
@pytest.mark.asyncio
429-
async def test_get_tx_receipt_with_execution_resources(client_sepolia_integration):
430-
receipt = await client_sepolia_integration.get_transaction_receipt(
431-
tx_hash=0x077E84B7C0C4CC88B778EEAEF32B7CED4500FE4AAEE62FD2F849B7DD90A87826
432-
)
433-
434-
assert receipt.execution_resources is not None
435-
assert receipt.execution_resources.data_availability is not None
436-
assert receipt.execution_resources.steps is not None
437-
assert receipt.execution_resources.bitwise_builtin_applications is not None
438-
assert receipt.execution_resources.ec_op_builtin_applications is not None
439-
assert receipt.execution_resources.pedersen_builtin_applications is not None
440-
assert receipt.execution_resources.range_check_builtin_applications is not None
441-
442-
443399
@pytest.mark.asyncio
444400
async def test_get_block_with_receipts(client_sepolia_testnet):
445401
block_with_receipts = await client_sepolia_testnet.get_block_with_receipts(
@@ -456,8 +412,8 @@ async def test_get_block_with_receipts(client_sepolia_testnet):
456412

457413

458414
@pytest.mark.asyncio
459-
async def test_get_pending_block_with_receipts(client_sepolia_integration):
460-
block_with_receipts = await client_sepolia_integration.get_block_with_receipts(
415+
async def test_get_pending_block_with_receipts(client_sepolia_testnet):
416+
block_with_receipts = await client_sepolia_testnet.get_block_with_receipts(
461417
block_number="pending"
462418
)
463419

starknet_py/tests/e2e/tests_on_networks/fixtures.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,15 @@
77
from starknet_py.tests.e2e.fixtures.constants import (
88
SEPOLIA_ACCOUNT_ADDRESS,
99
SEPOLIA_ACCOUNT_PRIVATE_KEY,
10-
SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS,
11-
SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY,
12-
SEPOLIA_INTEGRATION_RPC_URL,
1310
SEPOLIA_RPC_URL,
1411
)
1512

1613

17-
@pytest.fixture(scope="package")
18-
def client_sepolia_integration() -> FullNodeClient:
19-
return FullNodeClient(node_url=SEPOLIA_INTEGRATION_RPC_URL())
20-
21-
2214
@pytest.fixture(scope="package")
2315
def client_sepolia_testnet() -> FullNodeClient:
2416
return FullNodeClient(node_url=SEPOLIA_RPC_URL())
2517

2618

27-
@pytest.fixture(scope="package")
28-
def account_sepolia_integration(client_sepolia_integration) -> Account:
29-
return Account(
30-
address=SEPOLIA_INTEGRATION_ACCOUNT_ADDRESS(),
31-
client=client_sepolia_integration,
32-
key_pair=KeyPair.from_private_key(
33-
int(SEPOLIA_INTEGRATION_ACCOUNT_PRIVATE_KEY(), 0)
34-
),
35-
chain=StarknetChainId.SEPOLIA_INTEGRATION,
36-
)
37-
38-
3919
@pytest.fixture(scope="package")
4020
def account_sepolia_testnet(client_sepolia_testnet) -> Account:
4121
return Account(

0 commit comments

Comments
 (0)