diff --git a/rpc/src/v1/helpers/signing_queue.rs b/rpc/src/v1/helpers/signing_queue.rs index b6ab6126f..c7abd4924 100644 --- a/rpc/src/v1/helpers/signing_queue.rs +++ b/rpc/src/v1/helpers/signing_queue.rs @@ -58,7 +58,7 @@ mod test { #[test] fn should_work_for_hashset() { // given - let mut queue = Mutex::new(HashSet::new()); + let queue = Mutex::new(HashSet::new()); let request = TransactionRequest { from: Address::from(1), diff --git a/rpc/src/v1/tests/mocked/eth_signing.rs b/rpc/src/v1/tests/mocked/eth_signing.rs index 05ceaf3d3..07adc44b5 100644 --- a/rpc/src/v1/tests/mocked/eth_signing.rs +++ b/rpc/src/v1/tests/mocked/eth_signing.rs @@ -14,4 +14,64 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::collections::HashSet; +use std::sync::{Arc, Mutex}; +use jsonrpc_core::IoHandler; +use v1::impls::EthSigningQueueClient; +use v1::traits::EthSigning; +use v1::helpers::SigningQueue; +use util::keys::TestAccount; +struct EthSignerTester { + pub queue: Arc, + pub io: IoHandler, +} + +impl Default for EthSignerTester { + fn default() -> Self { + let queue : Arc = Arc::new(Mutex::new(HashSet::new())); + let io = IoHandler::new(); + io.add_delegate(EthSigningQueueClient::new(&queue).to_delegate()); + + EthSignerTester { + queue: queue, + io: io, + } + } +} + +fn eth_signer() -> EthSignerTester { + EthSignerTester::default() +} + + + +#[test] +fn should_add_transaction_to_queue() { + // given + let tester = eth_signer(); + let account = TestAccount::new("123"); + let address = account.address(); + assert_eq!(tester.queue.requests().len(), 0); + + // when + let request = r#"{ + "jsonrpc": "2.0", + "method": "eth_sendTransaction", + "params": [{ + "from": ""#.to_owned() + format!("0x{:?}", address).as_ref() + r#"", + "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567", + "gas": "0x76c0", + "gasPrice": "0x9184e72a000", + "value": "0x9184e72a" + }], + "id": 1 + }"#; + let response = r#"{"jsonrpc":"2.0","result":"0x0000000000000000000000000000000000000000000000000000000000000000","id":1}"#; + + + // then + assert_eq!(tester.io.handle_request(&request), Some(response.to_owned())); + assert_eq!(tester.queue.requests().len(), 1); + +} diff --git a/rpc/src/v1/tests/mocked/mod.rs b/rpc/src/v1/tests/mocked/mod.rs index 98caf6e08..450960f78 100644 --- a/rpc/src/v1/tests/mocked/mod.rs +++ b/rpc/src/v1/tests/mocked/mod.rs @@ -17,8 +17,10 @@ //! RPC serialization tests. mod eth; +mod eth_signing; mod net; mod web3; mod personal; +mod personal_signer; mod ethcore; mod rpc;