sync_provider function

This commit is contained in:
debris 2016-03-11 11:03:43 +01:00
parent 3479a9bf95
commit 18939462c3

View File

@ -19,12 +19,16 @@ use jsonrpc_core::IoHandler;
use v1::{Net, NetClient}; use v1::{Net, NetClient};
use v1::tests::helpers::{Config, TestSyncProvider}; use v1::tests::helpers::{Config, TestSyncProvider};
#[test] fn sync_provider() -> Arc<TestSyncProvider> {
fn rpc_net_version() { Arc::new(TestSyncProvider::new(Config {
let sync = Arc::new(TestSyncProvider::new(Config {
protocol_version: 65, protocol_version: 65,
num_peers: 120, num_peers: 120,
})); }))
}
#[test]
fn rpc_net_version() {
let sync = sync_provider();
let net = NetClient::new(&sync).to_delegate(); let net = NetClient::new(&sync).to_delegate();
let io = IoHandler::new(); let io = IoHandler::new();
io.add_delegate(net); io.add_delegate(net);
@ -37,10 +41,7 @@ fn rpc_net_version() {
#[test] #[test]
fn rpc_net_peer_count() { fn rpc_net_peer_count() {
let sync = Arc::new(TestSyncProvider::new(Config { let sync = sync_provider();
protocol_version: 65,
num_peers: 120,
}));
let net = NetClient::new(&sync).to_delegate(); let net = NetClient::new(&sync).to_delegate();
let io = IoHandler::new(); let io = IoHandler::new();
io.add_delegate(net); io.add_delegate(net);
@ -53,10 +54,7 @@ fn rpc_net_peer_count() {
#[test] #[test]
fn rpc_net_listening() { fn rpc_net_listening() {
let sync = Arc::new(TestSyncProvider::new(Config { let sync = sync_provider();
protocol_version: 65,
num_peers: 120,
}));
let net = NetClient::new(&sync).to_delegate(); let net = NetClient::new(&sync).to_delegate();
let io = IoHandler::new(); let io = IoHandler::new();
io.add_delegate(net); io.add_delegate(net);