tests for log serialization

This commit is contained in:
debris 2016-02-17 14:45:25 +01:00
parent c74c016ce2
commit 68d546ce02
2 changed files with 31 additions and 1 deletions

View File

@ -210,7 +210,6 @@ impl Eth for EthClient {
}
}
/// Eth filter rpc implementation.
pub struct EthFilterClient {
client: Arc<Client>

View File

@ -50,3 +50,34 @@ impl From<LocalizedLogEntry> for Log {
}
}
}
#[cfg(test)]
mod tests {
use serde_json;
use std::str::FromStr;
use util::hash::*;
use util::uint::*;
use v1::types::{Bytes, Log};
#[test]
fn log_serialization() {
let s = r#"{"address":"0x33990122638b9132ca29c723bdf037f1a891a70c","topics":["0xa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc","0x4861736852656700000000000000000000000000000000000000000000000000"],"data":"0x","blockHash":"0xed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5","blockNumber":"0x04510c","transactionHash":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionIndex":"0x00","logIndex":"0x01"}"#;
let log = Log {
address: Address::from_str("33990122638b9132ca29c723bdf037f1a891a70c").unwrap(),
topics: vec![
H256::from_str("a6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc").unwrap(),
H256::from_str("4861736852656700000000000000000000000000000000000000000000000000").unwrap()
],
data: Bytes::new(vec![]),
block_hash: H256::from_str("ed76641c68a1c641aee09a94b3b471f4dc0316efe5ac19cf488e2674cf8d05b5").unwrap(),
block_number: U256::from(0x4510c),
transaction_hash: H256::new(),
transaction_index: U256::zero(),
log_index: U256::one()
};
let serialized = serde_json::to_string(&log).unwrap();
assert_eq!(serialized, s);
}
}