feat: Handle correct probing of genesis block (#57)
This commit is contained in:
parent
f09047482e
commit
5784ee6c4a
2 changed files with 13 additions and 0 deletions
1
pallas-primitives/src/byron/test_data/genesis.block
Normal file
1
pallas-primitives/src/byron/test_data/genesis.block
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -7,6 +7,7 @@ use crate::Era;
|
|||
#[derive(Debug)]
|
||||
pub enum Outcome {
|
||||
Matched(Era),
|
||||
GenesisBlock,
|
||||
Inconclusive,
|
||||
}
|
||||
|
||||
|
|
@ -22,6 +23,7 @@ pub fn probe_block_cbor_era(cbor: &[u8]) -> Outcome {
|
|||
|
||||
match tokenizer.next() {
|
||||
Some(Ok(Token::U8(variant))) => match variant {
|
||||
0 => Outcome::GenesisBlock,
|
||||
1 => Outcome::Matched(Era::Byron),
|
||||
2 => Outcome::Matched(Era::Shelley),
|
||||
3 => Outcome::Matched(Era::Allegra),
|
||||
|
|
@ -37,6 +39,16 @@ pub fn probe_block_cbor_era(cbor: &[u8]) -> Outcome {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn genesis_block_detected() {
|
||||
let block_str = include_str!("byron/test_data/genesis.block");
|
||||
let bytes = hex::decode(block_str).unwrap();
|
||||
|
||||
let inference = probe_block_cbor_era(bytes.as_slice());
|
||||
|
||||
assert!(matches!(inference, Outcome::GenesisBlock));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn byron_block_detected() {
|
||||
let block_str = include_str!("byron/test_data/test1.block");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue