Reformat the source code
This commit is contained in:
@@ -16,10 +16,8 @@
|
||||
|
||||
//! Transaction test deserialization.
|
||||
|
||||
mod test;
|
||||
mod transaction;
|
||||
mod txtest;
|
||||
mod test;
|
||||
|
||||
pub use self::transaction::Transaction;
|
||||
pub use self::txtest::TransactionTest;
|
||||
pub use self::test::Test;
|
||||
pub use self::{test::Test, transaction::Transaction, txtest::TransactionTest};
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
//! TransactionTest test deserializer.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::Read;
|
||||
use serde_json;
|
||||
use serde_json::Error;
|
||||
use serde_json::{self, Error};
|
||||
use std::{collections::BTreeMap, io::Read};
|
||||
use transaction::TransactionTest;
|
||||
|
||||
/// TransactionTest test deserializer.
|
||||
@@ -27,17 +25,20 @@ use transaction::TransactionTest;
|
||||
pub struct Test(BTreeMap<String, TransactionTest>);
|
||||
|
||||
impl IntoIterator for Test {
|
||||
type Item = <BTreeMap<String, TransactionTest> as IntoIterator>::Item;
|
||||
type IntoIter = <BTreeMap<String, TransactionTest> as IntoIterator>::IntoIter;
|
||||
type Item = <BTreeMap<String, TransactionTest> as IntoIterator>::Item;
|
||||
type IntoIter = <BTreeMap<String, TransactionTest> as IntoIterator>::IntoIter;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.into_iter()
|
||||
}
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl Test {
|
||||
/// Loads test from json.
|
||||
pub fn load<R>(reader: R) -> Result<Self, Error> where R: Read {
|
||||
serde_json::from_reader(reader)
|
||||
}
|
||||
/// Loads test from json.
|
||||
pub fn load<R>(reader: R) -> Result<Self, Error>
|
||||
where
|
||||
R: Read,
|
||||
{
|
||||
serde_json::from_reader(reader)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,43 +16,43 @@
|
||||
|
||||
//! Transaction test transaction deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use maybe::MaybeEmpty;
|
||||
use uint::Uint;
|
||||
|
||||
/// Transaction test transaction deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Transaction {
|
||||
/// Transaction data.
|
||||
pub data: Bytes,
|
||||
/// Gas limit.
|
||||
pub gas_limit: Uint,
|
||||
/// Gas price.
|
||||
pub gas_price: Uint,
|
||||
/// Nonce.
|
||||
pub nonce: Uint,
|
||||
/// To.
|
||||
pub to: MaybeEmpty<Address>,
|
||||
/// Value.
|
||||
pub value: Uint,
|
||||
/// R.
|
||||
pub r: Uint,
|
||||
/// S.
|
||||
pub s: Uint,
|
||||
/// V.
|
||||
pub v: Uint,
|
||||
/// Transaction data.
|
||||
pub data: Bytes,
|
||||
/// Gas limit.
|
||||
pub gas_limit: Uint,
|
||||
/// Gas price.
|
||||
pub gas_price: Uint,
|
||||
/// Nonce.
|
||||
pub nonce: Uint,
|
||||
/// To.
|
||||
pub to: MaybeEmpty<Address>,
|
||||
/// Value.
|
||||
pub value: Uint,
|
||||
/// R.
|
||||
pub r: Uint,
|
||||
/// S.
|
||||
pub s: Uint,
|
||||
/// V.
|
||||
pub v: Uint,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use transaction::Transaction;
|
||||
use serde_json;
|
||||
use transaction::Transaction;
|
||||
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
let s = r#"{
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
let s = r#"{
|
||||
"data" : "0x",
|
||||
"gasLimit" : "0xf388",
|
||||
"gasPrice" : "0x09184e72a000",
|
||||
@@ -63,7 +63,7 @@ mod tests {
|
||||
"v" : "0x1b",
|
||||
"value" : "0x00"
|
||||
}"#;
|
||||
let _deserialized: Transaction = serde_json::from_str(s).unwrap();
|
||||
// TODO: validate all fields
|
||||
}
|
||||
let _deserialized: Transaction = serde_json::from_str(s).unwrap();
|
||||
// TODO: validate all fields
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,39 +16,38 @@
|
||||
|
||||
//! Transaction test deserialization.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use bytes::Bytes;
|
||||
use hash::Address;
|
||||
use hash::H256;
|
||||
use hash::{Address, H256};
|
||||
use spec::ForkSpec;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Transaction test deserialization.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct TransactionTest {
|
||||
pub rlp: Bytes,
|
||||
pub _info: ::serde::de::IgnoredAny,
|
||||
#[serde(flatten)]
|
||||
pub post_state: BTreeMap<ForkSpec, PostState>,
|
||||
pub rlp: Bytes,
|
||||
pub _info: ::serde::de::IgnoredAny,
|
||||
#[serde(flatten)]
|
||||
pub post_state: BTreeMap<ForkSpec, PostState>,
|
||||
}
|
||||
|
||||
/// TransactionTest post state.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct PostState {
|
||||
/// Transaction sender.
|
||||
pub sender: Option<Address>,
|
||||
/// Transaction hash.
|
||||
pub hash: Option<H256>,
|
||||
/// Transaction sender.
|
||||
pub sender: Option<Address>,
|
||||
/// Transaction hash.
|
||||
pub hash: Option<H256>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use transaction::TransactionTest;
|
||||
use serde_json;
|
||||
use transaction::TransactionTest;
|
||||
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
let s = r#"{
|
||||
#[test]
|
||||
fn transaction_deserialization() {
|
||||
let s = r#"{
|
||||
"Byzantium" : {
|
||||
"hash" : "4782cb5edcaeda1f0aef204b161214f124cefade9e146245183abbb9ca01bca5",
|
||||
"sender" : "2ea991808ba979ba103147edfd72304ebd95c028"
|
||||
@@ -77,7 +76,7 @@ mod tests {
|
||||
"rlp" : "0xf865808698852840a46f82d6d894095e7baea6a6c7c4c2dfeb977efac326af552d87808025a098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa01887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"
|
||||
}"#;
|
||||
|
||||
let _deserialized: TransactionTest = serde_json::from_str(s).unwrap();
|
||||
// TODO: validate all fields
|
||||
}
|
||||
let _deserialized: TransactionTest = serde_json::from_str(s).unwrap();
|
||||
// TODO: validate all fields
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user