Skip to content

Commit f758df5

Browse files
committed
fix: get_message_error now handle removing status and return the reason field
1 parent 8e3e766 commit f758df5

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

src/aleph/sdk/client/http.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ async def get_message_error(
465465
raise RemovedMessageError(
466466
f"The requested message {message_raw['item_hash']} has been removed by {', '.join(message_raw['reason'])}"
467467
)
468+
if message_raw["status"] == "removing":
469+
return {"reason": message_raw["reason"]}
468470
if message_raw["status"] != "rejected":
469471
return None
470472
return {

tests/unit/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ def rejected_message():
6868
return json.load(f)
6969

7070

71+
@pytest.fixture
72+
def removing_message():
73+
message_path = Path(__file__).parent / "removing_message.json"
74+
with open(message_path) as f:
75+
return json.load(f)
76+
77+
7178
@pytest.fixture
7279
def aleph_messages() -> List[AlephMessage]:
7380
return [

tests/unit/removing_message.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"status": "removing",
3+
"item_hash": "8315e613eae0651f698b5cdd17ae935597620bdba280d2154bed347d088072a1",
4+
"reception_time": "2025-08-30T02:18:59.708600Z",
5+
"message": {
6+
"sender": "0x759962fB336f88a18Fe098cf3C82e51e5131ca9A",
7+
"chain": "ETH",
8+
"signature": "0x1caa8a64723acbd80ef321fe0de8a355b2727dad000e49d5913d0d17eb0732d64f791f8126c385c0fb30ae47f027ccb4b469427d68f25d0e010b821821b0c25b1c",
9+
"type": "STORE",
10+
"item_content": "{\"address\":\"0x759962fB336f88a18Fe098cf3C82e51e5131ca9A\",\"time\":1756520339.1264179,\"item_type\":\"ipfs\",\"item_hash\":\"QmVQKFq7HsEREuns2GkFHGimGppFQeFokqyzZpj94Tx35r\"}",
11+
"item_type": "inline",
12+
"item_hash": "8315e613eae0651f698b5cdd17ae935597620bdba280d2154bed347d088072a1",
13+
"time": 1756520339.12647,
14+
"channel": "ALEPH-CLOUDSOLUTIONS",
15+
"content": {
16+
"address": "0x759962fB336f88a18Fe098cf3C82e51e5131ca9A",
17+
"time": 1756520339.12642,
18+
"item_type": "ipfs",
19+
"item_hash": "QmVQKFq7HsEREuns2GkFHGimGppFQeFokqyzZpj94Tx35r",
20+
"size": null,
21+
"content_type": null,
22+
"ref": null,
23+
"metadata": null
24+
},
25+
"confirmed": true,
26+
"confirmations": [
27+
{
28+
"chain": "ETH",
29+
"height": 23251108,
30+
"hash": "0xc91a41b40c1294280983c4d76f9d7496190bace8414b83fd651dc1710e1452e3"
31+
}
32+
]
33+
},
34+
"reason": "balance_insufficient"
35+
}

tests/unit/services/test_pricing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ async def test_get_pricing_aggregate(mock_client):
6868
storage_price = storage_entity.price["storage"]
6969
assert isinstance(storage_price, Price) # Add type assertion for mypy
7070
assert storage_price.holding == Decimal("0.333333333")
71-
assert storage_entity.price["storage"].holding == Decimal("0.333333333")
72-
7371
# Check program entity has correct compute unit details
7472
program_entity = result[PricingEntity.PROGRAM]
7573
assert isinstance(program_entity, PricingPerEntity)

tests/unit/test_asynchronous_get.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def test_get_forgotten_message():
8686

8787

8888
@pytest.mark.asyncio
89-
async def test_get_message_error(rejected_message):
89+
async def test_get_message_error_rejected(rejected_message):
9090
mock_session = make_mock_get_session(rejected_message)
9191
async with mock_session as session:
9292
error = await session.get_message_error(rejected_message["item_hash"])
@@ -95,5 +95,14 @@ async def test_get_message_error(rejected_message):
9595
assert error["details"] == rejected_message["details"]
9696

9797

98+
@pytest.mark.asyncio
99+
async def test_get_message_error_removing(removing_message):
100+
mock_session = make_mock_get_session(removing_message)
101+
async with mock_session as session:
102+
error = await session.get_message_error(removing_message["item_hash"])
103+
assert error
104+
assert error["reason"] == removing_message["reason"]
105+
106+
98107
if __name__ == "__main __":
99108
unittest.main()

0 commit comments

Comments
 (0)