fix: Handle undefined CBOR maps in Plutus data (#196)
This commit is contained in:
parent
74f8f38a92
commit
10c684a805
3 changed files with 12 additions and 3 deletions
|
|
@ -946,7 +946,9 @@ impl<'b, C> minicbor::decode::Decode<'b, C> for PlutusData {
|
||||||
| minicbor::data::Type::I16
|
| minicbor::data::Type::I16
|
||||||
| minicbor::data::Type::I32
|
| minicbor::data::Type::I32
|
||||||
| 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 | minicbor::data::Type::MapIndef => {
|
||||||
|
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 => {
|
minicbor::data::Type::BytesIndef => {
|
||||||
let mut full = Vec::new();
|
let mut full = Vec::new();
|
||||||
|
|
@ -1219,8 +1221,12 @@ impl<'b, C> minicbor::Decode<'b, C> for Metadatum {
|
||||||
}
|
}
|
||||||
minicbor::data::Type::Bytes => Ok(Metadatum::Bytes(d.decode_with(ctx)?)),
|
minicbor::data::Type::Bytes => Ok(Metadatum::Bytes(d.decode_with(ctx)?)),
|
||||||
minicbor::data::Type::String => Ok(Metadatum::Text(d.decode_with(ctx)?)),
|
minicbor::data::Type::String => Ok(Metadatum::Text(d.decode_with(ctx)?)),
|
||||||
minicbor::data::Type::Array => Ok(Metadatum::Array(d.decode_with(ctx)?)),
|
minicbor::data::Type::Array | minicbor::data::Type::ArrayIndef => {
|
||||||
minicbor::data::Type::Map => Ok(Metadatum::Map(d.decode_with(ctx)?)),
|
Ok(Metadatum::Array(d.decode_with(ctx)?))
|
||||||
|
}
|
||||||
|
minicbor::data::Type::Map | minicbor::data::Type::MapIndef => {
|
||||||
|
Ok(Metadatum::Map(d.decode_with(ctx)?))
|
||||||
|
}
|
||||||
_ => Err(minicbor::decode::Error::message(
|
_ => Err(minicbor::decode::Error::message(
|
||||||
"Can't turn data type into metadatum",
|
"Can't turn data type into metadatum",
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
|
|
@ -597,6 +597,8 @@ mod tests {
|
||||||
include_str!("../../../test_data/babbage4.block"),
|
include_str!("../../../test_data/babbage4.block"),
|
||||||
// peculiar block with i32 overlfow
|
// peculiar block with i32 overlfow
|
||||||
include_str!("../../../test_data/babbage5.block"),
|
include_str!("../../../test_data/babbage5.block"),
|
||||||
|
// peculiar block with map undef in plutus data
|
||||||
|
include_str!("../../../test_data/babbage6.block"),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (idx, block_str) in test_blocks.iter().enumerate() {
|
for (idx, block_str) in test_blocks.iter().enumerate() {
|
||||||
|
|
|
||||||
1
test_data/babbage6.block
Normal file
1
test_data/babbage6.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