@@ -1654,7 +1654,7 @@ mod fixed_rate_streams {
16541654 ) ;
16551655
16561656 // Set the last valid proof of the payment stream from Bob to Alice to block 123 (represented by Alice's account ID)
1657- // Since we are using the mocked ReadProofSubmittersInterface , we can pass the account ID as the
1657+ // Since we are using the mocked ProofSubmittersInterface , we can pass the account ID as the
16581658 // block number to the `on_poll` hook and it will consider that Provider as one that submitted a proof
16591659 run_to_block ( alice_on_poll) ;
16601660
@@ -1665,7 +1665,62 @@ mod fixed_rate_streams {
16651665 // The payment stream should be updated with the correct last valid proof
16661666 assert_eq ! (
16671667 alice_last_chargeable_info. last_chargeable_tick,
1668- System :: block_number( ) - 1 // We subtract one since the chargeable info is set for the previous block always
1668+ System :: block_number( )
1669+ ) ;
1670+ } ) ;
1671+ }
1672+
1673+ #[ test]
1674+ fn update_last_chargeable_tick_with_submitters_paused_works ( ) {
1675+ ExtBuilder :: build ( ) . execute_with ( || {
1676+ let alice_on_poll: AccountId = 123 ;
1677+ let bob: AccountId = 1 ;
1678+
1679+ // Register Alice as a MSP with 100 units of data and get her MSP ID
1680+ register_account_as_msp ( alice_on_poll, 100 ) ;
1681+ let alice_msp_id =
1682+ <StorageProviders as ReadProvidersInterface >:: get_provider_id ( alice_on_poll)
1683+ . unwrap ( ) ;
1684+
1685+ // Create a payment stream from Bob to Alice of 10 units per block
1686+ let rate: BalanceOf < Test > = 10 ;
1687+ assert_ok ! (
1688+ <PaymentStreams as PaymentStreamsInterface >:: create_fixed_rate_payment_stream(
1689+ & alice_msp_id,
1690+ & bob,
1691+ rate
1692+ )
1693+ ) ;
1694+
1695+ // Set the last valid proof of the payment stream from Bob to Alice to block 123 (represented by Alice's account ID)
1696+ // Since we are using the mocked ProofSubmittersInterface, we can pass the account ID as the
1697+ // block number to the `on_poll` hook and it will consider that Provider as one that submitted a proof.
1698+ // We advance to one block before Alice's turn.
1699+ run_to_block ( alice_on_poll - 1 ) ;
1700+
1701+ // Mock blocks advancing where the Proofs Submitters' tick is stopped.
1702+ let tick_before = crate :: OnPollTicker :: < Test > :: get ( ) ;
1703+ for _ in 0 ..10 {
1704+ // For that, we run `on_poll` hooks of this Payment Stream's pallet, without actually advancing blocks.
1705+ PaymentStreams :: on_poll ( System :: block_number ( ) , & mut WeightMeter :: new ( ) ) ;
1706+ }
1707+ let tick_after = crate :: OnPollTicker :: < Test > :: get ( ) ;
1708+ assert ! ( tick_before == tick_after - 10 ) ;
1709+
1710+ // Now the Proof Submitters pallet "resumes", so we advance one more block to when
1711+ // it is Alice's turn to be in the valid proofs submitters set.
1712+ run_to_block ( alice_on_poll) ;
1713+
1714+ // Get Alice's last chargeable information
1715+ let alice_last_chargeable_info =
1716+ PaymentStreams :: get_last_chargeable_info ( & alice_msp_id) ;
1717+ let current_tick = crate :: OnPollTicker :: < Test > :: get ( ) ;
1718+
1719+ // The payment stream should be updated and considering that the last chargeable tick
1720+ // is the current tick for the Payment Streams pallet.
1721+ assert_eq ! (
1722+ alice_last_chargeable_info. last_chargeable_tick,
1723+ current_tick
16691724 ) ;
16701725 } ) ;
16711726 }
0 commit comments