mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Refactor out external parts to generics
Also creates a dedicated file for the message log.
This commit is contained in:
29
substrate/tendermint/tests/ext.rs
Normal file
29
substrate/tendermint/tests/ext.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use tendermint_machine::ext::{BlockError, Block, Network};
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
struct TestBlock {
|
||||
id: u32,
|
||||
valid: Result<(), BlockError>,
|
||||
}
|
||||
|
||||
impl Block for TestBlock {
|
||||
type Id = u32;
|
||||
|
||||
fn id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
struct TestNetwork;
|
||||
impl Network<u16, TestBlock> for TestNetwork {
|
||||
fn total_weight(&self) -> u64 {
|
||||
5
|
||||
}
|
||||
fn weight(&self, id: u16) -> u64 {
|
||||
[1, 1, 1, 1, 1][usize::try_from(id).unwrap()]
|
||||
}
|
||||
|
||||
fn validate(&mut self, block: TestBlock) -> Result<(), BlockError> {
|
||||
block.valid
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user