next batch of rpc fixes, 103 still failing

This commit is contained in:
debris 2016-03-19 12:23:48 +01:00
parent 52dbcd8152
commit e5c6579a8c
4 changed files with 13 additions and 12 deletions

View File

@ -38,7 +38,7 @@ use ethcore::client::{BlockChainClient, Client, ClientConfig};
use devtools::RandomTempPath;
use util::IoChannel;
use rpc::v1::tests::helpers::{TestSyncProvider, Config as SyncConfig, TestMinerService, TestAccountProvider, TestAccount};
use rpc::v1::{Eth, EthClient};
use rpc::v1::{Eth, EthClient, EthFilter, EthFilterClient};
use util::panics::MayPanic;
use util::hash::Address;
@ -124,6 +124,7 @@ impl Configuration {
let accounts = Arc::new(TestAccountProvider::new(accs));
let server = rpc::RpcServer::new();
server.add_delegate(EthClient::new(&client, &sync, &accounts, &miner).to_delegate());
server.add_delegate(EthFilterClient::new(&client, &miner).to_delegate());
let url = format!("{}:{}", self.args.flag_jsonrpc_addr, self.args.flag_jsonrpc_port);
let panic_handler = server.start_http(url.as_ref(), "*", 1);

View File

@ -104,7 +104,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
difficulty: view.difficulty(),
total_difficulty: total_difficulty,
nonce: view.seal().get(1).map_or_else(H64::zero, |r| H64::from_slice(r)),
uncles: vec![],
uncles: block_view.uncle_hashes(),
transactions: {
if include_txs {
BlockTransactions::Full(block_view.localized_transactions().into_iter().map(From::from).collect())
@ -230,8 +230,8 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
fn block_transaction_count_by_hash(&self, params: Params) -> Result<Value, Error> {
from_params::<(H256,)>(params)
.and_then(|(hash,)| // match
to_value(&take_weak!(self.client).block(BlockId::Hash(hash))
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).transactions_count()))))
take_weak!(self.client).block(BlockId::Hash(hash))
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).transactions_count()))))
}
fn block_transaction_count_by_number(&self, params: Params) -> Result<Value, Error> {
@ -240,24 +240,24 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
BlockNumber::Pending => to_value(
&U256::from(take_weak!(self.miner).status().transactions_in_pending_block)
),
_ => to_value(&take_weak!(self.client).block(block_number.into())
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).transactions_count())))
_ => take_weak!(self.client).block(block_number.into())
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).transactions_count())))
})
}
fn block_uncles_count_by_hash(&self, params: Params) -> Result<Value, Error> {
from_params::<(H256,)>(params)
.and_then(|(hash,)|
to_value(&take_weak!(self.client).block(BlockId::Hash(hash))
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).uncles_count()))))
take_weak!(self.client).block(BlockId::Hash(hash))
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).uncles_count()))))
}
fn block_uncles_count_by_number(&self, params: Params) -> Result<Value, Error> {
from_params::<(BlockNumber,)>(params)
.and_then(|(block_number,)| match block_number {
BlockNumber::Pending => to_value(&U256::from(0)),
_ => to_value(&take_weak!(self.client).block(block_number.into())
.map_or_else(U256::zero, |bytes| U256::from(BlockView::new(&bytes).uncles_count())))
_ => take_weak!(self.client).block(block_number.into())
.map_or(Ok(Value::Null), |bytes| to_value(&U256::from(BlockView::new(&bytes).uncles_count())))
})
}

View File

@ -57,7 +57,7 @@ impl MinerService for TestMinerService {
where T: Fn(&Address) -> AccountDetails { unimplemented!(); }
/// Returns hashes of transactions currently in pending
fn pending_transactions_hashes(&self) -> Vec<H256> { unimplemented!(); }
fn pending_transactions_hashes(&self) -> Vec<H256> { vec![] }
/// Removes all transactions from the queue and restart mining operation.
fn clear_and_reset(&self, _chain: &BlockChainClient) { unimplemented!(); }

View File

@ -64,7 +64,7 @@ pub struct Block {
#[serde(rename="totalDifficulty")]
pub total_difficulty: U256,
pub nonce: H64,
pub uncles: Vec<U256>,
pub uncles: Vec<H256>,
pub transactions: BlockTransactions
}