Tests checking item sizes for changed types

This commit is contained in:
maciejhirsz 2017-01-30 20:01:32 +01:00
parent 6795068ea4
commit 681fa10d4b
5 changed files with 96 additions and 7 deletions

View File

@ -242,3 +242,21 @@ impl HeapSizeOf for BlockReceipts {
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();
}
}

View File

@ -215,6 +215,18 @@ mod tests {
use super::super::Step;
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]
fn encode_decode() {
let message = ConsensusMessage {

View File

@ -212,12 +212,28 @@ impl fmt::Display for CallError {
/// Transaction execution result.
pub type ExecutionResult = Result<Executed, ExecutionError>;
#[test]
fn should_encode_and_decode_call_type() {
use rlp;
#[cfg(test)]
mod tests {
use rlp::*;
use super::CallType;
let original = CallType::Call;
let encoded = rlp::encode(&original);
let decoded = rlp::decode(&encoded);
assert_eq!(original, decoded);
#[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]
fn should_encode_and_decode_call_type() {
let original = CallType::Call;
let encoded = encode(&original);
let decoded = decode(&encoded);
assert_eq!(original, decoded);
}
}

View File

@ -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();
}
}

View File

@ -162,10 +162,35 @@ impl Into<Vec<FlatTransactionTraces>> for FlatBlockTraces {
#[cfg(test)]
mod tests {
use rlp::*;
use super::{FlatBlockTraces, FlatTransactionTraces, FlatTrace};
use trace::trace::{Action, Res, CallResult, Call, Suicide};
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]
fn test_trace_serialization() {
// block #51921