@@ -21,7 +21,7 @@ use subxt::utils::H256;
21
21
/// <https://github.com/autonomys/subspace/releases/tag/runtime-mainnet-2025-jul-31>
22
22
///
23
23
/// TODO: turn this into a struct
24
- const SUDO_BLOCK : ( BlockNumber , RawBlockHash , ExtrinsicIndex , EventIndex , Slot ) = (
24
+ const SUDO_EXTRINSIC_BLOCK : ( BlockNumber , RawBlockHash , ExtrinsicIndex , EventIndex , Slot ) = (
25
25
3_795_487 ,
26
26
hex_literal:: hex!( "18c2f211b752cbc2f06943788ed011ab1fe64fb2e28ffcd1aeb4490c2e8b1baa" ) ,
27
27
5 ,
@@ -68,7 +68,7 @@ const LARGE_TRANSFER_BLOCKS: [(
68
68
clippy:: type_complexity,
69
69
reason = "this is a test, TODO: turn this into a struct"
70
70
) ]
71
- const IMPORTANT_ADDRESS_BLOCKS : [ (
71
+ const IMPORTANT_ADDRESS_TRANSFER_BLOCKS : [ (
72
72
BlockNumber ,
73
73
RawBlockHash ,
74
74
ExtrinsicIndex ,
@@ -134,6 +134,21 @@ const IMPORTANT_ADDRESS_BLOCKS: [(
134
134
) ,
135
135
] ;
136
136
137
+ /// Some extrinsics for important address alerts (which aren't any other higher
138
+ /// priority alert).
139
+ /// TODO: find an event sent by an important address, that isn't a higher priority alert.
140
+ const IMPORTANT_ADDRESS_ONLY_BLOCKS : [ ( BlockNumber , RawBlockHash , ExtrinsicIndex , & str , Slot ) ; 1 ] = [
141
+ // <https://autonomys.subscan.io/account/subKQqsYRyVkugvKQqLXEuhsefa9728PBAqtwxpeM5N4VD6mv>
142
+ (
143
+ 3_497_809 ,
144
+ hex_literal:: hex!( "bfa548573d1ff035e2009fdaa68499fe74c4ab30a775f5eb35624fdb9f95dc91" ) ,
145
+ // <https://autonomys.subscan.io/extrinsic/3497809-9>
146
+ 9 ,
147
+ "Sudo" ,
148
+ Slot ( 21_070_789 ) ,
149
+ ) ,
150
+ ] ;
151
+
137
152
// TODO: force transfer blocks:
138
153
// Failed force_transfer: <https://autonomys.subscan.io/extrinsic/2173351-7>
139
154
// Failed force_set_balance: <https://autonomys.subscan.io/extrinsic/1154587-11>
@@ -177,11 +192,15 @@ async fn test_sudo_alerts() -> anyhow::Result<()> {
177
192
let ( subspace_client, _, alert_tx, mut alert_rx, update_task) =
178
193
test_setup ( node_rpc_url ( ) ) . await ?;
179
194
180
- let ( block_info, extrinsics, events) =
181
- fetch_block_info ( & subspace_client, H256 :: from ( SUDO_BLOCK . 1 ) , SUDO_BLOCK . 0 ) . await ?;
195
+ let ( block_info, extrinsics, events) = fetch_block_info (
196
+ & subspace_client,
197
+ H256 :: from ( SUDO_EXTRINSIC_BLOCK . 1 ) ,
198
+ SUDO_EXTRINSIC_BLOCK . 0 ,
199
+ )
200
+ . await ?;
182
201
183
202
let ( extrinsic, extrinsic_info) =
184
- decode_extrinsic ( & block_info, & extrinsics, SUDO_BLOCK . 2 ) . await ?;
203
+ decode_extrinsic ( & block_info, & extrinsics, SUDO_EXTRINSIC_BLOCK . 2 ) . await ?;
185
204
186
205
alerts:: check_extrinsic ( BlockCheckMode :: Replay , & alert_tx, & extrinsic, & block_info) . await ?;
187
206
let alert = alert_rx. try_recv ( ) . expect ( "no alert received" ) ;
@@ -201,7 +220,7 @@ async fn test_sudo_alerts() -> anyhow::Result<()> {
201
220
Some ( ( "Sudo" , "sudo" ) )
202
221
) ;
203
222
204
- let ( event, event_info) = decode_event ( & block_info, & events, SUDO_BLOCK . 3 ) . await ?;
223
+ let ( event, event_info) = decode_event ( & block_info, & events, SUDO_EXTRINSIC_BLOCK . 3 ) . await ?;
205
224
206
225
alerts:: check_event ( BlockCheckMode :: Replay , & alert_tx, & event, & block_info) . await ?;
207
226
let alert = alert_rx. try_recv ( ) . expect ( "no alert received" ) ;
@@ -226,7 +245,7 @@ async fn test_sudo_alerts() -> anyhow::Result<()> {
226
245
. expect_err ( "alert received when none expected" ) ;
227
246
228
247
// Check block slot parsing works on a known slot value.
229
- assert_eq ! ( alert. block_info. slot, Some ( SUDO_BLOCK . 4 ) ) ;
248
+ assert_eq ! ( alert. block_info. slot, Some ( SUDO_EXTRINSIC_BLOCK . 4 ) ) ;
230
249
231
250
let result = update_task. now_or_never ( ) ;
232
251
assert ! (
@@ -303,9 +322,9 @@ async fn test_large_balance_transfer_alerts() -> anyhow::Result<()> {
303
322
Ok ( ( ) )
304
323
}
305
324
306
- /// Check that the important address alert works on known important address blocks.
325
+ /// Check that important address transfer alerts work on known important address transfer blocks.
307
326
#[ tokio:: test( flavor = "multi_thread" ) ]
308
- async fn test_important_address_alerts ( ) -> anyhow:: Result < ( ) > {
327
+ async fn test_important_address_transfer_alerts ( ) -> anyhow:: Result < ( ) > {
309
328
let ( subspace_client, _, alert_tx, mut alert_rx, update_task) =
310
329
test_setup ( node_rpc_url ( ) ) . await ?;
311
330
@@ -318,7 +337,7 @@ async fn test_important_address_alerts() -> anyhow::Result<()> {
318
337
extrinsic_transfer_value,
319
338
event_transfer_value,
320
339
slot,
321
- ) in IMPORTANT_ADDRESS_BLOCKS
340
+ ) in IMPORTANT_ADDRESS_TRANSFER_BLOCKS
322
341
{
323
342
let ( block_info, extrinsics, events) =
324
343
fetch_block_info ( & subspace_client, H256 :: from ( block_hash) , block_number) . await ?;
@@ -410,6 +429,53 @@ async fn test_important_address_alerts() -> anyhow::Result<()> {
410
429
Ok ( ( ) )
411
430
}
412
431
432
+ /// Check that the important address alert works on known important address blocks.
433
+ #[ tokio:: test( flavor = "multi_thread" ) ]
434
+ async fn test_important_address_only_alerts ( ) -> anyhow:: Result < ( ) > {
435
+ let ( subspace_client, _, alert_tx, mut alert_rx, update_task) =
436
+ test_setup ( node_rpc_url ( ) ) . await ?;
437
+
438
+ for ( block_number, block_hash, extrinsic_index, address_kind, slot) in
439
+ IMPORTANT_ADDRESS_ONLY_BLOCKS
440
+ {
441
+ let ( block_info, extrinsics, _events) =
442
+ fetch_block_info ( & subspace_client, H256 :: from ( block_hash) , block_number) . await ?;
443
+
444
+ let ( extrinsic, extrinsic_info) =
445
+ decode_extrinsic ( & block_info, & extrinsics, extrinsic_index) . await ?;
446
+
447
+ alerts:: check_extrinsic ( BlockCheckMode :: Replay , & alert_tx, & extrinsic, & block_info) . await ?;
448
+ let alert = alert_rx. try_recv ( ) . expect ( "no extrinsic alert received" ) ;
449
+
450
+ assert_eq ! (
451
+ alert,
452
+ Alert :: new(
453
+ AlertKind :: ImportantAddressExtrinsic {
454
+ address_kind: address_kind. to_string( ) ,
455
+ extrinsic_info: extrinsic_info. clone( ) ,
456
+ } ,
457
+ block_info,
458
+ BlockCheckMode :: Replay ,
459
+ )
460
+ ) ;
461
+
462
+ alert_rx
463
+ . try_recv ( )
464
+ . expect_err ( "alert received when none expected" ) ;
465
+
466
+ // Check block slot parsing works on a known slot value.
467
+ assert_eq ! ( alert. block_info. slot, Some ( slot) ) ;
468
+ }
469
+
470
+ let result = update_task. now_or_never ( ) ;
471
+ assert ! (
472
+ result. is_none( ) ,
473
+ "metadata update task exited unexpectedly with: {result:?}"
474
+ ) ;
475
+
476
+ Ok ( ( ) )
477
+ }
478
+
413
479
/// Check that the slot time alert is not triggered when the time per slot is below the threshold.
414
480
#[ tokio:: test( flavor = "multi_thread" ) ]
415
481
async fn no_expected_test_slot_time_alert ( ) -> anyhow:: Result < ( ) > {
0 commit comments