Skip to content

Commit 840f720

Browse files
committed
use Conf::default() for tests
1 parent b916441 commit 840f720

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

src/lib.rs

+14-30
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ impl BitcoinD {
150150
Err(_) => TempDir::new(),
151151
},
152152
}?;
153+
debug!("work_dir: {:?}", work_dir);
153154
let datadir = work_dir.path().to_path_buf();
154155
let cookie_file = datadir.join(conf.network).join(".cookie");
155156
let rpc_port = get_available_port()?;
@@ -329,15 +330,6 @@ mod test {
329330
assert_eq!(format!("127.0.0.1:{}", port), format!("{}", socket));
330331
}
331332

332-
#[test]
333-
fn test_default() {
334-
let conf = Conf {
335-
p2p: P2P::Yes,
336-
..Default::default()
337-
};
338-
assert_eq!("regtest", conf.network);
339-
}
340-
341333
#[test]
342334
fn test_bitcoind() {
343335
let exe = init();
@@ -371,41 +363,33 @@ mod test {
371363
#[test]
372364
fn test_p2p() {
373365
let exe = init();
374-
let conf = Conf {
375-
p2p: P2P::Yes,
376-
..Default::default()
377-
};
366+
let mut conf = Conf::default();
367+
conf.p2p = P2P::Yes;
368+
378369
let bitcoind = BitcoinD::with_conf(&exe, &conf).unwrap();
379370
assert_eq!(bitcoind.client.get_peer_info().unwrap().len(), 0);
380-
let other_conf = Conf {
381-
p2p: bitcoind.p2p_connect(false).unwrap(),
382-
..Default::default()
383-
};
371+
let mut other_conf = Conf::default();
372+
other_conf.p2p = bitcoind.p2p_connect(false).unwrap();
373+
384374
let other_bitcoind = BitcoinD::with_conf(&exe, &other_conf).unwrap();
385375
assert_eq!(bitcoind.client.get_peer_info().unwrap().len(), 1);
386376
assert_eq!(other_bitcoind.client.get_peer_info().unwrap().len(), 1);
387377
}
388378

389379
#[test]
390380
fn test_multi_p2p() {
391-
let conf_node1 = Conf {
392-
p2p: P2P::Yes,
393-
..Default::default()
394-
};
381+
let mut conf_node1 = Conf::default();
382+
conf_node1.p2p = P2P::Yes;
395383
let node1 = BitcoinD::with_conf(exe_path(), &conf_node1).unwrap();
396384

397385
// Create Node 2 connected Node 1
398-
let conf_node2 = Conf {
399-
p2p: node1.p2p_connect(true).unwrap(),
400-
..Default::default()
401-
};
386+
let mut conf_node2 = Conf::default();
387+
conf_node2.p2p = node1.p2p_connect(true).unwrap();
402388
let node2 = BitcoinD::with_conf(exe_path(), &conf_node2).unwrap();
403389

404-
// Create Node 3 Connected To Node 2
405-
let conf_node3 = Conf {
406-
p2p: node2.p2p_connect(false).unwrap(),
407-
..Default::default()
408-
};
390+
// Create Node 3 Connected To Node
391+
let mut conf_node3 = Conf::default();
392+
conf_node3.p2p = node2.p2p_connect(false).unwrap();
409393
let node3 = BitcoinD::with_conf(exe_path(), &conf_node3).unwrap();
410394

411395
// Get each nodes Peers

0 commit comments

Comments
 (0)