@@ -1319,14 +1319,44 @@ impl TestRig {
1319
1319
} ) ;
1320
1320
}
1321
1321
1322
- fn assert_sampling_request_status (
1323
- & self ,
1324
- block_root : Hash256 ,
1325
- ongoing : & Vec < ColumnIndex > ,
1326
- no_peers : & Vec < ColumnIndex > ,
1327
- ) {
1328
- self . sync_manager
1329
- . assert_sampling_request_status ( block_root, ongoing, no_peers)
1322
+ fn assert_sampling_request_ongoing ( & self , block_root : Hash256 , indices : & [ ColumnIndex ] ) {
1323
+ for index in indices {
1324
+ let status = self
1325
+ . sync_manager
1326
+ . get_sampling_request_status ( block_root, index)
1327
+ . unwrap_or_else ( || panic ! ( "No request state for {index}" ) ) ;
1328
+ if !matches ! ( status, crate :: sync:: peer_sampling:: Status :: Sampling { .. } ) {
1329
+ panic ! ( "expected {block_root} {index} request to be on going: {status:?}" ) ;
1330
+ }
1331
+ }
1332
+ }
1333
+
1334
+ fn assert_sampling_request_nopeers ( & self , block_root : Hash256 , indices : & [ ColumnIndex ] ) {
1335
+ for index in indices {
1336
+ let status = self
1337
+ . sync_manager
1338
+ . get_sampling_request_status ( block_root, index)
1339
+ . unwrap_or_else ( || panic ! ( "No request state for {index}" ) ) ;
1340
+ if !matches ! ( status, crate :: sync:: peer_sampling:: Status :: NoPeers { .. } ) {
1341
+ panic ! ( "expected {block_root} {index} request to be no peers: {status:?}" ) ;
1342
+ }
1343
+ }
1344
+ }
1345
+
1346
+ fn log_sampling_requests ( & self , block_root : Hash256 , indices : & [ ColumnIndex ] ) {
1347
+ let statuses = indices
1348
+ . iter ( )
1349
+ . map ( |index| {
1350
+ let status = self
1351
+ . sync_manager
1352
+ . get_sampling_request_status ( block_root, index)
1353
+ . unwrap_or_else ( || panic ! ( "No request state for {index}" ) ) ;
1354
+ ( index, status)
1355
+ } )
1356
+ . collect :: < Vec < _ > > ( ) ;
1357
+ self . log ( & format ! (
1358
+ "Sampling request status for {block_root}: {statuses:?}"
1359
+ ) ) ;
1330
1360
}
1331
1361
}
1332
1362
@@ -2099,7 +2129,7 @@ fn sampling_batch_requests() {
2099
2129
. pop ( )
2100
2130
. unwrap ( ) ;
2101
2131
assert_eq ! ( column_indexes. len( ) , SAMPLING_REQUIRED_SUCCESSES ) ;
2102
- r. assert_sampling_request_status ( block_root, & column_indexes, & vec ! [ ] ) ;
2132
+ r. assert_sampling_request_ongoing ( block_root, & column_indexes) ;
2103
2133
2104
2134
// Resolve the request.
2105
2135
r. complete_valid_sampling_column_requests (
@@ -2127,7 +2157,7 @@ fn sampling_batch_requests_not_enough_responses_returned() {
2127
2157
assert_eq ! ( column_indexes. len( ) , SAMPLING_REQUIRED_SUCCESSES ) ;
2128
2158
2129
2159
// The request status should be set to Sampling.
2130
- r. assert_sampling_request_status ( block_root, & column_indexes, & vec ! [ ] ) ;
2160
+ r. assert_sampling_request_ongoing ( block_root, & column_indexes) ;
2131
2161
2132
2162
// Split the indexes to simulate the case where the supernode doesn't have the requested column.
2133
2163
let ( _column_indexes_supernode_does_not_have, column_indexes_to_complete) =
@@ -2145,7 +2175,8 @@ fn sampling_batch_requests_not_enough_responses_returned() {
2145
2175
) ;
2146
2176
2147
2177
// The request status should be set to NoPeers since the supernode, the only peer, returned not enough responses.
2148
- r. assert_sampling_request_status ( block_root, & vec ! [ ] , & column_indexes) ;
2178
+ r. log_sampling_requests ( block_root, & column_indexes) ;
2179
+ r. assert_sampling_request_nopeers ( block_root, & column_indexes) ;
2149
2180
2150
2181
// The sampling request stalls.
2151
2182
r. expect_empty_network ( ) ;
0 commit comments