mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Keep sessions in window for the full unfinalized chain (#6054)
* Impl dynamic window size. Keep sessions for unfinalized chain Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Stretch also in contructor plus tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * review feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix approval-voting tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * grunting: dispute coordinator tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -1296,6 +1296,38 @@ pub(crate) mod tests {
|
||||
}
|
||||
);
|
||||
|
||||
// Caching of sesssions needs sessoion of first unfinalied block.
|
||||
assert_matches!(
|
||||
handle.recv().await,
|
||||
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber(
|
||||
s_tx,
|
||||
)) => {
|
||||
let _ = s_tx.send(Ok(header.number));
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
handle.recv().await,
|
||||
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash(
|
||||
block_number,
|
||||
s_tx,
|
||||
)) => {
|
||||
assert_eq!(block_number, header.number);
|
||||
let _ = s_tx.send(Ok(Some(header.hash())));
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
handle.recv().await,
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
h,
|
||||
RuntimeApiRequest::SessionIndexForChild(s_tx),
|
||||
)) => {
|
||||
assert_eq!(h, header.hash());
|
||||
let _ = s_tx.send(Ok(session));
|
||||
}
|
||||
);
|
||||
|
||||
// determine_new_blocks exits early as the parent_hash is in the DB
|
||||
|
||||
assert_matches!(
|
||||
|
||||
@@ -807,6 +807,37 @@ async fn import_block(
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
overseer_recv(overseer).await,
|
||||
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber(
|
||||
s_tx,
|
||||
)) => {
|
||||
let _ = s_tx.send(Ok(number));
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
overseer_recv(overseer).await,
|
||||
AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash(
|
||||
block_number,
|
||||
s_tx,
|
||||
)) => {
|
||||
assert_eq!(block_number, number);
|
||||
let _ = s_tx.send(Ok(Some(hashes[number as usize].0)));
|
||||
}
|
||||
);
|
||||
|
||||
assert_matches!(
|
||||
overseer_recv(overseer).await,
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
h,
|
||||
RuntimeApiRequest::SessionIndexForChild(s_tx),
|
||||
)) => {
|
||||
assert_eq!(h, hashes[number as usize].0);
|
||||
let _ = s_tx.send(Ok(number.into()));
|
||||
}
|
||||
);
|
||||
|
||||
if !fork {
|
||||
assert_matches!(
|
||||
overseer_recv(overseer).await,
|
||||
|
||||
Reference in New Issue
Block a user