upd native token transfer tests

This commit is contained in:
Jack Forgash 2025-04-25 12:28:34 -06:00
parent 332e3e3fdc
commit 21b6037aa9
3 changed files with 26 additions and 33 deletions

View File

@ -6,49 +6,44 @@
WITH deposit_functioncalls AS (
SELECT
DISTINCT action_id,
DISTINCT receipt_id,
action_index,
block_id,
block_timestamp,
_partition_by_block_number
FROM
{{ ref('silver__actions_events_function_call_s3') }}
{{ ref('core__ez_token_transfers') }}
WHERE
deposit :: INT > 0
action_data :deposit :: INT > 0
AND receipt_succeeded
{% if var('DBT_FULL_TEST') %}
AND _inserted_timestamp < SYSDATE() - INTERVAL '1 hour'
{% else %}
AND _inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days'
AND SYSDATE() - INTERVAL '1 hour'
{% endif %}
AND inserted_timestamp BETWEEN SYSDATE() - INTERVAL '{{ var('DBT_TEST_LOOKBACK_DAYS', 14) }} days'
AND SYSDATE() - INTERVAL '1 hour'
),
native_transfer_deposits AS (
SELECT
DISTINCT action_id,
DISTINCT receipt_id,
action_index,
block_id,
block_timestamp,
_partition_by_block_number
FROM
{{ ref('silver__token_transfer_deposit') }}
{% if var('DBT_FULL_TEST') %}
WHERE
_inserted_timestamp < SYSDATE() - INTERVAL '1 hour'
{% else %}
WHERE
_inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days'
AND inserted_timestamp BETWEEN SYSDATE() - INTERVAL '{{ var('DBT_TEST_LOOKBACK_DAYS', 14) }} days'
AND SYSDATE() - INTERVAL '1 hour'
{% endif %}
)
SELECT
A.action_id,
A.receipt_id,
A.action_index,
A.block_id,
A.block_timestamp,
A._partition_by_block_number
FROM
deposit_functioncalls A
LEFT JOIN native_transfer_deposits b
ON A.action_id = b.action_id
ON A.receipt_id = b.receipt_id
AND A.action_index = b.action_index
WHERE
b.action_id IS NULL
b.receipt_id IS NULL

View File

@ -5,3 +5,4 @@ tests:
description: |-
This test checks for gaps in Deposits from FunctionCalls and the silver model.
For best use, aggregate the results around _PARTITION_BY_BLOCK_NUMBER and run MANUAL FIX logic on these ranges.
Note - the migrated transfers table drops action_id. Tbd but needed to drop use of the functioncall table.

View File

@ -7,38 +7,34 @@ WITH transfer_actions AS (
SELECT
DISTINCT tx_hash,
receipt_id,
block_id,
block_timestamp,
_partition_by_block_number
FROM
{{ ref('silver__actions_events_s3') }}
{{ ref('core__ez_actions') }}
WHERE
LOWER(action_name) = 'transfer' {% if var('DBT_FULL_TEST') %}
AND _inserted_timestamp < SYSDATE() - INTERVAL '1 hour'
{% else %}
AND _inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days'
LOWER(action_name) = 'transfer'
AND receipt_succeeded
AND inserted_timestamp BETWEEN SYSDATE() - INTERVAL '{{ var('DBT_TEST_LOOKBACK_DAYS', 14) }} days'
AND SYSDATE() - INTERVAL '1 hour'
{% endif %}
),
native_transfers AS (
SELECT
DISTINCT tx_hash,
receipt_id,
block_id,
block_timestamp,
_partition_by_block_number
FROM
{{ ref('silver__token_transfer_native')}}
{% if var('DBT_FULL_TEST')%}
WHERE
_inserted_timestamp < SYSDATE() - INTERVAL '1 hour'
{% else %}
WHERE
_inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days'
AND SYSDATE() - INTERVAL '1 hour'
{% endif %}
inserted_timestamp BETWEEN SYSDATE() - INTERVAL '{{ var('DBT_TEST_LOOKBACK_DAYS', 14) }} days'
AND SYSDATE() - INTERVAL '1 hour'
)
select
a.tx_hash,
a.receipt_id,
a.block_id,
a.block_timestamp,
a._partition_by_block_number
@ -46,5 +42,6 @@ from
transfer_actions a
left join native_transfers b
on a.tx_hash = b.tx_hash
and a.receipt_id = b.receipt_id
where
b.tx_hash is null