From 80ba427a0cebf8f77b39f566f97d8f0214c98142 Mon Sep 17 00:00:00 2001 From: ztepler Date: Fri, 19 Jun 2026 15:35:04 +0000 Subject: [PATCH] test: sync integration tests with current Tezos X indexer API - l2_account is now a relation table; query/assert via the l2_account_id scalar FK instead of the old scalar field - tezos_ticket.etherlink_token (1:1) became etherlink_tokens (1:N, one L2 token per runtime); assert membership in the list - native XTZ L2 token id renamed xtz -> xtz_evm - indexer health check classifies the Michelson L2 index by name so its L2 levels aren't compared against the L1 head Assisted-By: claude-opus-4-8[1m] --- scripts/tests/deposit_test.py | 24 ++++++++++++------------ scripts/tests/dto.py | 3 ++- scripts/tests/indexer_content_test.py | 20 +++++++++++--------- scripts/tests/withdraw_test.py | 6 +++--- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/scripts/tests/deposit_test.py b/scripts/tests/deposit_test.py index 4292705..ad62dca 100644 --- a/scripts/tests/deposit_test.py +++ b/scripts/tests/deposit_test.py @@ -72,10 +72,10 @@ def bridge_deposit_query(self) -> DocumentNode: } ) { l1_transaction { - operation_hash, l1_account, l2_account, ticket_hash, amount, ticket {token_id} + operation_hash, l1_account, l2_account_id, ticket_hash, amount, ticket {token_id} } l2_transaction { - l2_account, ticket_hash, amount, l2_token {id} + l2_account_id, ticket_hash, amount, l2_token {id} } } } @@ -117,7 +117,7 @@ def bridge_operation_query(self) -> DocumentNode: }) { deposit { l1_transaction { - l1_account, l2_account, amount, ticket {token_id} + l1_account, l2_account_id, amount, ticket {token_id} } }, is_completed, is_successful, status } @@ -176,13 +176,13 @@ def test_single_token_deposit( 'l1_transaction': { 'operation_hash': operation_hash, 'l1_account': wallet.l1_public_key_hash, - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(token.ticket_hash), 'amount': str(amount), 'ticket': {'token_id': token.l1_asset_id}, }, 'l2_transaction': { - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(token.ticket_hash), 'amount': str(amount), 'l2_token': {'id': token.l2_token_address.lower()}, @@ -257,13 +257,13 @@ def test_batch_token_deposit( 'l1_transaction': { 'operation_hash': operation_hash, 'l1_account': wallet.l1_public_key_hash, - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(token.ticket_hash), 'amount': str(amount), 'ticket': {'token_id': token.l1_asset_id}, }, 'l2_transaction': { - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(token.ticket_hash), 'amount': str(amount), 'l2_token': {'id': token.l2_token_address.lower()}, @@ -378,7 +378,7 @@ def test_successful_deposit_with_ticket_router_tester( indexed_operation = indexed_operations[0] assert indexed_operation['deposit']['l1_transaction'] == { 'l1_account': wallet.l1_public_key_hash, - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'amount': str(amount), 'ticket': { 'token_id': token.l1_asset_id, @@ -437,13 +437,13 @@ def test_single_xtz_deposit( 'l1_transaction': { 'operation_hash': operation_hash, 'l1_account': wallet.l1_public_key_hash, - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(native_asset.ticket_hash), 'amount': str(amount), 'ticket': {'token_id': native_asset.l1_asset_id}, }, 'l2_transaction': { - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(native_asset.ticket_hash), 'amount': str(amount) + '0' * 12, 'l2_token': {'id': native_asset.l2_token_address}, @@ -505,13 +505,13 @@ def test_batch_xtz_deposit( 'l1_transaction': { 'operation_hash': operation_hash, 'l1_account': wallet.l1_public_key_hash, - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(native_asset.ticket_hash), 'amount': str(amount), 'ticket': {'token_id': native_asset.l1_asset_id}, }, 'l2_transaction': { - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(native_asset.ticket_hash), 'amount': str(amount) + '0' * 12, 'l2_token': {'id': native_asset.l2_token_address}, diff --git a/scripts/tests/dto.py b/scripts/tests/dto.py index fbd2d9f..b2e785a 100644 --- a/scripts/tests/dto.py +++ b/scripts/tests/dto.py @@ -35,4 +35,5 @@ class Token(BaseModel): class Native(Token): l1_asset_id: Literal['xtz'] = 'xtz' - l2_token_address: Literal['xtz'] = 'xtz' + # Etherlink-side id of native XTZ on the EVM L2 (Michelson L2 uses 'xtz_michelson'). + l2_token_address: Literal['xtz_evm'] = 'xtz_evm' diff --git a/scripts/tests/indexer_content_test.py b/scripts/tests/indexer_content_test.py index 84f9f60..529639b 100644 --- a/scripts/tests/indexer_content_test.py +++ b/scripts/tests/indexer_content_test.py @@ -57,7 +57,7 @@ def indexer_query(self) -> DocumentNode: tezos_ticket(where: {hash: {_eq: $ticket_hash}}) { ticketer_address token_id - etherlink_token { id } + etherlink_tokens { id } } } ''' @@ -71,9 +71,11 @@ def test_indexer_is_healthy( indexer_query: DocumentNode, ) -> None: # An index reports the block level it has processed; compare it to the - # chain head (L1 for `tezos.*` indexes, L2 for `etherlink_*`). A `status` - # check alone is not enough — DipDup keeps EVM indexes at `syncing` even - # when they are caught up, so the real health signal is the gap to head. + # chain head. Most `tezos.*` indexes track L1, but the Tezos X Michelson L2 + # index also carries a `tezos.*` type while indexing the L2 chain — classify + # it as L2 by name, else its L1-vs-L2 level gap reads as a huge bogus lag. A + # `status` check alone is not enough — DipDup keeps EVM indexes at `syncing` + # even when caught up, so the real health signal is the gap to head. l2_head = get_etherlink_web3(bridge.l2_rpc_url).eth.block_number response = indexer.execute(indexer_query, operation_name='IndexerStatus') @@ -83,7 +85,8 @@ def test_indexer_is_healthy( name, status = index['name'], index['status'] assert status not in ('failed', 'disabled'), f"Index '{name}': {status}" - head = l1_head if index['type'].startswith('tezos') else l2_head + is_l2 = index['type'].startswith('evm') or 'michelson' in name + head = l2_head if is_l2 else l1_head lag = head - index['level'] assert lag < INDEXER_MAX_LAG_BLOCKS, ( f"Index '{name}' is {lag} blocks behind the chain head " @@ -153,7 +156,6 @@ def test_asset_ticket_whitelisted( indexer_ticket_data = response['tezos_ticket'][0] assert indexer_ticket_data['token_id'] == asset.l1_asset_id assert indexer_ticket_data['ticketer_address'] == asset.l1_ticketer_address - assert ( - indexer_ticket_data['etherlink_token']['id'] - == asset.l2_token_address.lower() - ) + # A ticket can map to several Etherlink tokens, so check membership. + etherlink_token_ids = [t['id'] for t in indexer_ticket_data['etherlink_tokens']] + assert asset.l2_token_address.lower() in etherlink_token_ids diff --git a/scripts/tests/withdraw_test.py b/scripts/tests/withdraw_test.py index f3b2cb0..0db4b5c 100644 --- a/scripts/tests/withdraw_test.py +++ b/scripts/tests/withdraw_test.py @@ -27,7 +27,7 @@ def bridge_withdrawal_query(self) -> DocumentNode: l2_transaction { transaction_hash l1_account - l2_account + l2_account_id ticket_hash l2_token { id @@ -55,7 +55,7 @@ def bridge_pending_withdrawal_query(self) -> DocumentNode: where: { l1_transaction_id: {_is_null: true} l2_transaction: { - l2_account: {_eq: $l2_account} + l2_account_id: {_eq: $l2_account} ticket_hash: {_eq: $ticket_hash}, } }, @@ -131,7 +131,7 @@ def test_create_token_withdraw( 'l2_transaction': { 'transaction_hash': transaction_hash, 'l1_account': wallet.l1_public_key_hash, - 'l2_account': wallet.l2_public_key.removeprefix('0x').lower(), + 'l2_account_id': wallet.l2_public_key.removeprefix('0x').lower(), 'ticket_hash': str(token.ticket_hash), 'l2_token': { 'id': token.l2_token_address.lower(),