mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 01:57:56 +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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate substrate_runtime_std as rstd;
|
||||
|
||||
#[macro_use]
|
||||
|
||||
@@ -189,9 +189,7 @@ mod tests {
|
||||
|
||||
// Block 1: Make proposal. Approve it. Era length changes.
|
||||
with_env(|e| e.block_number = 1);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
public::approve(&two, 1);
|
||||
staking::internal::check_new_era();
|
||||
assert_eq!(staking::era_length(), 2);
|
||||
@@ -214,17 +212,13 @@ mod tests {
|
||||
|
||||
// Block 1: Make proposal. Fail it.
|
||||
with_env(|e| e.block_number = 1);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
staking::internal::check_new_era();
|
||||
assert_eq!(staking::era_length(), 1);
|
||||
|
||||
// Block 2: Make proposal. Approve it. It should change era length.
|
||||
with_env(|e| e.block_number = 2);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
public::approve(&two, 2);
|
||||
staking::internal::check_new_era();
|
||||
assert_eq!(staking::era_length(), 2);
|
||||
@@ -247,9 +241,7 @@ mod tests {
|
||||
|
||||
// Block 1: Make proposal. Will have only 1 vote. No change.
|
||||
with_env(|e| e.block_number = 1);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
staking::internal::check_new_era();
|
||||
assert_eq!(staking::era_length(), 1);
|
||||
});
|
||||
@@ -272,9 +264,7 @@ mod tests {
|
||||
|
||||
// Block 1: Make proposal. Will have only 1 vote. No change.
|
||||
with_env(|e| e.block_number = 1);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
public::approve(&two, 0);
|
||||
staking::internal::check_new_era();
|
||||
assert_eq!(staking::era_length(), 1);
|
||||
@@ -298,9 +288,7 @@ mod tests {
|
||||
|
||||
// Block 1: Make proposal. Will have only 1 vote. No change.
|
||||
with_env(|e| e.block_number = 1);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
public::approve(&two, 1);
|
||||
public::approve(&two, 1);
|
||||
staking::internal::check_new_era();
|
||||
@@ -325,12 +313,8 @@ mod tests {
|
||||
|
||||
// Block 1: Make proposal. Will have only 1 vote. No change.
|
||||
with_env(|e| e.block_number = 1);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&two, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
public::propose(&two, &Proposal::StakingSetSessionsPerEra(2));
|
||||
staking::internal::check_new_era();
|
||||
assert_eq!(staking::era_length(), 1);
|
||||
});
|
||||
@@ -377,9 +361,7 @@ mod tests {
|
||||
|
||||
// Block 1: Make proposal. Will have only 1 vote. No change.
|
||||
with_env(|e| e.block_number = 1);
|
||||
public::propose(&one, &Proposal {
|
||||
function: Proposal::StakingSetSessionsPerEra(2),
|
||||
});
|
||||
public::propose(&one, &Proposal::StakingSetSessionsPerEra(2));
|
||||
public::approve(&four, 1);
|
||||
staking::internal::check_new_era();
|
||||
assert_eq!(staking::era_length(), 1);
|
||||
|
||||
@@ -338,12 +338,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn proposals_can_be_stored() {
|
||||
use polkadot_primitives::{Proposal, InternalFunction};
|
||||
use polkadot_primitives::Proposal;
|
||||
let mut t = TestExternalities { storage: HashMap::new(), };
|
||||
with_externalities(&mut t, || {
|
||||
let x = Proposal {
|
||||
function: InternalFunction::StakingSetSessionsPerEra(25519),
|
||||
};
|
||||
let x = Proposal::StakingSetSessionsPerEra(25519);
|
||||
put(b":test", &x);
|
||||
let y: Proposal = get(b":test").unwrap();
|
||||
assert_eq!(x, y);
|
||||
|
||||
Reference in New Issue
Block a user