Skip to content

Commit d806a59

Browse files
committed
fix: credit_balances does not exist anymore replaced by credit_history`
1 parent d96a6a8 commit d806a59

File tree

2 files changed

+24
-39
lines changed

2 files changed

+24
-39
lines changed

src/aleph/sdk/query/responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class CreditsHistoryResponse(PaginationResponse):
8787
"""Response from an aleph.im node API on the path /api/v0/credits"""
8888

8989
address: str
90-
credit_balances: List[CreditHistoryResponseItem]
90+
credit_history: List[CreditHistoryResponseItem]
9191
pagination_item: str = "credit_history"
9292

9393

tests/unit/test_credits.py

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,36 @@ async def test_get_credits_history():
1616
# Mock data for credit history
1717
credit_history_data = {
1818
"address": address,
19-
"credit_balances": [
19+
"credit_history": [
2020
{
21-
"amount": 1000,
22-
"ratio": 1.0,
23-
"tx_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
24-
"token": "ALEPH",
25-
"chain": "ETH",
26-
"provider": "gateway",
27-
"origin": "purchase",
28-
"origin_ref": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
29-
"payment_method": "token",
30-
"credit_ref": "init_credit_1",
31-
"credit_index": 1,
32-
"expiration_date": "2025-12-31T23:59:59Z",
33-
"message_timestamp": "2023-01-01T12:00:00Z",
34-
},
35-
{
36-
"amount": -100,
21+
"amount": -22,
3722
"ratio": None,
3823
"tx_hash": None,
3924
"token": None,
4025
"chain": None,
41-
"provider": "node1.aleph.im",
42-
"origin": "vm_usage",
43-
"origin_ref": "vm_instance_123456",
44-
"payment_method": None,
45-
"credit_ref": "vm_consumption_1",
46-
"credit_index": 2,
26+
"provider": "ALEPH",
27+
"origin": None,
28+
"origin_ref": "212f4825dd30e01f3801cdff1bdf8cd4d1c14ce2d31d695aee429d2ad0dfcba1",
29+
"payment_method": "credit_expense",
30+
"credit_ref": "cd77a7983af168941fd011427c6198b146ccd6f85077e0b593a4e7239d45fb11",
31+
"credit_index": 0,
4732
"expiration_date": None,
48-
"message_timestamp": "2023-01-15T14:30:00Z",
33+
"message_timestamp": "2025-09-30T06:57:26.106000Z",
4934
},
5035
{
51-
"amount": 500,
52-
"ratio": 0.8,
53-
"tx_hash": "0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba",
54-
"token": "ALEPH",
55-
"chain": "ETH",
56-
"provider": "gateway",
57-
"origin": "purchase",
58-
"origin_ref": "0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210",
59-
"payment_method": "token",
60-
"credit_ref": "add_credit_1",
61-
"credit_index": 3,
62-
"expiration_date": "2026-06-30T23:59:59Z",
63-
"message_timestamp": "2023-02-01T09:15:00Z",
36+
"amount": -22,
37+
"ratio": None,
38+
"tx_hash": None,
39+
"token": None,
40+
"chain": None,
41+
"provider": "ALEPH",
42+
"origin": None,
43+
"origin_ref": "36ceb85fb570fc87a6b906dc89df39129a971de96cbc56250553cfb8d49487e3",
44+
"payment_method": "credit_expense",
45+
"credit_ref": "5881c8f813ea186b25a9a20d9bea46e2082c4d61c2b9e7d53bf8a164dc892b73",
46+
"credit_index": 0,
47+
"expiration_date": None,
48+
"message_timestamp": "2025-09-30T02:57:07.673000Z",
6449
},
6550
],
6651
"pagination_page": 1,
@@ -87,4 +72,4 @@ async def test_get_credits_history():
8772
spy.assert_called_once_with(
8873
expected_url, params={"page": "1", "pagination": "200"}
8974
)
90-
assert len(response.credit_balances) == 3
75+
assert len(response.credit_history) == 2

0 commit comments

Comments
 (0)