Get rid of unsafe code in ethkey, propagate incorrect Secret errors. (#4119)

* Implementing secret

* Fixing tests
This commit is contained in:
Tomasz Drwięga
2017-01-11 12:16:47 +01:00
committed by Gav Wood
parent 4ecd9da6e4
commit 21006da125
30 changed files with 205 additions and 108 deletions

View File

@@ -23,6 +23,7 @@ use network::{NetworkProtocolHandler, NetworkService, NetworkContext, PeerId, Pr
AllowIP as NetworkAllowIP};
use util::{U256, H256, H512};
use io::{TimerToken};
use ethcore::ethstore::ethkey::Secret;
use ethcore::client::{BlockChainClient, ChainNotify};
use ethcore::snapshot::SnapshotService;
use ethcore::header::BlockNumber;
@@ -476,7 +477,7 @@ pub struct NetworkConfiguration {
/// List of initial node addresses
pub boot_nodes: Vec<String>,
/// Use provided node key instead of default
pub use_secret: Option<H256>,
pub use_secret: Option<Secret>,
/// Max number of connected peers to maintain
pub max_peers: u32,
/// Min number of connected peers to maintain
@@ -667,3 +668,4 @@ impl ManageNetwork for LightSync {
NetworkConfiguration::from(self.network.config().clone())
}
}

View File

@@ -22,7 +22,7 @@ use ethcore::spec::Spec;
use ethcore::miner::MinerService;
use ethcore::transaction::*;
use ethcore::account_provider::AccountProvider;
use ethkey::KeyPair;
use ethkey::{KeyPair, Secret};
use super::helpers::*;
use SyncConfig;
@@ -41,7 +41,7 @@ impl IoHandler<ClientIoMessage> for TestIoHandler {
}
}
fn new_tx(secret: &H256, nonce: U256) -> PendingTransaction {
fn new_tx(secret: &Secret, nonce: U256) -> PendingTransaction {
let signed = Transaction {
nonce: nonce.into(),
gas_price: 0.into(),
@@ -55,8 +55,8 @@ fn new_tx(secret: &H256, nonce: U256) -> PendingTransaction {
#[test]
fn authority_round() {
let s0 = KeyPair::from_secret("1".sha3()).unwrap();
let s1 = KeyPair::from_secret("0".sha3()).unwrap();
let s0 = KeyPair::from_secret_slice(&"1".sha3()).unwrap();
let s1 = KeyPair::from_secret_slice(&"0".sha3()).unwrap();
let spec_factory = || {
let spec = Spec::new_test_round();
let account_provider = AccountProvider::transient_provider();
@@ -118,8 +118,8 @@ fn authority_round() {
#[test]
fn tendermint() {
let s0 = KeyPair::from_secret("1".sha3()).unwrap();
let s1 = KeyPair::from_secret("0".sha3()).unwrap();
let s0 = KeyPair::from_secret_slice(&"1".sha3()).unwrap();
let s1 = KeyPair::from_secret_slice(&"0".sha3()).unwrap();
let spec_factory = || {
let spec = Spec::new_test_tendermint();
let account_provider = AccountProvider::transient_provider();