From c9ac0392d8813584ab0639a1c050ff5f99d8eef7 Mon Sep 17 00:00:00 2001 From: debris Date: Sun, 27 Mar 2016 14:14:05 +0200 Subject: [PATCH] tests for deserialization of issue #835 --- rpc/src/v1/impls/eth.rs | 8 ++++---- rpc/src/v1/types/transaction_request.rs | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index a68fc91fd..2fe887654 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -476,11 +476,11 @@ impl Eth for EthClient Ok(_) => to_value(&hash), Err(e) => { warn!("Error sending transaction: {:?}", e); - to_value(&U256::zero()) + to_value(&H256::zero()) } } }, - Err(_) => { to_value(&U256::zero()) } + Err(_) => { to_value(&H256::zero()) } } }) } @@ -503,11 +503,11 @@ impl Eth for EthClient Ok(_) => to_value(&hash), Err(e) => { warn!("Error sending transaction: {:?}", e); - to_value(&U256::zero()) + to_value(&H256::zero()) } } }, - Err(_) => { to_value(&U256::zero()) } + Err(_) => { to_value(&H256::zero()) } } }) } diff --git a/rpc/src/v1/types/transaction_request.rs b/rpc/src/v1/types/transaction_request.rs index 2623fd0ea..f00fa9ef0 100644 --- a/rpc/src/v1/types/transaction_request.rs +++ b/rpc/src/v1/types/transaction_request.rs @@ -102,4 +102,27 @@ mod tests { nonce: None, }); } + + #[test] + fn transaction_request_deserialize_test() { + let s = r#"{ + "from":"0xb5f7502a2807cb23615c7456055e1d65b2508625", + "to":"0x895d32f2db7d01ebb50053f9e48aacf26584fe40", + "data":"0x8595bab1", + "gas":"0x2fd618", + "gasPrice":"0x0ba43b7400" + }"#; + + let deserialized: TransactionRequest = serde_json::from_str(s).unwrap(); + + assert_eq!(deserialized, TransactionRequest { + from: Address::from_str("b5f7502a2807cb23615c7456055e1d65b2508625").unwrap(), + to: Some(Address::from_str("895d32f2db7d01ebb50053f9e48aacf26584fe40").unwrap()), + gas_price: Some(U256::from_str("0ba43b7400").unwrap()), + gas: Some(U256::from_str("2fd618").unwrap()), + value: None, + data: Some(Bytes::new(vec![0x85, 0x95, 0xba, 0xb1])), + nonce: None, + }); + } }