Skip to content

Commit c8359e9

Browse files
authored
feat(cat-gateway): cardano/assets integration test (#2139)
* add assets test * wip * fix * wip * wip
1 parent 210a207 commit c8359e9

File tree

6 files changed

+80
-5218
lines changed

6 files changed

+80
-5218
lines changed

catalyst-gateway/tests/api_tests/Earthfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ builder:
1212
COPY --dir ./utils .
1313
COPY --dir ./test_data .
1414
COPY cat-libs-rust+build/mk_signed_doc .
15-
COPY ./snapshot_tool-56364174.json .
1615
DO python-ci+BUILDER
1716

1817
test:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import requests
2+
from api import cat_gateway_endpoint_url
3+
4+
URL = cat_gateway_endpoint_url("api/v1/cardano")
5+
6+
7+
# cardano assets GET
8+
def assets(stake_address: str, slot_no: int, token: str):
9+
url = f"{URL}/assets/{stake_address}?asat=SLOT:{slot_no}"
10+
headers = {
11+
"Authorization": f"Bearer {token}",
12+
"Content-Type": "application/json",
13+
}
14+
return requests.get(url, headers=headers)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pytest
2+
from loguru import logger
3+
from utils.address import stake_public_key_to_address
4+
from utils.snapshot import snapshot
5+
from utils.auth_token import rbac_auth_token_factory
6+
from api.v1 import cardano
7+
8+
9+
@pytest.mark.skip("To be refactored when the api is ready")
10+
def test_persistent_ada_amount_endpoint(snapshot, rbac_auth_token_factory):
11+
# health.is_live()
12+
# health.is_ready()
13+
logger.info(f"{snapshot.network}, {snapshot.slot_no}")
14+
token = rbac_auth_token_factory()
15+
16+
total_len = len(snapshot.data)
17+
for i, entry in enumerate(snapshot.data):
18+
logger.info(f"Checking .... {round(i / total_len * 100, 1)}%")
19+
expected_amount = entry["voting_power"]
20+
stake_address = stake_public_key_to_address(
21+
key=entry["stake_public_key"][2:],
22+
is_stake=True,
23+
network_type=snapshot.network,
24+
)
25+
resp = cardano.assets(stake_address, snapshot.slot_no, token)
26+
if expected_amount == 0 and resp.status_code == 404:
27+
# it is possible that snapshot tool collected data for the stake key which does not have any unspent utxo
28+
# at this case cat-gateway return 404, that is why we are checking this case additionally
29+
continue
30+
31+
assert (
32+
resp.status_code == 200
33+
), f"Cannot find assets for stake_address: {stake_address}"
34+
assets = resp.json()
35+
if assets["persistent"]["ada_amount"] != expected_amount:
36+
logger.error(
37+
f"Not expected ada amount for stake_address: {stake_address}, {entry["stake_public_key"]}"
38+
)
39+
# assert (
40+
# assets["persistent"]["ada_amount"] == expected_amount
41+
# ), f"Not expected ada amount for stake_address: {stake_address}, {entry["stake_public_key"]}"

catalyst-gateway/tests/api_tests/integration/test_utxo.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)