fix(primitives): Fix decoding of empty Nonce hash (#67)
This commit is contained in:
parent
3b9c81e6a0
commit
90dfecd283
3 changed files with 10 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use net2::TcpStreamExt;
|
use net2::TcpStreamExt;
|
||||||
|
|
||||||
use pallas::{
|
use pallas::{
|
||||||
ledger::primitives::{alonzo::BlockWrapper, byron::Block, Fragment},
|
ledger::primitives::{byron::Block, Fragment},
|
||||||
network::{
|
network::{
|
||||||
miniprotocols::{
|
miniprotocols::{
|
||||||
blockfetch::{BatchClient, Observer},
|
blockfetch::{BatchClient, Observer},
|
||||||
|
|
@ -22,7 +22,7 @@ impl Observer for BlockPrinter {
|
||||||
println!("{}", hex::encode(&body));
|
println!("{}", hex::encode(&body));
|
||||||
println!("----------");
|
println!("----------");
|
||||||
|
|
||||||
let block = BlockWrapper::decode_fragment(body.as_slice()).unwrap();
|
let block = Block::decode_fragment(body.as_slice()).unwrap();
|
||||||
println!("{:?}", block);
|
println!("{:?}", block);
|
||||||
println!("===========\n\n");
|
println!("===========\n\n");
|
||||||
|
|
||||||
|
|
@ -45,13 +45,13 @@ fn main() {
|
||||||
|
|
||||||
let range = (
|
let range = (
|
||||||
Point::Specific(
|
Point::Specific(
|
||||||
16233554,
|
3240000,
|
||||||
hex::decode("02707620f06fbf6daf2e56848e1b881df1a2b7d3d7ecd53cffc55151858a1de1")
|
hex::decode("b7096a881f77ced24bdd285758646c0e059545b54855bd3a2307ece518bd6317")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
Point::Specific(
|
Point::Specific(
|
||||||
16233737,
|
4492794,
|
||||||
hex::decode("77a63ccd3b2b7a9f83686915884ff9c59aab4e00b12c92df46a904dc59e7b5fd")
|
hex::decode("5c196e7394ace0449ba5a51c919369699b13896e97432894b4f0354dce8670b6")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ pub struct Nonce {
|
||||||
pub variant: NonceVariant,
|
pub variant: NonceVariant,
|
||||||
|
|
||||||
#[n(1)]
|
#[n(1)]
|
||||||
pub hash: Hash<32>,
|
pub hash: Option<Hash<32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ScriptHash = ByteVec;
|
pub type ScriptHash = ByteVec;
|
||||||
|
|
@ -1424,6 +1424,8 @@ mod tests {
|
||||||
include_str!("test_data/test15.block"),
|
include_str!("test_data/test15.block"),
|
||||||
// peculiar block with protocol update values
|
// peculiar block with protocol update values
|
||||||
include_str!("test_data/test16.block"),
|
include_str!("test_data/test16.block"),
|
||||||
|
// peculiar block with missing nonce hash
|
||||||
|
include_str!("test_data/test17.block"),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (idx, block_str) in test_blocks.iter().enumerate() {
|
for (idx, block_str) in test_blocks.iter().enumerate() {
|
||||||
|
|
|
||||||
1
pallas-primitives/src/alonzo/test_data/test17.block
Normal file
1
pallas-primitives/src/alonzo/test_data/test17.block
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue