Bumping sysui & topbar. personal_signerEnabled returns port
This commit is contained in:
parent
036b324804
commit
e5e238746b
@ -360,6 +360,14 @@ impl Configuration {
|
||||
if self.args.flag_geth { self.geth_ipc_path() }
|
||||
else { Configuration::replace_home(&self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone())) }
|
||||
}
|
||||
|
||||
pub fn signer_port(&self) -> Option<u16> {
|
||||
if self.args.flag_signer {
|
||||
Some(self.args.flag_signer_port)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -201,7 +201,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
let sync = EthSync::register(service.network(), sync_config, client.clone());
|
||||
|
||||
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
|
||||
signer_enabled: conf.args.flag_signer,
|
||||
signer_port: conf.signer_port(),
|
||||
signer_queue: Arc::new(rpc_apis::ConfirmationsQueue::default()),
|
||||
client: client.clone(),
|
||||
sync: sync.clone(),
|
||||
@ -244,7 +244,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
|
||||
// Set up a signer
|
||||
let signer_server = signer::start(signer::Configuration {
|
||||
enabled: deps_for_rpc_apis.signer_enabled,
|
||||
enabled: deps_for_rpc_apis.signer_port.is_some(),
|
||||
port: conf.args.flag_signer_port,
|
||||
signer_path: conf.directories().signer,
|
||||
}, signer::Dependencies {
|
||||
|
@ -79,7 +79,7 @@ impl FromStr for Api {
|
||||
}
|
||||
|
||||
pub struct Dependencies {
|
||||
pub signer_enabled: bool,
|
||||
pub signer_port: Option<u16>,
|
||||
pub signer_queue: Arc<ConfirmationsQueue>,
|
||||
pub client: Arc<Client>,
|
||||
pub sync: Arc<EthSync>,
|
||||
@ -146,14 +146,14 @@ pub fn setup_rpc<T: Extendable>(server: T, deps: Arc<Dependencies>, apis: ApiSet
|
||||
server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner).to_delegate());
|
||||
server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate());
|
||||
|
||||
if deps.signer_enabled {
|
||||
if deps.signer_port.is_some() {
|
||||
server.add_delegate(EthSigningQueueClient::new(&deps.signer_queue).to_delegate());
|
||||
} else {
|
||||
server.add_delegate(EthSigningUnsafeClient::new(&deps.client, &deps.secret_store, &deps.miner).to_delegate());
|
||||
}
|
||||
},
|
||||
Api::Personal => {
|
||||
server.add_delegate(PersonalClient::new(&deps.secret_store, &deps.client, &deps.miner, deps.signer_enabled).to_delegate());
|
||||
server.add_delegate(PersonalClient::new(&deps.secret_store, &deps.client, &deps.miner, deps.signer_port.clone()).to_delegate());
|
||||
},
|
||||
Api::Signer => {
|
||||
server.add_delegate(SignerClient::new(&deps.secret_store, &deps.client, &deps.miner, &deps.signer_queue).to_delegate());
|
||||
|
@ -31,18 +31,18 @@ pub struct PersonalClient<A, C, M>
|
||||
accounts: Weak<A>,
|
||||
client: Weak<C>,
|
||||
miner: Weak<M>,
|
||||
signer_enabled: bool,
|
||||
signer_port: Option<u16>,
|
||||
}
|
||||
|
||||
impl<A, C, M> PersonalClient<A, C, M>
|
||||
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
|
||||
/// Creates new PersonalClient
|
||||
pub fn new(store: &Arc<A>, client: &Arc<C>, miner: &Arc<M>, signer_enabled: bool) -> Self {
|
||||
pub fn new(store: &Arc<A>, client: &Arc<C>, miner: &Arc<M>, signer_port: Option<u16>) -> Self {
|
||||
PersonalClient {
|
||||
accounts: Arc::downgrade(store),
|
||||
client: Arc::downgrade(client),
|
||||
miner: Arc::downgrade(miner),
|
||||
signer_enabled: signer_enabled,
|
||||
signer_port: signer_port,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,9 @@ impl<A: 'static, C: 'static, M: 'static> Personal for PersonalClient<A, C, M>
|
||||
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
|
||||
|
||||
fn signer_enabled(&self, _: Params) -> Result<Value, Error> {
|
||||
to_value(&self.signer_enabled)
|
||||
self.signer_port
|
||||
.map(|v| to_value(&v))
|
||||
.unwrap_or_else(|| to_value(&false))
|
||||
}
|
||||
|
||||
fn accounts(&self, _: Params) -> Result<Value, Error> {
|
||||
|
@ -49,11 +49,11 @@ fn miner_service() -> Arc<TestMinerService> {
|
||||
Arc::new(TestMinerService::default())
|
||||
}
|
||||
|
||||
fn setup() -> PersonalTester {
|
||||
fn setup(signer: Option<u16>) -> PersonalTester {
|
||||
let accounts = accounts_provider();
|
||||
let client = blockchain_client();
|
||||
let miner = miner_service();
|
||||
let personal = PersonalClient::new(&accounts, &client, &miner, false);
|
||||
let personal = PersonalClient::new(&accounts, &client, &miner, signer);
|
||||
|
||||
let io = IoHandler::new();
|
||||
io.add_delegate(personal.to_delegate());
|
||||
@ -71,7 +71,7 @@ fn setup() -> PersonalTester {
|
||||
#[test]
|
||||
fn should_return_false_if_signer_is_disabled() {
|
||||
// given
|
||||
let tester = setup();
|
||||
let tester = setup(None);
|
||||
|
||||
// when
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#;
|
||||
@ -82,9 +82,23 @@ fn should_return_false_if_signer_is_disabled() {
|
||||
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_return_port_number_if_signer_is_enabled() {
|
||||
// given
|
||||
let tester = setup(Some(8180));
|
||||
|
||||
// when
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#;
|
||||
let response = r#"{"jsonrpc":"2.0","result":8180,"id":1}"#;
|
||||
|
||||
|
||||
// then
|
||||
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accounts() {
|
||||
let tester = setup();
|
||||
let tester = setup(None);
|
||||
tester.accounts.accounts
|
||||
.write()
|
||||
.unwrap()
|
||||
@ -98,7 +112,7 @@ fn accounts() {
|
||||
|
||||
#[test]
|
||||
fn new_account() {
|
||||
let tester = setup();
|
||||
let tester = setup(None);
|
||||
let request = r#"{"jsonrpc": "2.0", "method": "personal_newAccount", "params": ["pass"], "id": 1}"#;
|
||||
|
||||
let res = tester.io.handle_request(request);
|
||||
@ -122,7 +136,7 @@ fn sign_and_send_transaction_with_invalid_password() {
|
||||
let account = TestAccount::new("password123");
|
||||
let address = account.address();
|
||||
|
||||
let tester = setup();
|
||||
let tester = setup(None);
|
||||
tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
|
||||
let request = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
@ -148,7 +162,7 @@ fn sign_and_send_transaction() {
|
||||
let address = account.address();
|
||||
let secret = account.secret.clone();
|
||||
|
||||
let tester = setup();
|
||||
let tester = setup(None);
|
||||
tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
|
||||
let request = r#"{
|
||||
"jsonrpc": "2.0",
|
||||
|
Loading…
Reference in New Issue
Block a user