add tests

This commit is contained in:
mattromano 2024-06-18 12:16:19 -07:00
parent 83c714e019
commit 347dd0f83b
8 changed files with 33 additions and 101 deletions

View File

@ -1,5 +1,6 @@
{% macro missing_txs(
model
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
@ -7,6 +8,9 @@
tx_hash AS base_tx_hash
FROM
{{ ref('test_silver__transactions_full') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT
@ -33,7 +37,8 @@ WHERE
{% endmacro %}
{% macro recent_missing_txs(
model
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
@ -41,6 +46,9 @@ WHERE
tx_hash AS base_tx_hash
FROM
{{ ref('test_silver__transactions_recent') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT
@ -65,7 +73,8 @@ WHERE
{% endmacro %}
{% macro gold_missing_txs(
model
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
@ -73,6 +82,9 @@ WHERE
tx_hash AS base_tx_hash
FROM
{{ ref('test_gold__transactions_full') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT
@ -99,7 +111,8 @@ WHERE
{% endmacro %}
{% macro gold_recent_missing_txs(
model
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
@ -107,6 +120,9 @@ WHERE
tx_hash AS base_tx_hash
FROM
{{ ref('test_gold__transactions_recent') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT
@ -167,83 +183,3 @@ WHERE
txs_base
)
{% endmacro %}
{% macro tx_gaps(
model
) %}
WITH block_base AS (
SELECT
block_number,
tx_count
FROM
{{ ref('test_gold__blocks_full') }}
),
model_name AS (
SELECT
block_number,
COUNT(
DISTINCT tx_hash
) AS model_tx_count
FROM
{{ model }}
GROUP BY
block_number
)
SELECT
block_base.block_number,
tx_count,
model_name.block_number AS model_block_number,
model_tx_count
FROM
block_base
LEFT JOIN model_name
ON block_base.block_number = model_name.block_number
WHERE
(
tx_count <> model_tx_count
)
OR (
model_tx_count IS NULL
AND tx_count <> 0
)
{% endmacro %}
{% macro recent_tx_gaps(
model
) %}
WITH block_base AS (
SELECT
block_number,
tx_count
FROM
{{ ref('test_gold__blocks_recent') }}
),
model_name AS (
SELECT
block_number,
COUNT(
DISTINCT tx_hash
) AS model_tx_count
FROM
{{ model }}
GROUP BY
block_number
)
SELECT
block_base.block_number,
tx_count,
model_name.block_number AS model_block_number,
model_tx_count
FROM
block_base
LEFT JOIN model_name
ON block_base.block_number = model_name.block_number
WHERE
(
tx_count <> model_tx_count
)
OR (
model_tx_count IS NULL
AND tx_count <> 0
)
{% endmacro %}

View File

@ -6,8 +6,4 @@
SELECT
*
FROM
{{ ref('core__fact_traces') }}
WHERE
from_address <> '0x'
AND
to_address <> '0x'
{{ ref('core__fact_traces') }}

View File

@ -12,6 +12,4 @@ models:
tests:
- dbt_expectations.expect_row_values_to_have_recent_data:
datepart: day
interval: 1
interval: 1

View File

@ -20,8 +20,4 @@ WHERE
block_number
FROM
last_3_days
)
AND
from_address <> '0x'
AND
to_address <> '0x'
)

View File

@ -1,2 +1,5 @@
-- depends_on: {{ ref('test_gold__transactions_full') }}
{{ gold_missing_txs(ref("test_gold__traces_full")) }}
{{ gold_missing_txs(
ref("test_gold__traces_full"),
"block_timestamp >= '2024-05-31' AND block_timestamp <= DATEADD(hour, -3, CURRENT_TIMESTAMP)"
) }}

View File

@ -1,2 +1,2 @@
-- depends_on: {{ ref('test_gold__blocks_full') }}
{{ tx_gaps(ref("test_gold__transactions_full")) }}
{{ fsc_utils.tx_gaps(ref("test_gold__transactions_full")) }}

View File

@ -1,2 +1,5 @@
-- depends_on: {{ ref('test_gold__transactions_recent') }}
{{ gold_recent_missing_txs(ref("test_gold__traces_recent")) }}
{{ gold_recent_missing_txs(
ref("test_gold__traces_recent"),
"block_timestamp <= DATEADD(hour, -3, CURRENT_TIMESTAMP)"
) }}

View File

@ -1,2 +1,2 @@
-- depends_on: {{ ref('test_gold__blocks_recent') }}
{{ recent_tx_gaps(ref("test_gold__transactions_recent")) }}
{{ fsc_utils.recent_tx_gaps(ref("test_gold__transactions_recent")) }}