Tests checking item sizes for changed types
This commit is contained in:
parent
6795068ea4
commit
681fa10d4b
@ -242,3 +242,21 @@ impl HeapSizeOf for BlockReceipts {
|
|||||||
self.receipts.heap_size_of_children()
|
self.receipts.heap_size_of_children()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use rlp::*;
|
||||||
|
use super::BlockReceipts;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_block_receipts() {
|
||||||
|
let br = BlockReceipts::new(Vec::new());
|
||||||
|
|
||||||
|
let mut s = RlpStream::new_list(2);
|
||||||
|
s.append(&br);
|
||||||
|
assert!(!s.is_finished(), "List shouldn't finished yet");
|
||||||
|
s.append(&br);
|
||||||
|
assert!(s.is_finished(), "List should be finished now");
|
||||||
|
s.out();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -215,6 +215,18 @@ mod tests {
|
|||||||
use super::super::Step;
|
use super::super::Step;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_step() {
|
||||||
|
let step = Step::Precommit;
|
||||||
|
|
||||||
|
let mut s = RlpStream::new_list(2);
|
||||||
|
s.append(&step);
|
||||||
|
assert!(!s.is_finished(), "List shouldn't finished yet");
|
||||||
|
s.append(&step);
|
||||||
|
assert!(s.is_finished(), "List should be finished now");
|
||||||
|
s.out();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn encode_decode() {
|
fn encode_decode() {
|
||||||
let message = ConsensusMessage {
|
let message = ConsensusMessage {
|
||||||
|
@ -212,12 +212,28 @@ impl fmt::Display for CallError {
|
|||||||
/// Transaction execution result.
|
/// Transaction execution result.
|
||||||
pub type ExecutionResult = Result<Executed, ExecutionError>;
|
pub type ExecutionResult = Result<Executed, ExecutionError>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use rlp::*;
|
||||||
|
use super::CallType;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_call_type() {
|
||||||
|
let ct = CallType::Call;
|
||||||
|
|
||||||
|
let mut s = RlpStream::new_list(2);
|
||||||
|
s.append(&ct);
|
||||||
|
assert!(!s.is_finished(), "List shouldn't finished yet");
|
||||||
|
s.append(&ct);
|
||||||
|
assert!(s.is_finished(), "List should be finished now");
|
||||||
|
s.out();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_encode_and_decode_call_type() {
|
fn should_encode_and_decode_call_type() {
|
||||||
use rlp;
|
|
||||||
|
|
||||||
let original = CallType::Call;
|
let original = CallType::Call;
|
||||||
let encoded = rlp::encode(&original);
|
let encoded = encode(&original);
|
||||||
let decoded = rlp::decode(&encoded);
|
let decoded = decode(&encoded);
|
||||||
assert_eq!(original, decoded);
|
assert_eq!(original, decoded);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -98,3 +98,21 @@ impl Decodable for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use rlp::*;
|
||||||
|
use super::Error;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_error() {
|
||||||
|
let err = Error::BadJumpDestination;
|
||||||
|
|
||||||
|
let mut s = RlpStream::new_list(2);
|
||||||
|
s.append(&err);
|
||||||
|
assert!(!s.is_finished(), "List shouldn't finished yet");
|
||||||
|
s.append(&err);
|
||||||
|
assert!(s.is_finished(), "List should be finished now");
|
||||||
|
s.out();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -162,10 +162,35 @@ impl Into<Vec<FlatTransactionTraces>> for FlatBlockTraces {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use rlp::*;
|
||||||
use super::{FlatBlockTraces, FlatTransactionTraces, FlatTrace};
|
use super::{FlatBlockTraces, FlatTransactionTraces, FlatTrace};
|
||||||
use trace::trace::{Action, Res, CallResult, Call, Suicide};
|
use trace::trace::{Action, Res, CallResult, Call, Suicide};
|
||||||
use types::executed::CallType;
|
use types::executed::CallType;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_flat_transaction_traces() {
|
||||||
|
let ftt = FlatTransactionTraces::from(Vec::new());
|
||||||
|
|
||||||
|
let mut s = RlpStream::new_list(2);
|
||||||
|
s.append(&ftt);
|
||||||
|
assert!(!s.is_finished(), "List shouldn't finished yet");
|
||||||
|
s.append(&ftt);
|
||||||
|
assert!(s.is_finished(), "List should be finished now");
|
||||||
|
s.out();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn encode_flat_block_traces() {
|
||||||
|
let fbt = FlatBlockTraces::from(Vec::new());
|
||||||
|
|
||||||
|
let mut s = RlpStream::new_list(2);
|
||||||
|
s.append(&fbt);
|
||||||
|
assert!(!s.is_finished(), "List shouldn't finished yet");
|
||||||
|
s.append(&fbt);
|
||||||
|
assert!(s.is_finished(), "List should be finished now");
|
||||||
|
s.out();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trace_serialization() {
|
fn test_trace_serialization() {
|
||||||
// block #51921
|
// block #51921
|
||||||
|
Loading…
Reference in New Issue
Block a user