mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-14 01:35:50 +00:00
Half of tests fixed.
This commit is contained in:
@@ -67,6 +67,9 @@ impl Slicable for Digest {
|
||||
}
|
||||
}
|
||||
|
||||
/// The block "body": A bunch of transactions.
|
||||
pub type Body = Vec<UncheckedTransaction>;
|
||||
|
||||
/// A Polkadot relay chain block.
|
||||
#[derive(PartialEq, Eq, Clone)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
|
||||
@@ -74,7 +77,7 @@ pub struct Block {
|
||||
/// The block header.
|
||||
pub header: Header,
|
||||
/// All relay-chain transactions.
|
||||
pub transactions: Vec<UncheckedTransaction>,
|
||||
pub transactions: Body,
|
||||
}
|
||||
|
||||
impl Slicable for Block {
|
||||
@@ -165,7 +168,7 @@ mod tests {
|
||||
use super::*;
|
||||
use codec::Slicable;
|
||||
use substrate_serializer as ser;
|
||||
use parachain;
|
||||
use primitives::hexdisplay::HexDisplay;
|
||||
|
||||
#[test]
|
||||
fn test_header_serialization() {
|
||||
@@ -192,28 +195,4 @@ mod tests {
|
||||
let v = header.to_vec();
|
||||
assert_eq!(Header::from_slice(&mut &v[..]).unwrap(), header);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_body_serialization() {
|
||||
assert_eq!(ser::to_string_pretty(&Body {
|
||||
candidates: vec![
|
||||
parachain::Candidate {
|
||||
parachain_index: 10.into(),
|
||||
collator_signature: Default::default(),
|
||||
unprocessed_ingress: Default::default(),
|
||||
block: ::parachain::BlockData(vec![1, 3, 5, 8]),
|
||||
}
|
||||
],
|
||||
}), r#"{
|
||||
"candidates": [
|
||||
{
|
||||
"parachainIndex": 10,
|
||||
"collatorSignature": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"unprocessedIngress": [],
|
||||
"block": "0x01030508"
|
||||
}
|
||||
]
|
||||
}"#);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -290,8 +290,6 @@ impl Slicable for Transaction {
|
||||
// with substrate's generic `Vec<u8>` type. Basically this just means accepting that there
|
||||
// will be a prefix of u32, which has the total number of bytes following (we don't need
|
||||
// to use this).
|
||||
let _length_do_not_remove_me_see_above: u32 = try_opt!(Slicable::from_slice(value));
|
||||
|
||||
Some(Transaction {
|
||||
signed: try_opt!(Slicable::from_slice(value)),
|
||||
nonce: try_opt!(Slicable::from_slice(value)),
|
||||
@@ -380,9 +378,10 @@ impl fmt::Debug for UncheckedTransaction {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ::codec::Slicable;
|
||||
use primitives;
|
||||
use super::*;
|
||||
use primitives;
|
||||
use ::codec::Slicable;
|
||||
use primitives::hexdisplay::HexDisplay;
|
||||
|
||||
#[test]
|
||||
fn serialize_unchecked() {
|
||||
@@ -394,8 +393,15 @@ mod tests {
|
||||
},
|
||||
signature: primitives::hash::H512([0; 64]),
|
||||
};
|
||||
// 71000000
|
||||
// 0101010101010101010101010101010101010101010101010101010101010101
|
||||
// e703000000000000
|
||||
// 00
|
||||
// df0f0200
|
||||
// 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
let v = Slicable::to_vec(&tx);
|
||||
println!("{}", HexDisplay::from(&v));
|
||||
assert_eq!(UncheckedTransaction::from_slice(&mut &v[..]).unwrap(), tx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user