mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-12 09:26:51 +00:00
Expand sanity checks
Substrate doesn't expect nor officially support children with less work than their parents. It's a trick used here. Accordingly, ensure the trick's validity.
This commit is contained in:
parent
b6dddc469f
commit
78fa292230
1 changed files with 10 additions and 1 deletions
|
@ -348,6 +348,7 @@ where
|
|||
let hash = block.hash();
|
||||
let (header, body) = block.clone().deconstruct();
|
||||
let parent = *header.parent_hash();
|
||||
let number = *header.number();
|
||||
*self.importing_block.write().unwrap() = Some(hash);
|
||||
self.queue.write().await.as_mut().unwrap().import_blocks(
|
||||
// We do not want this block, which hasn't been confirmed, to be broadcast over the net
|
||||
|
@ -372,7 +373,15 @@ where
|
|||
if !ImportFuture::new(hash, self.queue.write().await.as_mut().unwrap()).await {
|
||||
todo!()
|
||||
}
|
||||
assert_eq!(self.client.info().best_hash, parent);
|
||||
|
||||
// Sanity checks that a child block can have less work than its parent
|
||||
{
|
||||
let info = self.client.info();
|
||||
assert_eq!(info.best_hash, parent);
|
||||
assert_eq!(info.finalized_hash, parent);
|
||||
assert_eq!(info.best_number, number - 1);
|
||||
assert_eq!(info.finalized_number, number - 1);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue