fixed parsing blockchain file, added default account to rpc tests

This commit is contained in:
debris 2016-03-19 11:02:44 +01:00 committed by arkpar
parent cb246c26c0
commit 8f1618687c
3 changed files with 10 additions and 5 deletions

View File

@ -82,7 +82,8 @@ impl From<ethjson::blockchain::Account> for PodAccount {
code: a.code.into(),
storage: a.storage.into_iter().fold(BTreeMap::new(), |mut acc, (key, value)| {
let key: U256 = key.into();
acc.insert(H256::from(key), value.into());
let value: U256 = value.into();
acc.insert(H256::from(key), H256::from(value));
acc
})
}

View File

@ -31,7 +31,7 @@ pub struct Account {
/// Nonce.
pub nonce: Uint,
/// Storage.
pub storage: BTreeMap<Uint, H256>,
pub storage: BTreeMap<Uint, Uint>,
}
#[cfg(test)]

View File

@ -37,9 +37,10 @@ use ethcore::ethereum;
use ethcore::client::{BlockChainClient, Client, ClientConfig};
use devtools::RandomTempPath;
use util::IoChannel;
use rpc::v1::tests::helpers::{TestSyncProvider, Config as SyncConfig, TestMinerService, TestAccountProvider};
use rpc::v1::tests::helpers::{TestSyncProvider, Config as SyncConfig, TestMinerService, TestAccountProvider, TestAccount};
use rpc::v1::{Eth, EthClient};
use util::panics::MayPanic;
use util::hash::Address;
const USAGE: &'static str = r#"
Parity rpctest client.
@ -86,8 +87,9 @@ impl Configuration {
process::exit(1);
});
let tests: ethjson::blockchain::Test = serde_json::from_reader(file).unwrap_or_else(|_| {
let tests: ethjson::blockchain::Test = serde_json::from_reader(file).unwrap_or_else(|err| {
println!("Invalid json file.");
println!("{:?}", err);
process::exit(2);
});
@ -117,7 +119,9 @@ impl Configuration {
}));
let miner = Arc::new(TestMinerService::default());
let accounts = Arc::new(TestAccountProvider::new(HashMap::new()));
let mut accs = HashMap::new();
accs.insert(Address::from(1), TestAccount::new("test"));
let accounts = Arc::new(TestAccountProvider::new(accs));
let server = rpc::RpcServer::new();
server.add_delegate(EthClient::new(&client, &sync, &accounts, &miner).to_delegate());