Merge branches 'kill_unwraps' and 'dynamic-gas-price' of github.com:ethcore/parity into dynamic-gas-price
This commit is contained in:
@@ -41,6 +41,7 @@ use rpc::v1::tests::helpers::{TestSyncProvider, Config as SyncConfig, TestMinerS
|
||||
use rpc::v1::{Eth, EthClient, EthFilter, EthFilterClient};
|
||||
use util::panics::MayPanic;
|
||||
use util::hash::Address;
|
||||
use util::Lockable;
|
||||
|
||||
const USAGE: &'static str = r#"
|
||||
Parity rpctest client.
|
||||
@@ -137,7 +138,7 @@ impl Configuration {
|
||||
panic_handler.on_panic(move |_reason| { e.notify_all(); });
|
||||
|
||||
let mutex = Mutex::new(());
|
||||
let _ = exit.wait(mutex.lock().unwrap()).unwrap();
|
||||
let _ = exit.wait(mutex.locked()).unwrap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::time::{Instant, Duration};
|
||||
use std::sync::{mpsc, Mutex, RwLock, Arc};
|
||||
use std::collections::HashMap;
|
||||
use jsonrpc_core;
|
||||
use util::U256;
|
||||
use util::{U256, Lockable, RwLockable};
|
||||
use v1::helpers::{TransactionRequest, TransactionConfirmation};
|
||||
|
||||
/// Result that can be returned from JSON RPC.
|
||||
@@ -110,7 +110,7 @@ pub struct ConfirmationPromise {
|
||||
impl ConfirmationToken {
|
||||
/// Submit solution to all listeners
|
||||
fn resolve(&self, result: Option<RpcResult>) {
|
||||
let mut res = self.result.lock().unwrap();
|
||||
let mut res = self.result.locked();
|
||||
*res = result.map_or(ConfirmationResult::Rejected, |h| ConfirmationResult::Confirmed(h));
|
||||
// Notify listener
|
||||
self.handle.unpark();
|
||||
@@ -142,7 +142,7 @@ impl ConfirmationPromise {
|
||||
// Park thread (may wake up spuriously)
|
||||
thread::park_timeout(deadline - now);
|
||||
// Take confirmation result
|
||||
let res = self.result.lock().unwrap();
|
||||
let res = self.result.locked();
|
||||
// Check the result
|
||||
match *res {
|
||||
ConfirmationResult::Rejected => return None,
|
||||
@@ -183,7 +183,7 @@ impl ConfirmationsQueue {
|
||||
/// This method can be used only once (only single consumer of events can exist).
|
||||
pub fn start_listening<F>(&self, listener: F) -> Result<(), QueueError>
|
||||
where F: Fn(QueueEvent) -> () {
|
||||
let recv = self.receiver.lock().unwrap().take();
|
||||
let recv = self.receiver.locked().take();
|
||||
if let None = recv {
|
||||
return Err(QueueError::AlreadyUsed);
|
||||
}
|
||||
@@ -208,13 +208,13 @@ impl ConfirmationsQueue {
|
||||
/// Notifies receiver about the event happening in this queue.
|
||||
fn notify(&self, message: QueueEvent) {
|
||||
// We don't really care about the result
|
||||
let _ = self.sender.lock().unwrap().send(message);
|
||||
let _ = self.sender.locked().send(message);
|
||||
}
|
||||
|
||||
/// Removes transaction from this queue and notifies `ConfirmationPromise` holders about the result.
|
||||
/// Notifies also a receiver about that event.
|
||||
fn remove(&self, id: U256, result: Option<RpcResult>) -> Option<TransactionConfirmation> {
|
||||
let token = self.queue.write().unwrap().remove(&id);
|
||||
let token = self.queue.unwrapped_write().remove(&id);
|
||||
|
||||
if let Some(token) = token {
|
||||
// notify receiver about the event
|
||||
@@ -241,13 +241,13 @@ impl SigningQueue for ConfirmationsQueue {
|
||||
fn add_request(&self, transaction: TransactionRequest) -> ConfirmationPromise {
|
||||
// Increment id
|
||||
let id = {
|
||||
let mut last_id = self.id.lock().unwrap();
|
||||
let mut last_id = self.id.locked();
|
||||
*last_id = *last_id + U256::from(1);
|
||||
*last_id
|
||||
};
|
||||
// Add request to queue
|
||||
let res = {
|
||||
let mut queue = self.queue.write().unwrap();
|
||||
let mut queue = self.queue.unwrapped_write();
|
||||
queue.insert(id, ConfirmationToken {
|
||||
result: Arc::new(Mutex::new(ConfirmationResult::Waiting)),
|
||||
handle: thread::current(),
|
||||
@@ -266,7 +266,7 @@ impl SigningQueue for ConfirmationsQueue {
|
||||
}
|
||||
|
||||
fn peek(&self, id: &U256) -> Option<TransactionConfirmation> {
|
||||
self.queue.read().unwrap().get(id).map(|token| token.request.clone())
|
||||
self.queue.unwrapped_read().get(id).map(|token| token.request.clone())
|
||||
}
|
||||
|
||||
fn request_rejected(&self, id: U256) -> Option<TransactionConfirmation> {
|
||||
@@ -280,17 +280,17 @@ impl SigningQueue for ConfirmationsQueue {
|
||||
}
|
||||
|
||||
fn requests(&self) -> Vec<TransactionConfirmation> {
|
||||
let queue = self.queue.read().unwrap();
|
||||
let queue = self.queue.unwrapped_read();
|
||||
queue.values().map(|token| token.request.clone()).collect()
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
let queue = self.queue.read().unwrap();
|
||||
let queue = self.queue.unwrapped_read();
|
||||
queue.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
let queue = self.queue.read().unwrap();
|
||||
let queue = self.queue.unwrapped_read();
|
||||
queue.is_empty()
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ mod test {
|
||||
use std::time::Duration;
|
||||
use std::thread;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use util::{Address, U256, H256};
|
||||
use util::{Address, U256, H256, Lockable};
|
||||
use v1::helpers::{SigningQueue, ConfirmationsQueue, QueueEvent, TransactionRequest};
|
||||
use v1::types::H256 as NH256;
|
||||
use jsonrpc_core::to_value;
|
||||
@@ -354,7 +354,7 @@ mod test {
|
||||
let r = received.clone();
|
||||
let handle = thread::spawn(move || {
|
||||
q.start_listening(move |notification| {
|
||||
let mut v = r.lock().unwrap();
|
||||
let mut v = r.locked();
|
||||
*v = Some(notification);
|
||||
}).expect("Should be closed nicely.")
|
||||
});
|
||||
@@ -363,7 +363,7 @@ mod test {
|
||||
|
||||
// then
|
||||
handle.join().expect("Thread should finish nicely");
|
||||
let r = received.lock().unwrap().take();
|
||||
let r = received.locked().take();
|
||||
assert_eq!(r, Some(QueueEvent::NewRequest(U256::from(1))));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ use jsonrpc_core::*;
|
||||
use util::numbers::*;
|
||||
use util::sha3::*;
|
||||
use util::rlp::{encode, decode, UntrustedRlp, View};
|
||||
use util::Lockable;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::client::{MiningBlockChainClient, BlockID, TransactionID, UncleID};
|
||||
use ethcore::header::Header as BlockHeader;
|
||||
@@ -561,7 +562,7 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
miner.map_sealing_work(client.deref(), |b| {
|
||||
let pow_hash = b.hash();
|
||||
let target = Ethash::difficulty_to_boundary(b.block().header().difficulty());
|
||||
let seed_hash = self.seed_compute.lock().unwrap().get_seedhash(b.block().header().number());
|
||||
let seed_hash = self.seed_compute.locked().get_seedhash(b.block().header().number());
|
||||
let block_number = RpcU256::from(b.block().header().number());
|
||||
to_value(&(RpcH256::from(pow_hash), RpcH256::from(seed_hash), RpcH256::from(target), block_number))
|
||||
}).unwrap_or(Err(Error::internal_error())) // no work found.
|
||||
|
||||
@@ -20,6 +20,7 @@ use std::ops::Deref;
|
||||
use std::sync::{Arc, Weak, Mutex};
|
||||
use std::collections::HashSet;
|
||||
use jsonrpc_core::*;
|
||||
use util::Lockable;
|
||||
use util::numbers::*;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::filter::Filter as EthcoreFilter;
|
||||
@@ -68,7 +69,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
try!(self.active());
|
||||
from_params::<(Filter,)>(params)
|
||||
.and_then(|(filter,)| {
|
||||
let mut polls = self.polls.lock().unwrap();
|
||||
let mut polls = self.polls.locked();
|
||||
let block_number = take_weak!(self.client).chain_info().best_block_number;
|
||||
let id = polls.create_poll(PollFilter::Logs(block_number, Default::default(), filter));
|
||||
to_value(&RpcU256::from(id))
|
||||
@@ -79,7 +80,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
try!(self.active());
|
||||
match params {
|
||||
Params::None => {
|
||||
let mut polls = self.polls.lock().unwrap();
|
||||
let mut polls = self.polls.locked();
|
||||
let id = polls.create_poll(PollFilter::Block(take_weak!(self.client).chain_info().best_block_number));
|
||||
to_value(&RpcU256::from(id))
|
||||
},
|
||||
@@ -91,7 +92,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
try!(self.active());
|
||||
match params {
|
||||
Params::None => {
|
||||
let mut polls = self.polls.lock().unwrap();
|
||||
let mut polls = self.polls.locked();
|
||||
let pending_transactions = take_weak!(self.miner).pending_transactions_hashes();
|
||||
let id = polls.create_poll(PollFilter::PendingTransaction(pending_transactions));
|
||||
|
||||
@@ -106,7 +107,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
let client = take_weak!(self.client);
|
||||
from_params::<(Index,)>(params)
|
||||
.and_then(|(index,)| {
|
||||
let mut polls = self.polls.lock().unwrap();
|
||||
let mut polls = self.polls.locked();
|
||||
match polls.poll_mut(&index.value()) {
|
||||
None => Ok(Value::Array(vec![] as Vec<Value>)),
|
||||
Some(filter) => match *filter {
|
||||
@@ -196,7 +197,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
try!(self.active());
|
||||
from_params::<(Index,)>(params)
|
||||
.and_then(|(index,)| {
|
||||
let mut polls = self.polls.lock().unwrap();
|
||||
let mut polls = self.polls.locked();
|
||||
match polls.poll(&index.value()) {
|
||||
Some(&PollFilter::Logs(ref _block_number, ref _previous_log, ref filter)) => {
|
||||
let include_pending = filter.to_block == Some(BlockNumber::Pending);
|
||||
@@ -222,7 +223,7 @@ impl<C, M> EthFilter for EthFilterClient<C, M> where
|
||||
try!(self.active());
|
||||
from_params::<(Index,)>(params)
|
||||
.and_then(|(index,)| {
|
||||
self.polls.lock().unwrap().remove_poll(&index.value());
|
||||
self.polls.locked().remove_poll(&index.value());
|
||||
to_value(&true)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Test implementation of miner service.
|
||||
|
||||
use util::{Address, H256, Bytes, U256, FixedHash, Uint};
|
||||
use util::{Address, H256, Bytes, U256, FixedHash, Uint, Lockable, RwLockable};
|
||||
use util::standard::*;
|
||||
use ethcore::error::{Error, ExecutionError};
|
||||
use ethcore::client::{MiningBlockChainClient, Executed, CallAnalytics};
|
||||
@@ -76,68 +76,68 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
fn set_author(&self, author: Address) {
|
||||
*self.author.write().unwrap() = author;
|
||||
*self.author.unwrapped_write() = author;
|
||||
}
|
||||
|
||||
fn set_extra_data(&self, extra_data: Bytes) {
|
||||
*self.extra_data.write().unwrap() = extra_data;
|
||||
*self.extra_data.unwrapped_write() = extra_data;
|
||||
}
|
||||
|
||||
/// Set the lower gas limit we wish to target when sealing a new block.
|
||||
fn set_gas_floor_target(&self, target: U256) {
|
||||
self.gas_range_target.write().unwrap().0 = target;
|
||||
self.gas_range_target.unwrapped_write().0 = target;
|
||||
}
|
||||
|
||||
/// Set the upper gas limit we wish to target when sealing a new block.
|
||||
fn set_gas_ceil_target(&self, target: U256) {
|
||||
self.gas_range_target.write().unwrap().1 = target;
|
||||
self.gas_range_target.unwrapped_write().1 = target;
|
||||
}
|
||||
|
||||
fn set_minimal_gas_price(&self, min_gas_price: U256) {
|
||||
*self.min_gas_price.write().unwrap() = min_gas_price;
|
||||
*self.min_gas_price.unwrapped_write() = min_gas_price;
|
||||
}
|
||||
|
||||
fn set_transactions_limit(&self, limit: usize) {
|
||||
*self.limit.write().unwrap() = limit;
|
||||
*self.limit.unwrapped_write() = limit;
|
||||
}
|
||||
|
||||
fn set_tx_gas_limit(&self, limit: U256) {
|
||||
*self.tx_gas_limit.write().unwrap() = limit;
|
||||
*self.tx_gas_limit.unwrapped_write() = limit;
|
||||
}
|
||||
|
||||
fn transactions_limit(&self) -> usize {
|
||||
*self.limit.read().unwrap()
|
||||
*self.limit.unwrapped_read()
|
||||
}
|
||||
|
||||
fn author(&self) -> Address {
|
||||
*self.author.read().unwrap()
|
||||
*self.author.unwrapped_read()
|
||||
}
|
||||
|
||||
fn minimal_gas_price(&self) -> U256 {
|
||||
*self.min_gas_price.read().unwrap()
|
||||
*self.min_gas_price.unwrapped_read()
|
||||
}
|
||||
|
||||
fn extra_data(&self) -> Bytes {
|
||||
self.extra_data.read().unwrap().clone()
|
||||
self.extra_data.unwrapped_read().clone()
|
||||
}
|
||||
|
||||
fn gas_floor_target(&self) -> U256 {
|
||||
self.gas_range_target.read().unwrap().0
|
||||
self.gas_range_target.unwrapped_read().0
|
||||
}
|
||||
|
||||
fn gas_ceil_target(&self) -> U256 {
|
||||
self.gas_range_target.read().unwrap().1
|
||||
self.gas_range_target.unwrapped_read().1
|
||||
}
|
||||
|
||||
/// Imports transactions to transaction queue.
|
||||
fn import_external_transactions(&self, _chain: &MiningBlockChainClient, transactions: Vec<SignedTransaction>) ->
|
||||
Vec<Result<TransactionImportResult, Error>> {
|
||||
// lets assume that all txs are valid
|
||||
self.imported_transactions.lock().unwrap().extend_from_slice(&transactions);
|
||||
self.imported_transactions.locked().extend_from_slice(&transactions);
|
||||
|
||||
for sender in transactions.iter().filter_map(|t| t.sender().ok()) {
|
||||
let nonce = self.last_nonce(&sender).expect("last_nonce must be populated in tests");
|
||||
self.last_nonces.write().unwrap().insert(sender, nonce + U256::from(1));
|
||||
self.last_nonces.unwrapped_write().insert(sender, nonce + U256::from(1));
|
||||
}
|
||||
transactions
|
||||
.iter()
|
||||
@@ -152,11 +152,11 @@ impl MinerService for TestMinerService {
|
||||
// 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));
|
||||
self.last_nonces.unwrapped_write().insert(sender.clone(), nonce + U256::from(1));
|
||||
}
|
||||
|
||||
// lets assume that all txs are valid
|
||||
self.imported_transactions.lock().unwrap().push(transaction);
|
||||
self.imported_transactions.locked().push(transaction);
|
||||
|
||||
Ok(TransactionImportResult::Current)
|
||||
}
|
||||
@@ -186,23 +186,23 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
fn transaction(&self, hash: &H256) -> Option<SignedTransaction> {
|
||||
self.pending_transactions.lock().unwrap().get(hash).cloned()
|
||||
self.pending_transactions.locked().get(hash).cloned()
|
||||
}
|
||||
|
||||
fn all_transactions(&self) -> Vec<SignedTransaction> {
|
||||
self.pending_transactions.lock().unwrap().values().cloned().collect()
|
||||
self.pending_transactions.locked().values().cloned().collect()
|
||||
}
|
||||
|
||||
fn pending_transactions(&self) -> Vec<SignedTransaction> {
|
||||
self.pending_transactions.lock().unwrap().values().cloned().collect()
|
||||
self.pending_transactions.locked().values().cloned().collect()
|
||||
}
|
||||
|
||||
fn pending_receipts(&self) -> BTreeMap<H256, Receipt> {
|
||||
self.pending_receipts.lock().unwrap().clone()
|
||||
self.pending_receipts.locked().clone()
|
||||
}
|
||||
|
||||
fn last_nonce(&self, address: &Address) -> Option<U256> {
|
||||
self.last_nonces.read().unwrap().get(address).cloned()
|
||||
self.last_nonces.unwrapped_read().get(address).cloned()
|
||||
}
|
||||
|
||||
/// Submit `seal` as a valid solution for the header of `pow_hash`.
|
||||
@@ -212,7 +212,7 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
fn balance(&self, _chain: &MiningBlockChainClient, address: &Address) -> U256 {
|
||||
self.latest_closed_block.lock().unwrap().as_ref().map_or_else(U256::zero, |b| b.block().fields().state.balance(address).clone())
|
||||
self.latest_closed_block.locked().as_ref().map_or_else(U256::zero, |b| b.block().fields().state.balance(address).clone())
|
||||
}
|
||||
|
||||
fn call(&self, _chain: &MiningBlockChainClient, _t: &SignedTransaction, _analytics: CallAnalytics) -> Result<Executed, ExecutionError> {
|
||||
@@ -220,7 +220,7 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
fn storage_at(&self, _chain: &MiningBlockChainClient, address: &Address, position: &H256) -> H256 {
|
||||
self.latest_closed_block.lock().unwrap().as_ref().map_or_else(H256::default, |b| b.block().fields().state.storage_at(address, position).clone())
|
||||
self.latest_closed_block.locked().as_ref().map_or_else(H256::default, |b| b.block().fields().state.storage_at(address, position).clone())
|
||||
}
|
||||
|
||||
fn nonce(&self, _chain: &MiningBlockChainClient, address: &Address) -> U256 {
|
||||
@@ -230,7 +230,7 @@ impl MinerService for TestMinerService {
|
||||
}
|
||||
|
||||
fn code(&self, _chain: &MiningBlockChainClient, address: &Address) -> Option<Bytes> {
|
||||
self.latest_closed_block.lock().unwrap().as_ref().map_or(None, |b| b.block().fields().state.code(address).clone())
|
||||
self.latest_closed_block.locked().as_ref().map_or(None, |b| b.block().fields().state.code(address).clone())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Test implementation of SyncProvider.
|
||||
|
||||
use util::U256;
|
||||
use util::{U256, RwLockable};
|
||||
use ethsync::{SyncProvider, SyncStatus, SyncState};
|
||||
use std::sync::RwLock;
|
||||
|
||||
@@ -57,7 +57,7 @@ impl TestSyncProvider {
|
||||
|
||||
impl SyncProvider for TestSyncProvider {
|
||||
fn status(&self) -> SyncStatus {
|
||||
self.status.read().unwrap().clone()
|
||||
self.status.unwrapped_read().clone()
|
||||
}
|
||||
|
||||
fn start_network(&self) {
|
||||
|
||||
@@ -18,6 +18,7 @@ use std::str::FromStr;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::{Lockable, RwLockable};
|
||||
use util::hash::{Address, H256, FixedHash};
|
||||
use util::numbers::{Uint, U256};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
@@ -103,13 +104,13 @@ fn rpc_eth_syncing() {
|
||||
assert_eq!(tester.io.handle_request(request), Some(false_res.to_owned()));
|
||||
|
||||
{
|
||||
let mut status = tester.sync.status.write().unwrap();
|
||||
let mut status = tester.sync.status.unwrapped_write();
|
||||
status.state = SyncState::Blocks;
|
||||
status.highest_block_number = Some(2500);
|
||||
|
||||
// "sync" to 1000 blocks.
|
||||
// causes TestBlockChainClient to return 1000 for its best block number.
|
||||
let mut blocks = tester.client.blocks.write().unwrap();
|
||||
let mut blocks = tester.client.blocks.unwrapped_write();
|
||||
for i in 0..1000 {
|
||||
blocks.insert(H256::from(i), Vec::new());
|
||||
}
|
||||
@@ -120,7 +121,7 @@ fn rpc_eth_syncing() {
|
||||
|
||||
{
|
||||
// finish "syncing"
|
||||
let mut blocks = tester.client.blocks.write().unwrap();
|
||||
let mut blocks = tester.client.blocks.unwrapped_write();
|
||||
for i in 0..1500 {
|
||||
blocks.insert(H256::from(i + 1000), Vec::new());
|
||||
}
|
||||
@@ -132,9 +133,9 @@ fn rpc_eth_syncing() {
|
||||
#[test]
|
||||
fn rpc_eth_hashrate() {
|
||||
let tester = EthTester::default();
|
||||
tester.hashrates.write().unwrap().insert(H256::from(0), U256::from(0xfffa));
|
||||
tester.hashrates.write().unwrap().insert(H256::from(0), U256::from(0xfffb));
|
||||
tester.hashrates.write().unwrap().insert(H256::from(1), U256::from(0x1));
|
||||
tester.hashrates.unwrapped_write().insert(H256::from(0), U256::from(0xfffa));
|
||||
tester.hashrates.unwrapped_write().insert(H256::from(0), U256::from(0xfffb));
|
||||
tester.hashrates.unwrapped_write().insert(H256::from(1), U256::from(0x1));
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "eth_hashrate", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":"0xfffc","id":1}"#;
|
||||
@@ -157,7 +158,7 @@ fn rpc_eth_submit_hashrate() {
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
|
||||
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||
assert_eq!(tester.hashrates.read().unwrap().get(&H256::from("0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c")).cloned(),
|
||||
assert_eq!(tester.hashrates.unwrapped_read().get(&H256::from("0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c")).cloned(),
|
||||
Some(U256::from(0x500_000)));
|
||||
}
|
||||
|
||||
@@ -214,7 +215,7 @@ fn rpc_eth_mining() {
|
||||
let response = r#"{"jsonrpc":"2.0","result":false,"id":1}"#;
|
||||
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||
|
||||
tester.hashrates.write().unwrap().insert(H256::from(1), U256::from(0x1));
|
||||
tester.hashrates.unwrapped_write().insert(H256::from(1), U256::from(0x1));
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "eth_mining", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||
@@ -363,7 +364,7 @@ fn rpc_eth_pending_transaction_by_hash() {
|
||||
let tester = EthTester::default();
|
||||
{
|
||||
let tx: SignedTransaction = decode(&FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap());
|
||||
tester.miner.pending_transactions.lock().unwrap().insert(H256::zero(), tx);
|
||||
tester.miner.pending_transactions.locked().insert(H256::zero(), tx);
|
||||
}
|
||||
|
||||
let response = r#"{"jsonrpc":"2.0","result":{"blockHash":null,"blockNumber":null,"creates":null,"from":"0x0f65fe9276bc9a24ae7083ae28e2660ef72df99e","gas":"0x5208","gasPrice":"0x01","hash":"0x41df922fd0d4766fcc02e161f8295ec28522f329ae487f14d811e4b64c8d6e31","input":"0x","nonce":"0x00","to":"0x095e7baea6a6c7c4c2dfeb977efac326af552d87","transactionIndex":null,"value":"0x0a"},"id":1}"#;
|
||||
@@ -590,7 +591,7 @@ fn rpc_eth_send_transaction() {
|
||||
|
||||
assert_eq!(tester.io.handle_request(&request), Some(response));
|
||||
|
||||
tester.miner.last_nonces.write().unwrap().insert(address.clone(), U256::zero());
|
||||
tester.miner.last_nonces.unwrapped_write().insert(address.clone(), U256::zero());
|
||||
|
||||
let t = Transaction {
|
||||
nonce: U256::one(),
|
||||
@@ -748,7 +749,7 @@ fn returns_error_if_can_mine_and_no_closed_block() {
|
||||
use ethsync::{SyncState};
|
||||
|
||||
let eth_tester = EthTester::default();
|
||||
eth_tester.sync.status.write().unwrap().state = SyncState::Idle;
|
||||
eth_tester.sync.status.unwrapped_write().state = SyncState::Idle;
|
||||
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal error","data":null},"id":1}"#;
|
||||
|
||||
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::numbers::*;
|
||||
use util::RwLockable;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use v1::{PersonalClient, Personal};
|
||||
use v1::tests::helpers::TestMinerService;
|
||||
@@ -174,7 +175,7 @@ fn sign_and_send_transaction() {
|
||||
|
||||
assert_eq!(tester.io.handle_request(request.as_ref()), Some(response));
|
||||
|
||||
tester.miner.last_nonces.write().unwrap().insert(address.clone(), U256::zero());
|
||||
tester.miner.last_nonces.unwrapped_write().insert(address.clone(), U256::zero());
|
||||
|
||||
let t = Transaction {
|
||||
nonce: U256::one(),
|
||||
|
||||
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::numbers::*;
|
||||
use util::Lockable;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::client::TestBlockChainClient;
|
||||
use ethcore::transaction::{Transaction, Action};
|
||||
@@ -112,7 +113,7 @@ fn should_reject_transaction_from_queue_without_dispatching() {
|
||||
// then
|
||||
assert_eq!(tester.io.handle_request(&request), Some(response.to_owned()));
|
||||
assert_eq!(tester.queue.requests().len(), 0);
|
||||
assert_eq!(tester.miner.imported_transactions.lock().unwrap().len(), 0);
|
||||
assert_eq!(tester.miner.imported_transactions.locked().len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -181,6 +182,6 @@ fn should_confirm_transaction_and_dispatch() {
|
||||
// then
|
||||
assert_eq!(tester.io.handle_request(&request), Some(response.to_owned()));
|
||||
assert_eq!(tester.queue.requests().len(), 0);
|
||||
assert_eq!(tester.miner.imported_transactions.lock().unwrap().len(), 1);
|
||||
assert_eq!(tester.miner.imported_transactions.locked().len(), 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user