fixed parsing blockchain file, added default account to rpc tests
This commit is contained in:
parent
1d822132f0
commit
906e9b395e
@ -82,7 +82,8 @@ impl From<ethjson::blockchain::Account> for PodAccount {
|
|||||||
code: a.code.into(),
|
code: a.code.into(),
|
||||||
storage: a.storage.into_iter().fold(BTreeMap::new(), |mut acc, (key, value)| {
|
storage: a.storage.into_iter().fold(BTreeMap::new(), |mut acc, (key, value)| {
|
||||||
let key: U256 = key.into();
|
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
|
acc
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ pub struct Account {
|
|||||||
/// Nonce.
|
/// Nonce.
|
||||||
pub nonce: Uint,
|
pub nonce: Uint,
|
||||||
/// Storage.
|
/// Storage.
|
||||||
pub storage: BTreeMap<Uint, H256>,
|
pub storage: BTreeMap<Uint, Uint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -37,9 +37,10 @@ use ethcore::ethereum;
|
|||||||
use ethcore::client::{BlockChainClient, Client, ClientConfig};
|
use ethcore::client::{BlockChainClient, Client, ClientConfig};
|
||||||
use devtools::RandomTempPath;
|
use devtools::RandomTempPath;
|
||||||
use util::IoChannel;
|
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 rpc::v1::{Eth, EthClient};
|
||||||
use util::panics::MayPanic;
|
use util::panics::MayPanic;
|
||||||
|
use util::hash::Address;
|
||||||
|
|
||||||
const USAGE: &'static str = r#"
|
const USAGE: &'static str = r#"
|
||||||
Parity rpctest client.
|
Parity rpctest client.
|
||||||
@ -86,8 +87,9 @@ impl Configuration {
|
|||||||
process::exit(1);
|
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!("Invalid json file.");
|
||||||
|
println!("{:?}", err);
|
||||||
process::exit(2);
|
process::exit(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -117,7 +119,9 @@ impl Configuration {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
let miner = Arc::new(TestMinerService::default());
|
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();
|
let server = rpc::RpcServer::new();
|
||||||
server.add_delegate(EthClient::new(&client, &sync, &accounts, &miner).to_delegate());
|
server.add_delegate(EthClient::new(&client, &sync, &accounts, &miner).to_delegate());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user