@@ -41,7 +41,7 @@ use sp_keyring::Sr25519Keyring;
4141use sp_keystore:: Keystore ;
4242use sp_tracing as _;
4343use statement_table:: v2:: Misbehavior ;
44- use std:: collections:: HashMap ;
44+ use std:: { collections:: HashMap , time :: Duration } ;
4545
4646mod prospective_parachains;
4747
@@ -80,6 +80,7 @@ struct TestState {
8080 head_data : HashMap < ParaId , HeadData > ,
8181 signing_context : SigningContext ,
8282 relay_parent : Hash ,
83+ disabled_validators : Vec < ValidatorIndex > ,
8384}
8485
8586impl TestState {
@@ -150,6 +151,7 @@ impl Default for TestState {
150151 validation_data,
151152 signing_context,
152153 relay_parent,
154+ disabled_validators : Vec :: new ( ) ,
153155 }
154156 }
155157}
@@ -296,7 +298,7 @@ async fn test_startup(virtual_overseer: &mut VirtualOverseer, test_state: &TestS
296298 AllMessages :: RuntimeApi (
297299 RuntimeApiMessage :: Request ( parent, RuntimeApiRequest :: DisabledValidators ( tx) )
298300 ) if parent == test_state. relay_parent => {
299- tx. send( Ok ( Vec :: new ( ) ) ) . unwrap( ) ;
301+ tx. send( Ok ( test_state . disabled_validators . clone ( ) ) ) . unwrap( ) ;
300302 }
301303 ) ;
302304}
@@ -2003,3 +2005,51 @@ fn new_leaf_view_doesnt_clobber_old() {
20032005 virtual_overseer
20042006 } ) ;
20052007}
2008+
2009+ // Test that a disabled local validator doesn't do any work on `CandidateBackingMessage::Second`
2010+ #[ test]
2011+ fn disabled_validator_doesnt_distribute_statement ( ) {
2012+ let mut test_state = TestState :: default ( ) ;
2013+ test_state. disabled_validators . push ( ValidatorIndex ( 0 ) ) ;
2014+
2015+ test_harness ( test_state. keystore . clone ( ) , |mut virtual_overseer| async move {
2016+ test_startup ( & mut virtual_overseer, & test_state) . await ;
2017+
2018+ let pov = PoV { block_data : BlockData ( vec ! [ 42 , 43 , 44 ] ) } ;
2019+ let pvd = dummy_pvd ( ) ;
2020+ let validation_code = ValidationCode ( vec ! [ 1 , 2 , 3 ] ) ;
2021+
2022+ let expected_head_data = test_state. head_data . get ( & test_state. chain_ids [ 0 ] ) . unwrap ( ) ;
2023+
2024+ let pov_hash = pov. hash ( ) ;
2025+ let candidate = TestCandidateBuilder {
2026+ para_id : test_state. chain_ids [ 0 ] ,
2027+ relay_parent : test_state. relay_parent ,
2028+ pov_hash,
2029+ head_data : expected_head_data. clone ( ) ,
2030+ erasure_root : make_erasure_root ( & test_state, pov. clone ( ) , pvd. clone ( ) ) ,
2031+ persisted_validation_data_hash : pvd. hash ( ) ,
2032+ validation_code : validation_code. 0 . clone ( ) ,
2033+ }
2034+ . build ( ) ;
2035+
2036+ let second = CandidateBackingMessage :: Second (
2037+ test_state. relay_parent ,
2038+ candidate. to_plain ( ) ,
2039+ pvd. clone ( ) ,
2040+ pov. clone ( ) ,
2041+ ) ;
2042+
2043+ virtual_overseer. send ( FromOrchestra :: Communication { msg : second } ) . await ;
2044+
2045+ // Ensure backing subsystem is not doing any work
2046+ assert_matches ! ( virtual_overseer. recv( ) . timeout( Duration :: from_secs( 1 ) ) . await , None ) ;
2047+
2048+ virtual_overseer
2049+ . send ( FromOrchestra :: Signal ( OverseerSignal :: ActiveLeaves (
2050+ ActiveLeavesUpdate :: stop_work ( test_state. relay_parent ) ,
2051+ ) ) )
2052+ . await ;
2053+ virtual_overseer
2054+ } ) ;
2055+ }
0 commit comments