fix(primitives): Handle bytes indef in Plutus data (#143)
This commit is contained in:
parent
98f71289b5
commit
ad5ff362ad
3 changed files with 16 additions and 5 deletions
|
|
@ -944,7 +944,15 @@ impl<'b, C> minicbor::decode::Decode<'b, C> for PlutusData {
|
||||||
| minicbor::data::Type::I64 => Ok(Self::BigInt(d.decode_with(ctx)?)),
|
| minicbor::data::Type::I64 => Ok(Self::BigInt(d.decode_with(ctx)?)),
|
||||||
minicbor::data::Type::Map => Ok(Self::Map(d.decode_with(ctx)?)),
|
minicbor::data::Type::Map => Ok(Self::Map(d.decode_with(ctx)?)),
|
||||||
minicbor::data::Type::Bytes => Ok(Self::BoundedBytes(d.decode_with(ctx)?)),
|
minicbor::data::Type::Bytes => Ok(Self::BoundedBytes(d.decode_with(ctx)?)),
|
||||||
minicbor::data::Type::BytesIndef => Ok(Self::BoundedBytes(d.decode_with(ctx)?)),
|
minicbor::data::Type::BytesIndef => {
|
||||||
|
let mut full = Vec::new();
|
||||||
|
|
||||||
|
for slice in d.bytes_iter()? {
|
||||||
|
full.extend(slice?);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Self::BoundedBytes(ByteVec::from(full)))
|
||||||
|
}
|
||||||
minicbor::data::Type::Array => Ok(Self::Array(d.decode_with(ctx)?)),
|
minicbor::data::Type::Array => Ok(Self::Array(d.decode_with(ctx)?)),
|
||||||
minicbor::data::Type::ArrayIndef => Ok(Self::ArrayIndef(d.decode_with(ctx)?)),
|
minicbor::data::Type::ArrayIndef => Ok(Self::ArrayIndef(d.decode_with(ctx)?)),
|
||||||
|
|
||||||
|
|
@ -1340,7 +1348,7 @@ pub struct MintedBlock<'b> {
|
||||||
pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,
|
pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,
|
||||||
|
|
||||||
#[n(2)]
|
#[n(2)]
|
||||||
pub transaction_witness_sets: MaybeIndefArray<TransactionWitnessSet>,
|
pub transaction_witness_sets: MaybeIndefArray<KeepRaw<'b, TransactionWitnessSet>>,
|
||||||
|
|
||||||
#[n(3)]
|
#[n(3)]
|
||||||
pub auxiliary_data_set: KeyValuePairs<TransactionIndex, KeepRaw<'b, AuxiliaryData>>,
|
pub auxiliary_data_set: KeyValuePairs<TransactionIndex, KeepRaw<'b, AuxiliaryData>>,
|
||||||
|
|
@ -1370,7 +1378,7 @@ pub struct MintedTx<'b> {
|
||||||
pub transaction_body: KeepRaw<'b, TransactionBody>,
|
pub transaction_body: KeepRaw<'b, TransactionBody>,
|
||||||
|
|
||||||
#[n(1)]
|
#[n(1)]
|
||||||
pub transaction_witness_set: TransactionWitnessSet,
|
pub transaction_witness_set: KeepRaw<'b, TransactionWitnessSet>,
|
||||||
|
|
||||||
#[n(2)]
|
#[n(2)]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
|
|
@ -1429,6 +1437,8 @@ mod tests {
|
||||||
include_str!("../../../test_data/alonzo21.block"),
|
include_str!("../../../test_data/alonzo21.block"),
|
||||||
// peculiar block with bad tx hash
|
// peculiar block with bad tx hash
|
||||||
include_str!("../../../test_data/alonzo22.block"),
|
include_str!("../../../test_data/alonzo22.block"),
|
||||||
|
// peculiar block with indef byte array in plutus data
|
||||||
|
include_str!("../../../test_data/alonzo23.block"),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (idx, block_str) in test_blocks.iter().enumerate() {
|
for (idx, block_str) in test_blocks.iter().enumerate() {
|
||||||
|
|
|
||||||
|
|
@ -536,7 +536,7 @@ pub struct MintedBlock<'b> {
|
||||||
pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,
|
pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,
|
||||||
|
|
||||||
#[n(2)]
|
#[n(2)]
|
||||||
pub transaction_witness_sets: MaybeIndefArray<TransactionWitnessSet>,
|
pub transaction_witness_sets: MaybeIndefArray<KeepRaw<'b, TransactionWitnessSet>>,
|
||||||
|
|
||||||
#[n(3)]
|
#[n(3)]
|
||||||
pub auxiliary_data_set: KeyValuePairs<TransactionIndex, KeepRaw<'b, AuxiliaryData>>,
|
pub auxiliary_data_set: KeyValuePairs<TransactionIndex, KeepRaw<'b, AuxiliaryData>>,
|
||||||
|
|
@ -566,7 +566,7 @@ pub struct MintedTx<'b> {
|
||||||
pub transaction_body: KeepRaw<'b, TransactionBody>,
|
pub transaction_body: KeepRaw<'b, TransactionBody>,
|
||||||
|
|
||||||
#[n(1)]
|
#[n(1)]
|
||||||
pub transaction_witness_set: TransactionWitnessSet,
|
pub transaction_witness_set: KeepRaw<'b, TransactionWitnessSet>,
|
||||||
|
|
||||||
#[n(2)]
|
#[n(2)]
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
|
|
|
||||||
1
test_data/alonzo23.block
Normal file
1
test_data/alonzo23.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