Skip to content

Commit 49d27a3

Browse files
committed
Tests
1 parent b98d4cb commit 49d27a3

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/integration_tests/test_async_substrate_interface.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,20 @@ async def test_fully_exhaust_query_map():
115115
fully_exhausted_records_count += 1
116116
assert fully_exhausted_records_count == initial_records_count_fully_exhaust
117117
assert initial_records_count_fully_exhaust == exhausted_records_count
118+
119+
120+
@pytest.mark.asyncio
121+
async def test_get_events_proper_decoding():
122+
# known block/hash pair that has the events we seek to decode
123+
block = 5846788
124+
block_hash = "0x0a1c45063a59b934bfee827caa25385e60d5ec1fd8566a58b5cc4affc4eec412"
125+
126+
async with AsyncSubstrateInterface(ARCHIVE_ENTRYPOINT) as substrate:
127+
all_events = await substrate.get_events(block_hash=block_hash)
128+
event = all_events[1]
129+
print(type(event["attributes"]))
130+
assert event["attributes"] == (
131+
"5G1NjW9YhXLadMWajvTkfcJy6up3yH2q1YzMXDTi6ijanChe",
132+
30,
133+
"0xa6b4e5c8241d60ece0c25056b19f7d21ae845269fc771ad46bf3e011865129a5",
134+
)

tests/integration_tests/test_substrate_interface.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,19 @@ def test_ss58_conversion():
6868
if len(value.value) > 0:
6969
for decoded_key in value.value:
7070
assert isinstance(decoded_key, str)
71+
72+
73+
def test_get_events_proper_decoding():
74+
# known block/hash pair that has the events we seek to decode
75+
block = 5846788
76+
block_hash = "0x0a1c45063a59b934bfee827caa25385e60d5ec1fd8566a58b5cc4affc4eec412"
77+
78+
with SubstrateInterface(ARCHIVE_ENTRYPOINT) as substrate:
79+
all_events = substrate.get_events(block_hash=block_hash)
80+
event = all_events[1]
81+
print(type(event["attributes"]))
82+
assert event["attributes"] == (
83+
"5G1NjW9YhXLadMWajvTkfcJy6up3yH2q1YzMXDTi6ijanChe",
84+
30,
85+
"0xa6b4e5c8241d60ece0c25056b19f7d21ae845269fc771ad46bf3e011865129a5",
86+
)

0 commit comments

Comments
 (0)