mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
improve decode for UncheckedExtrinsic (#9646)
* improve decode for UncheckedExtrinsic * fmt
This commit is contained in:
@@ -26,7 +26,7 @@ use crate::{
|
||||
transaction_validity::{InvalidTransaction, TransactionValidityError},
|
||||
OpaqueExtrinsic,
|
||||
};
|
||||
use codec::{Decode, Encode, EncodeLike, Error, Input};
|
||||
use codec::{Compact, Decode, Encode, EncodeLike, Error, Input};
|
||||
use sp_io::hashing::blake2_256;
|
||||
use sp_std::{fmt, prelude::*};
|
||||
|
||||
@@ -203,7 +203,7 @@ where
|
||||
// with substrate's generic `Vec<u8>` type. Basically this just means accepting that there
|
||||
// will be a prefix of vector length (we don't need
|
||||
// to use this).
|
||||
let _length_do_not_remove_me_see_above: Vec<()> = Decode::decode(input)?;
|
||||
let _length_do_not_remove_me_see_above: Compact<u32> = Decode::decode(input)?;
|
||||
|
||||
let version = input.read_byte()?;
|
||||
|
||||
@@ -446,4 +446,13 @@ mod tests {
|
||||
let opaque_encoded = opaque.encode();
|
||||
assert_eq!(opaque_encoded, encoded);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn large_bad_prefix_should_work() {
|
||||
let encoded = Compact::<u32>::from(u32::MAX).encode();
|
||||
assert_eq!(
|
||||
Ex::decode(&mut &encoded[..]),
|
||||
Err(Error::from("Not enough data to fill buffer"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user