fix: back-merge v0.18.1 hotfix (#254)

This commit is contained in:
Santiago Carmuega 2023-04-28 02:24:09 +02:00 committed by GitHub
parent 09f2bf3d26
commit a4bf887f28
3 changed files with 17 additions and 1 deletions

View file

@ -129,6 +129,8 @@ pub enum Value {
impl<'b, C> minicbor::decode::Decode<'b, C> for Value {
fn decode(d: &mut minicbor::Decoder<'b>, ctx: &mut C) -> Result<Self, minicbor::decode::Error> {
match d.datatype()? {
minicbor::data::Type::U8 => Ok(Value::Coin(d.decode_with(ctx)?)),
minicbor::data::Type::U16 => Ok(Value::Coin(d.decode_with(ctx)?)),
minicbor::data::Type::U32 => Ok(Value::Coin(d.decode_with(ctx)?)),
minicbor::data::Type::U64 => Ok(Value::Coin(d.decode_with(ctx)?)),
minicbor::data::Type::Array => {

View file

@ -738,7 +738,8 @@ impl<'b> From<MintedTx<'b>> for Tx {
mod tests {
use pallas_codec::minicbor;
use super::MintedBlock;
use super::{MintedBlock, TransactionOutput};
use crate::Fragment;
type BlockWrapper<'b> = (u16, MintedBlock<'b>);
@ -775,4 +776,16 @@ mod tests {
assert!(bytes.eq(&bytes2), "re-encoded bytes didn't match original");
}
}
#[test]
fn fragments_decoding() {
// peculiar array of outputs used in an hydra transaction
let hex = include_str!("../../../test_data/babbage1.fr");
let bytes = hex::decode(hex).unwrap();
let outputs = Vec::<TransactionOutput>::decode_fragment(&bytes).unwrap();
dbg!(outputs);
// add any loose fragment tests here
}
}