implemented net_listening method
This commit is contained in:
parent
34a120e127
commit
8e52510dbb
@ -42,4 +42,9 @@ impl<S> Net for NetClient<S> where S: SyncProvider + 'static {
|
|||||||
fn peer_count(&self, _params: Params) -> Result<Value, Error> {
|
fn peer_count(&self, _params: Params) -> Result<Value, Error> {
|
||||||
Ok(Value::String(format!("0x{:x}", take_weak!(self.sync).status().num_peers as u64).to_owned()))
|
Ok(Value::String(format!("0x{:x}", take_weak!(self.sync).status().num_peers as u64).to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_listening(&self, _: Params) -> Result<Value, Error> {
|
||||||
|
// right now (11 march 2016), we are always listening for incoming connections
|
||||||
|
Ok(Value::Bool(true))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,3 +50,19 @@ fn rpc_net_peer_count() {
|
|||||||
|
|
||||||
assert_eq!(io.handle_request(request), Some(response.to_string()));
|
assert_eq!(io.handle_request(request), Some(response.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rpc_net_listening() {
|
||||||
|
let sync = Arc::new(TestSyncProvider::new(Config {
|
||||||
|
protocol_version: 65,
|
||||||
|
num_peers: 120,
|
||||||
|
}));
|
||||||
|
let net = NetClient::new(&sync).to_delegate();
|
||||||
|
let io = IoHandler::new();
|
||||||
|
io.add_delegate(net);
|
||||||
|
|
||||||
|
let request = r#"{"jsonrpc": "2.0", "method": "net_listening", "params": [], "id": 1}"#;
|
||||||
|
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||||
|
|
||||||
|
assert_eq!(io.handle_request(request), Some(response.to_string()));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user