Merge branch 'master' into signer-signing
Conflicts: rpc/src/v1/impls/eth.rs rpc/src/v1/tests/mocked/eth.rs rpc/src/v1/traits/eth.rs
This commit is contained in:
@@ -19,6 +19,8 @@ ethcore = { path = "../ethcore" }
|
||||
ethash = { path = "../ethash" }
|
||||
ethsync = { path = "../sync" }
|
||||
ethminer = { path = "../miner" }
|
||||
ethjson = { path = "../json" }
|
||||
ethcore-devtools = { path = "../devtools" }
|
||||
rustc-serialize = "0.3"
|
||||
transient-hashmap = "0.1"
|
||||
serde_macros = { version = "0.7.0", optional = true }
|
||||
|
||||
@@ -33,6 +33,11 @@ extern crate ethminer;
|
||||
extern crate transient_hashmap;
|
||||
extern crate json_ipc_server as ipc;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate ethjson;
|
||||
#[cfg(test)]
|
||||
extern crate ethcore_devtools as devtools;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::net::SocketAddr;
|
||||
use self::jsonrpc_core::{IoHandler, IoDelegate};
|
||||
|
||||
@@ -26,6 +26,7 @@ use jsonrpc_core::*;
|
||||
use util::numbers::*;
|
||||
use util::sha3::*;
|
||||
use util::rlp::{encode, decode, UntrustedRlp, View};
|
||||
use util::keys::store::AccountProvider;
|
||||
use ethcore::client::{BlockChainClient, BlockID, TransactionID, UncleID};
|
||||
use ethcore::block::IsBlock;
|
||||
use ethcore::views::*;
|
||||
@@ -37,7 +38,6 @@ use self::ethash::SeedHashCompute;
|
||||
use v1::traits::Eth;
|
||||
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, CallRequest, OptionalValue, Index, Filter, Log, Receipt};
|
||||
use v1::impls::dispatch_transaction;
|
||||
use util::keys::store::AccountProvider;
|
||||
use serde;
|
||||
|
||||
/// Eth rpc implementation.
|
||||
@@ -529,4 +529,16 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM> where
|
||||
to_value(&r.map(|res| res.gas_used + res.refunded).unwrap_or(From::from(0)))
|
||||
})
|
||||
}
|
||||
|
||||
fn compile_lll(&self, _: Params) -> Result<Value, Error> {
|
||||
rpc_unimplemented!()
|
||||
}
|
||||
|
||||
fn compile_serpent(&self, _: Params) -> Result<Value, Error> {
|
||||
rpc_unimplemented!()
|
||||
}
|
||||
|
||||
fn compile_solidity(&self, _: Params) -> Result<Value, Error> {
|
||||
rpc_unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ impl EthSigningQueueClient {
|
||||
}
|
||||
|
||||
impl EthSigning for EthSigningQueueClient {
|
||||
|
||||
fn sign(&self, _params: Params) -> Result<Value, Error> {
|
||||
// TODO [ToDr] Implement sign when rest of the signing queue is ready.
|
||||
rpc_unimplemented!()
|
||||
}
|
||||
|
||||
fn send_transaction(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(TransactionRequest, )>(params)
|
||||
.and_then(|(request, )| {
|
||||
@@ -85,6 +91,12 @@ impl<C, A, M> EthSigning for EthSigningUnsafeClient<C, A, M> where
|
||||
A: AccountProvider + 'static,
|
||||
M: MinerService + 'static {
|
||||
|
||||
fn sign(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(Address, H256)>(params).and_then(|(addr, msg)| {
|
||||
to_value(&take_weak!(self.accounts).sign(&addr, &msg).unwrap_or(H520::zero()))
|
||||
})
|
||||
}
|
||||
|
||||
fn send_transaction(&self, params: Params) -> Result<Value, Error> {
|
||||
from_params::<(TransactionRequest, )>(params)
|
||||
.and_then(|(request, )| {
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::sync::{Arc, Weak};
|
||||
use std::ops::Deref;
|
||||
use std::collections::BTreeMap;
|
||||
use jsonrpc_core::*;
|
||||
use ethminer::{MinerService};
|
||||
use ethminer::MinerService;
|
||||
use v1::traits::Ethcore;
|
||||
use v1::types::Bytes;
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ macro_rules! take_weak {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! rpc_unimplemented {
|
||||
() => (Err(Error::internal_error()))
|
||||
}
|
||||
|
||||
mod web3;
|
||||
mod eth;
|
||||
mod eth_filter;
|
||||
@@ -61,22 +65,14 @@ fn dispatch_transaction<C, M>(client: &C, miner: &M, signed_transaction: SignedT
|
||||
where C: BlockChainClient, M: MinerService {
|
||||
let hash = signed_transaction.hash();
|
||||
|
||||
let import = {
|
||||
miner.import_own_transaction(client, signed_transaction, |a: &Address| {
|
||||
AccountDetails {
|
||||
nonce: client.latest_nonce(&a),
|
||||
balance: client.latest_balance(&a),
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
match import {
|
||||
Ok(_) => to_value(&hash),
|
||||
Err(e) => {
|
||||
warn!("Error sending transaction: {:?}", e);
|
||||
to_value(&H256::zero())
|
||||
let import = miner.import_own_transaction(client, signed_transaction, |a: &Address| {
|
||||
AccountDetails {
|
||||
nonce: client.latest_nonce(&a),
|
||||
balance: client.latest_balance(&a),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
to_value(&import.map(|_| hash).unwrap_or(H256::zero()))
|
||||
}
|
||||
|
||||
fn sign_and_dispatch<C, M>(client: &Weak<C>, miner: &Weak<M>, request: TransactionRequest, secret: H256) -> Result<Value, Error>
|
||||
|
||||
229
rpc/src/v1/tests/eth.rs
Normal file
229
rpc/src/v1/tests/eth.rs
Normal file
@@ -0,0 +1,229 @@
|
||||
// Copyright 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! rpc integration tests.
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
|
||||
use ethcore::client::{BlockChainClient, Client, ClientConfig};
|
||||
use ethcore::spec::Genesis;
|
||||
use ethcore::block::Block;
|
||||
use ethcore::ethereum;
|
||||
use ethcore::transaction::{Transaction, Action};
|
||||
use ethminer::{MinerService, ExternalMiner};
|
||||
use devtools::RandomTempPath;
|
||||
use util::io::IoChannel;
|
||||
use util::hash::Address;
|
||||
use util::numbers::{Uint, U256};
|
||||
use util::keys::{AccountProvider, TestAccount, TestAccountProvider};
|
||||
use jsonrpc_core::IoHandler;
|
||||
use ethjson::blockchain::BlockChain;
|
||||
|
||||
use v1::traits::eth::Eth;
|
||||
use v1::impls::EthClient;
|
||||
use v1::tests::helpers::{TestSyncProvider, Config, TestMinerService};
|
||||
|
||||
struct EthTester {
|
||||
_client: Arc<BlockChainClient>,
|
||||
_miner: Arc<MinerService>,
|
||||
accounts: Arc<TestAccountProvider>,
|
||||
handler: IoHandler,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn harness_works() {
|
||||
let chain: BlockChain = extract_chain!("BlockchainTests/bcUncleTest");
|
||||
chain_harness(chain, |_| {});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eth_get_balance() {
|
||||
let chain = extract_chain!("BlockchainTests/bcWalletTest", "wallet2outOf3txs");
|
||||
chain_harness(chain, |tester| {
|
||||
// final account state
|
||||
let req_latest = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getBalance",
|
||||
"params": ["0xaaaf5374fce5edbc8e2a8697c15331677e6ebaaa", "latest"],
|
||||
"id": 1
|
||||
}"#;
|
||||
let res_latest = r#"{"jsonrpc":"2.0","result":"0x09","id":1}"#.to_owned();
|
||||
assert_eq!(tester.handler.handle_request(req_latest).unwrap(), res_latest);
|
||||
|
||||
// non-existant account
|
||||
let req_new_acc = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getBalance",
|
||||
"params": ["0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
|
||||
"id": 3
|
||||
}"#;
|
||||
|
||||
let res_new_acc = r#"{"jsonrpc":"2.0","result":"0x00","id":3}"#.to_owned();
|
||||
assert_eq!(tester.handler.handle_request(req_new_acc).unwrap(), res_new_acc);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eth_block_number() {
|
||||
let chain = extract_chain!("BlockchainTests/bcRPC_API_Test");
|
||||
chain_harness(chain, |tester| {
|
||||
let req_number = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_blockNumber",
|
||||
"params": [],
|
||||
"id": 1
|
||||
}"#;
|
||||
|
||||
let res_number = r#"{"jsonrpc":"2.0","result":"0x20","id":1}"#.to_owned();
|
||||
assert_eq!(tester.handler.handle_request(req_number).unwrap(), res_number);
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn eth_transaction_count() {
|
||||
let chain = extract_chain!("BlockchainTests/bcRPC_API_Test");
|
||||
chain_harness(chain, |tester| {
|
||||
let address = tester.accounts.new_account("123").unwrap();
|
||||
let secret = tester.accounts.account_secret(&address).unwrap();
|
||||
|
||||
let req_before = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getTransactionCount",
|
||||
"params": [""#.to_owned() + format!("0x{:?}", address).as_ref() + r#"", "latest"],
|
||||
"id": 15
|
||||
}"#;
|
||||
|
||||
let res_before = r#"{"jsonrpc":"2.0","result":"0x00","id":15}"#;
|
||||
|
||||
assert_eq!(tester.handler.handle_request(&req_before).unwrap(), res_before);
|
||||
|
||||
let t = Transaction {
|
||||
nonce: U256::zero(),
|
||||
gas_price: U256::from(0x9184e72a000u64),
|
||||
gas: U256::from(0x76c0),
|
||||
action: Action::Call(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||
value: U256::from(0x9184e72au64),
|
||||
data: vec![]
|
||||
}.sign(&secret);
|
||||
|
||||
let req_send_trans = 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": 16
|
||||
}"#;
|
||||
|
||||
let res_send_trans = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":16}"#;
|
||||
|
||||
// dispatch the transaction.
|
||||
assert_eq!(tester.handler.handle_request(&req_send_trans).unwrap(), res_send_trans);
|
||||
|
||||
// we have submitted the transaction -- but this shouldn't be reflected in a "latest" query.
|
||||
let req_after_latest = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getTransactionCount",
|
||||
"params": [""#.to_owned() + format!("0x{:?}", address).as_ref() + r#"", "latest"],
|
||||
"id": 17
|
||||
}"#;
|
||||
|
||||
let res_after_latest = r#"{"jsonrpc":"2.0","result":"0x00","id":17}"#;
|
||||
|
||||
assert_eq!(&tester.handler.handle_request(&req_after_latest).unwrap(), res_after_latest);
|
||||
|
||||
// the pending transactions should have been updated.
|
||||
let req_after_pending = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getTransactionCount",
|
||||
"params": [""#.to_owned() + format!("0x{:?}", address).as_ref() + r#"", "pending"],
|
||||
"id": 18
|
||||
}"#;
|
||||
|
||||
let res_after_pending = r#"{"jsonrpc":"2.0","result":"0x01","id":18}"#;
|
||||
|
||||
assert_eq!(&tester.handler.handle_request(&req_after_pending).unwrap(), res_after_pending);
|
||||
});
|
||||
}
|
||||
|
||||
fn account_provider() -> Arc<TestAccountProvider> {
|
||||
let mut accounts = HashMap::new();
|
||||
accounts.insert(Address::from(1), TestAccount::new("test"));
|
||||
let ap = TestAccountProvider::new(accounts);
|
||||
Arc::new(ap)
|
||||
}
|
||||
|
||||
fn sync_provider() -> Arc<TestSyncProvider> {
|
||||
Arc::new(TestSyncProvider::new(Config {
|
||||
network_id: U256::from(3),
|
||||
num_peers: 120,
|
||||
}))
|
||||
}
|
||||
|
||||
fn miner_service() -> Arc<TestMinerService> {
|
||||
Arc::new(TestMinerService::default())
|
||||
}
|
||||
|
||||
// given a blockchain, this harness will create an EthClient wrapping it
|
||||
// which tests can pass specially crafted requests to.
|
||||
fn chain_harness<F, U>(chain: BlockChain, mut cb: F) -> U
|
||||
where F: FnMut(&EthTester) -> U {
|
||||
let genesis = Genesis::from(chain.genesis());
|
||||
let mut spec = ethereum::new_frontier_test();
|
||||
let state = chain.pre_state.clone().into();
|
||||
spec.set_genesis_state(state);
|
||||
spec.overwrite_genesis_params(genesis);
|
||||
assert!(spec.is_state_root_valid());
|
||||
|
||||
let dir = RandomTempPath::new();
|
||||
let client = Client::new(ClientConfig::default(), spec, dir.as_path(), IoChannel::disconnected()).unwrap();
|
||||
let sync_provider = sync_provider();
|
||||
let miner_service = miner_service();
|
||||
let account_provider = account_provider();
|
||||
let external_miner = Arc::new(ExternalMiner::default());
|
||||
|
||||
for b in &chain.blocks_rlp() {
|
||||
if Block::is_good(&b) {
|
||||
let _ = client.import_block(b.clone());
|
||||
client.flush_queue();
|
||||
client.import_verified_blocks(&IoChannel::disconnected());
|
||||
}
|
||||
}
|
||||
|
||||
assert!(client.chain_info().best_block_hash == chain.best_block.into());
|
||||
|
||||
let eth_client = EthClient::new(&client, &sync_provider, &account_provider,
|
||||
&miner_service, &external_miner);
|
||||
|
||||
let handler = IoHandler::new();
|
||||
let delegate = eth_client.to_delegate();
|
||||
handler.add_delegate(delegate);
|
||||
|
||||
let tester = EthTester {
|
||||
_miner: miner_service,
|
||||
_client: client,
|
||||
accounts: account_provider,
|
||||
handler: handler,
|
||||
};
|
||||
|
||||
cb(&tester)
|
||||
}
|
||||
@@ -115,12 +115,16 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
/// Imports transactions to transaction queue.
|
||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, _fetch_account: T) ->
|
||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) ->
|
||||
Vec<Result<TransactionImportResult, Error>>
|
||||
where T: Fn(&Address) -> AccountDetails {
|
||||
// lets assume that all txs are valid
|
||||
self.imported_transactions.lock().unwrap().extend_from_slice(&transactions);
|
||||
|
||||
for sender in transactions.iter().filter_map(|t| t.sender().ok()) {
|
||||
let nonce = self.last_nonce(&sender).unwrap_or(fetch_account(&sender).nonce);
|
||||
self.last_nonces.write().unwrap().insert(sender, nonce + U256::from(1));
|
||||
}
|
||||
transactions
|
||||
.iter()
|
||||
.map(|_| Ok(TransactionImportResult::Current))
|
||||
@@ -128,9 +132,16 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
/// Imports transactions to transaction queue.
|
||||
fn import_own_transaction<T>(&self, _chain: &BlockChainClient, transaction: SignedTransaction, _fetch_account: T) ->
|
||||
fn import_own_transaction<T>(&self, chain: &BlockChainClient, transaction: SignedTransaction, _fetch_account: T) ->
|
||||
Result<TransactionImportResult, Error>
|
||||
where T: Fn(&Address) -> AccountDetails {
|
||||
|
||||
// keep the pending nonces up to date
|
||||
if let Ok(ref sender) = transaction.sender() {
|
||||
let nonce = self.last_nonce(sender).unwrap_or(chain.latest_nonce(sender));
|
||||
self.last_nonces.write().unwrap().insert(sender.clone(), nonce + U256::from(1));
|
||||
}
|
||||
|
||||
// lets assume that all txs are valid
|
||||
self.imported_transactions.lock().unwrap().push(transaction);
|
||||
|
||||
@@ -200,7 +211,9 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
fn nonce(&self, _chain: &BlockChainClient, address: &Address) -> U256 {
|
||||
self.latest_closed_block.lock().unwrap().as_ref().map_or_else(U256::zero, |b| b.block().fields().state.nonce(address).clone())
|
||||
// we assume all transactions are in a pending block, ignoring the
|
||||
// reality of gas limits.
|
||||
self.last_nonce(address).unwrap_or(U256::zero())
|
||||
}
|
||||
|
||||
fn code(&self, _chain: &BlockChainClient, address: &Address) -> Option<Bytes> {
|
||||
|
||||
@@ -20,4 +20,4 @@ mod sync_provider;
|
||||
mod miner_service;
|
||||
|
||||
pub use self::sync_provider::{Config, TestSyncProvider};
|
||||
pub use self::miner_service::{TestMinerService};
|
||||
pub use self::miner_service::TestMinerService;
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
//! Test implementation of SyncProvider.
|
||||
|
||||
use util::{U256};
|
||||
use util::U256;
|
||||
use ethsync::{SyncProvider, SyncStatus, SyncState};
|
||||
use std::sync::{RwLock};
|
||||
use std::sync::RwLock;
|
||||
|
||||
/// TestSyncProvider config.
|
||||
pub struct Config {
|
||||
|
||||
@@ -20,14 +20,16 @@ use std::sync::{Arc, RwLock};
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::hash::{Address, H256, FixedHash};
|
||||
use util::numbers::{Uint, U256};
|
||||
use util::keys::{TestAccount, TestAccountProvider};
|
||||
use util::keys::{AccountProvider, TestAccount, TestAccountProvider};
|
||||
use ethcore::client::{TestBlockChainClient, EachBlockWith, Executed, TransactionID};
|
||||
use ethcore::log_entry::{LocalizedLogEntry, LogEntry};
|
||||
use ethcore::receipt::LocalizedReceipt;
|
||||
use ethcore::transaction::{Transaction, Action};
|
||||
use ethminer::ExternalMiner;
|
||||
use ethminer::{ExternalMiner, MinerService};
|
||||
use ethsync::SyncState;
|
||||
use v1::{Eth, EthClient, EthSigning, EthSigningUnsafeClient};
|
||||
use v1::tests::helpers::{TestSyncProvider, Config, TestMinerService};
|
||||
use rustc_serialize::hex::ToHex;
|
||||
|
||||
fn blockchain_client() -> Arc<TestBlockChainClient> {
|
||||
let client = TestBlockChainClient::new();
|
||||
@@ -95,9 +97,28 @@ fn rpc_eth_protocol_version() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn rpc_eth_syncing() {
|
||||
unimplemented!()
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "eth_syncing", "params": [], "id": 1}"#;
|
||||
|
||||
let tester = EthTester::default();
|
||||
|
||||
let false_res = r#"{"jsonrpc":"2.0","result":false,"id":1}"#;
|
||||
assert_eq!(tester.io.handle_request(request), Some(false_res.to_owned()));
|
||||
|
||||
{
|
||||
let mut status = tester.sync.status.write().unwrap();
|
||||
status.state = SyncState::Blocks;
|
||||
status.highest_block_number = Some(2500);
|
||||
|
||||
// causes TestBlockChainClient to return 1000 for its best block number.
|
||||
let mut blocks = tester.client.blocks.write().unwrap();
|
||||
for i in 0..1000 {
|
||||
blocks.insert(H256::from(i), Vec::new());
|
||||
}
|
||||
}
|
||||
|
||||
let true_res = r#"{"jsonrpc":"2.0","result":{"currentBlock":"0x03e8","highestBlock":"0x09c4","startingBlock":"0x00"},"id":1}"#;
|
||||
assert_eq!(tester.io.handle_request(request), Some(true_res.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -133,9 +154,47 @@ fn rpc_eth_submit_hashrate() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn rpc_eth_sign() {
|
||||
let tester = EthTester::default();
|
||||
|
||||
let account = tester.accounts_provider.new_account("abcd").unwrap();
|
||||
let message = H256::from("0x0cc175b9c0f1b6a831c399e26977266192eb5ffee6ae2fec3ad71c777531578f");
|
||||
let signed = tester.accounts_provider.sign(&account, &message).unwrap();
|
||||
|
||||
let req = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_sign",
|
||||
"params": [
|
||||
""#.to_owned() + &format!("0x{:?}", account) + r#"",
|
||||
"0x0cc175b9c0f1b6a831c399e26977266192eb5ffee6ae2fec3ad71c777531578f"
|
||||
],
|
||||
"id": 1
|
||||
}"#;
|
||||
let res = r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{:?}", signed) + r#"","id":1}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request(&req), Some(res));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rpc_eth_author() {
|
||||
unimplemented!()
|
||||
let make_res = |addr| r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{:?}", addr) + r#"","id":1}"#;
|
||||
let tester = EthTester::default();
|
||||
|
||||
let req = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_coinbase",
|
||||
"params": [],
|
||||
"id": 1
|
||||
}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request(req), Some(make_res(Address::zero())));
|
||||
|
||||
for i in 0..20 {
|
||||
let addr = tester.accounts_provider.new_account(&format!("{}", i)).unwrap();
|
||||
tester.miner.set_author(addr.clone());
|
||||
|
||||
assert_eq!(tester.io.handle_request(req), Some(make_res(addr)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -196,18 +255,22 @@ fn rpc_eth_balance() {
|
||||
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[ignore] //TODO: propert test
|
||||
#[test]
|
||||
fn rpc_eth_balance_pending() {
|
||||
let tester = EthTester::default();
|
||||
tester.client.set_balance(Address::from(1), U256::from(5));
|
||||
|
||||
let request = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_getBalance",
|
||||
"params": ["0x0000000000000000000000000000000000000001", "latest"],
|
||||
"params": ["0x0000000000000000000000000000000000000001", "pending"],
|
||||
"id": 1
|
||||
}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":"0x","id":1}"#;
|
||||
|
||||
// the TestMinerService doesn't communicate with the the TestBlockChainClient in any way.
|
||||
// if this returns zero, we know that the "pending" call is being properly forwarded to the
|
||||
// miner.
|
||||
let response = r#"{"jsonrpc":"2.0","result":"0x00","id":1}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||
}
|
||||
@@ -506,7 +569,7 @@ fn rpc_eth_send_transaction() {
|
||||
|
||||
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request(request.as_ref()), Some(response));
|
||||
assert_eq!(tester.io.handle_request(&request), Some(response));
|
||||
|
||||
tester.miner.last_nonces.write().unwrap().insert(address.clone(), U256::zero());
|
||||
|
||||
@@ -521,19 +584,38 @@ fn rpc_eth_send_transaction() {
|
||||
|
||||
let response = r#"{"jsonrpc":"2.0","result":""#.to_owned() + format!("0x{:?}", t.hash()).as_ref() + r#"","id":1}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request(request.as_ref()), Some(response));
|
||||
assert_eq!(tester.io.handle_request(&request), Some(response));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn rpc_eth_send_raw_transaction() {
|
||||
unimplemented!()
|
||||
}
|
||||
let tester = EthTester::default();
|
||||
let address = tester.accounts_provider.new_account("abcd").unwrap();
|
||||
let secret = tester.accounts_provider.account_secret(&address).unwrap();
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn rpc_eth_sign() {
|
||||
unimplemented!()
|
||||
let t = Transaction {
|
||||
nonce: U256::zero(),
|
||||
gas_price: U256::from(0x9184e72a000u64),
|
||||
gas: U256::from(0x76c0),
|
||||
action: Action::Call(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()),
|
||||
value: U256::from(0x9184e72au64),
|
||||
data: vec![]
|
||||
}.sign(&secret);
|
||||
|
||||
let rlp = ::util::rlp::encode(&t).to_vec().to_hex();
|
||||
|
||||
let req = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_sendRawTransaction",
|
||||
"params": [
|
||||
"0x"#.to_owned() + &rlp + r#""
|
||||
],
|
||||
"id": 1
|
||||
}"#;
|
||||
|
||||
let res = r#"{"jsonrpc":"2.0","result":""#.to_owned() + &format!("0x{:?}", t.hash()) + r#"","id":1}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request(&req), Some(res));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! RPC serialization tests.
|
||||
//! RPC mocked tests. Most of these test that the RPC server is serializing and forwarding
|
||||
//! method calls properly.
|
||||
|
||||
mod eth;
|
||||
mod eth_signing;
|
||||
|
||||
@@ -2,5 +2,40 @@
|
||||
|
||||
pub mod helpers;
|
||||
|
||||
// extract a chain from the given JSON file,
|
||||
// stored in ethcore/res/ethereum/tests/.
|
||||
//
|
||||
// usage:
|
||||
// `extract_chain!("Folder/File")` will load Folder/File.json and extract
|
||||
// the first block chain stored within.
|
||||
//
|
||||
// `extract_chain!("Folder/File", "with_name")` will load Folder/File.json and
|
||||
// extract the chain with that name. This will panic if no chain by that name
|
||||
// is found.
|
||||
macro_rules! extract_chain {
|
||||
($file:expr, $name:expr) => {{
|
||||
const RAW_DATA: &'static [u8] =
|
||||
include_bytes!(concat!("../../../../ethcore/res/ethereum/tests/", $file, ".json"));
|
||||
let mut chain = None;
|
||||
for (name, c) in ::ethjson::blockchain::Test::load(RAW_DATA).unwrap() {
|
||||
if name == $name {
|
||||
chain = Some(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
chain.unwrap()
|
||||
}};
|
||||
|
||||
($file:expr) => {{
|
||||
const RAW_DATA: &'static [u8] =
|
||||
include_bytes!(concat!("../../../../ethcore/res/ethereum/tests/", $file, ".json"));
|
||||
|
||||
::ethjson::blockchain::Test::load(RAW_DATA)
|
||||
.unwrap().into_iter().next().unwrap().1
|
||||
}};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod mocked;
|
||||
mod mocked;
|
||||
#[cfg(test)]
|
||||
mod eth;
|
||||
|
||||
@@ -21,109 +21,109 @@ use jsonrpc_core::*;
|
||||
/// Eth rpc interface.
|
||||
pub trait Eth: Sized + Send + Sync + 'static {
|
||||
/// Returns protocol version.
|
||||
fn protocol_version(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn protocol_version(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns an object with data about the sync status or false. (wtf?)
|
||||
fn syncing(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn syncing(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the number of hashes per second that the node is mining with.
|
||||
fn hashrate(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn hashrate(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns block author.
|
||||
fn author(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn author(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns true if client is actively mining new blocks.
|
||||
fn is_mining(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn is_mining(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns current gas_price.
|
||||
fn gas_price(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn gas_price(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns accounts list.
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns highest block number.
|
||||
fn block_number(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_number(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns balance of the given account.
|
||||
fn balance(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn balance(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns content of the storage at given address.
|
||||
fn storage_at(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn storage_at(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns block with given hash.
|
||||
fn block_by_hash(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_by_hash(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns block with given number.
|
||||
fn block_by_number(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_by_number(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the number of transactions sent from given address at given time (block number).
|
||||
fn transaction_count(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn transaction_count(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the number of transactions in a block with given hash.
|
||||
fn block_transaction_count_by_hash(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_transaction_count_by_hash(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the number of transactions in a block with given block number.
|
||||
fn block_transaction_count_by_number(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_transaction_count_by_number(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the number of uncles in a block with given hash.
|
||||
fn block_uncles_count_by_hash(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_uncles_count_by_hash(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the number of uncles in a block with given block number.
|
||||
fn block_uncles_count_by_number(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_uncles_count_by_number(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the code at given address at given time (block number).
|
||||
fn code_at(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn code_at(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Sends signed transaction.
|
||||
fn send_raw_transaction(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn send_raw_transaction(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Call contract.
|
||||
fn call(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn call(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Estimate gas needed for execution of given contract.
|
||||
fn estimate_gas(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn estimate_gas(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Get transaction by it's hash.
|
||||
fn transaction_by_hash(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn transaction_by_hash(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns transaction at given block hash and index.
|
||||
fn transaction_by_block_hash_and_index(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn transaction_by_block_hash_and_index(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns transaction by given block number and index.
|
||||
fn transaction_by_block_number_and_index(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn transaction_by_block_number_and_index(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns transaction receipt.
|
||||
fn transaction_receipt(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn transaction_receipt(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns an uncles at given block and index.
|
||||
fn uncle_by_block_hash_and_index(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn uncle_by_block_hash_and_index(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns an uncles at given block and index.
|
||||
fn uncle_by_block_number_and_index(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn uncle_by_block_number_and_index(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns available compilers.
|
||||
fn compilers(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn compilers(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Compiles lll code.
|
||||
fn compile_lll(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn compile_lll(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Compiles solidity.
|
||||
fn compile_solidity(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn compile_solidity(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Compiles serpent.
|
||||
fn compile_serpent(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn compile_serpent(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns logs matching given filter object.
|
||||
fn logs(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn logs(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns the hash of the current block, the seedHash, and the boundary condition to be met.
|
||||
fn work(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn work(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Used for submitting a proof-of-work solution.
|
||||
fn submit_work(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn submit_work(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Used for submitting mining hashrate.
|
||||
fn submit_hashrate(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn submit_hashrate(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
@@ -171,22 +171,22 @@ pub trait Eth: Sized + Send + Sync + 'static {
|
||||
// TODO: do filters api properly
|
||||
pub trait EthFilter: Sized + Send + Sync + 'static {
|
||||
/// Returns id of new filter.
|
||||
fn new_filter(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn new_filter(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns id of new block filter.
|
||||
fn new_block_filter(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn new_block_filter(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns id of new block filter.
|
||||
fn new_pending_transaction_filter(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn new_pending_transaction_filter(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns filter changes since last poll.
|
||||
fn filter_changes(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn filter_changes(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns all logs matching given filter (in a range 'from' - 'to').
|
||||
fn filter_logs(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn filter_logs(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Uninstalls filter.
|
||||
fn uninstall_filter(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn uninstall_filter(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
@@ -204,10 +204,10 @@ pub trait EthFilter: Sized + Send + Sync + 'static {
|
||||
/// Signing methods implementation relying on unlocked accounts.
|
||||
pub trait EthSigning: Sized + Send + Sync + 'static {
|
||||
/// Signs the data with given address signature.
|
||||
fn sign(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn sign(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Sends transaction.
|
||||
fn send_transaction(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn send_transaction(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
|
||||
@@ -22,55 +22,55 @@ use jsonrpc_core::*;
|
||||
pub trait Ethcore: Sized + Send + Sync + 'static {
|
||||
|
||||
/// Sets new minimal gas price for mined blocks.
|
||||
fn set_min_gas_price(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn set_min_gas_price(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Sets new gas floor target for mined blocks.
|
||||
fn set_gas_floor_target(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn set_gas_floor_target(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Sets new extra data for mined blocks.
|
||||
fn set_extra_data(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn set_extra_data(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Sets new author for mined block.
|
||||
fn set_author(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn set_author(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Sets the limits for transaction queue.
|
||||
fn set_transactions_limit(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn set_transactions_limit(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns current transactions limit.
|
||||
fn transactions_limit(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn transactions_limit(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns mining extra data.
|
||||
fn extra_data(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn extra_data(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns mining gas floor target.
|
||||
fn gas_floor_target(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn gas_floor_target(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns minimal gas price for transaction to be included in queue.
|
||||
fn min_gas_price(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn min_gas_price(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns latest logs
|
||||
fn dev_logs(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn dev_logs(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns logs levels
|
||||
fn dev_logs_levels(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn dev_logs_levels(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns chain name
|
||||
fn net_chain(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn net_chain(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns max peers
|
||||
fn net_max_peers(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn net_max_peers(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns network port
|
||||
fn net_port(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn net_port(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns rpc settings
|
||||
fn rpc_settings(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn rpc_settings(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns node name
|
||||
fn node_name(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn node_name(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns default extra data
|
||||
fn default_extra_data(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn default_extra_data(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
//! Ethereum rpc interfaces.
|
||||
|
||||
macro_rules! rpc_unimplemented {
|
||||
() => (Err(Error::internal_error()))
|
||||
}
|
||||
|
||||
pub mod web3;
|
||||
pub mod eth;
|
||||
pub mod net;
|
||||
|
||||
@@ -21,14 +21,14 @@ use jsonrpc_core::*;
|
||||
/// Net rpc interface.
|
||||
pub trait Net: Sized + Send + Sync + 'static {
|
||||
/// Returns protocol version.
|
||||
fn version(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn version(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns number of peers connected to node.
|
||||
fn peer_count(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn peer_count(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns true if client is actively listening for network connections.
|
||||
/// Otherwise false.
|
||||
fn is_listening(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn is_listening(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
|
||||
@@ -22,16 +22,16 @@ use jsonrpc_core::*;
|
||||
pub trait Personal: Sized + Send + Sync + 'static {
|
||||
|
||||
/// Lists all stored accounts
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Creates new account (it becomes new current unlocked account)
|
||||
fn new_account(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn new_account(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Unlocks specified account for use (can only be one unlocked account at one moment)
|
||||
fn unlock_account(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn unlock_account(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Sends transaction and signs it in single call. The account is not unlocked in such case.
|
||||
fn sign_and_send_transaction(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn sign_and_send_transaction(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
|
||||
@@ -23,10 +23,10 @@ use jsonrpc_core::*;
|
||||
pub trait Rpc: Sized + Send + Sync + 'static {
|
||||
|
||||
/// Returns supported modules for Geth 1.3.6
|
||||
fn modules(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn modules(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns supported modules for Geth 1.4.0
|
||||
fn rpc_modules(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn rpc_modules(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
|
||||
@@ -21,16 +21,16 @@ use jsonrpc_core::*;
|
||||
/// Traces specific rpc interface.
|
||||
pub trait Traces: Sized + Send + Sync + 'static {
|
||||
/// Returns traces matching given filter.
|
||||
fn filter(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn filter(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns transaction trace at given index.
|
||||
fn trace(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn trace(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns all traces of given transaction.
|
||||
fn transaction_traces(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn transaction_traces(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns all traces produced at given block.
|
||||
fn block_traces(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn block_traces(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
|
||||
@@ -21,10 +21,10 @@ use jsonrpc_core::*;
|
||||
/// Web3 rpc interface.
|
||||
pub trait Web3: Sized + Send + Sync + 'static {
|
||||
/// Returns current client version.
|
||||
fn client_version(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn client_version(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns sha3 of the given data
|
||||
fn sha3(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
|
||||
fn sha3(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
|
||||
Reference in New Issue
Block a user