Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions scripts/tests/deposit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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()},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down
3 changes: 2 additions & 1 deletion scripts/tests/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
20 changes: 11 additions & 9 deletions scripts/tests/indexer_content_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
'''
Expand All @@ -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')
Expand All @@ -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 "
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions scripts/tests/withdraw_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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},
}
},
Expand Down Expand Up @@ -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(),
Expand Down