Scope futures' instanciation

This commit is contained in:
Franck Royer 2020-12-04 14:41:05 +11:00
parent 6226e5789f
commit 1c7cc7ee46
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4

View File

@ -21,7 +21,7 @@ fn setup_tracing() {
.set_default();
}
// This is just to keep the container alive
// This is just to keep the containers alive
#[allow(dead_code)]
struct Containers<'a> {
bitcoind: Bitcoind<'a>,
@ -116,10 +116,11 @@ async fn alice_safe_restart_after_btc_is_locked() {
xmr: xmr_to_swap,
};
let alice_behaviour = alice::Behaviour::default();
let alice_peer_id = alice_behaviour.peer_id().clone();
let alice_transport = build(alice_behaviour.identity()).unwrap();
let (alice_swap, alice_peer_id) = {
let rng = &mut OsRng;
let alice_behaviour = alice::Behaviour::default();
let alice_peer_id = alice_behaviour.peer_id();
let alice_transport = build(alice_behaviour.identity()).unwrap();
let alice_state = {
let a = bitcoin::SecretKey::new_random(rng);
let s_a = cross_curve_dleq::Scalar::random(rng);
@ -137,7 +138,9 @@ async fn alice_safe_restart_after_btc_is_locked() {
let swap_id = Uuid::new_v4();
let tmp_dir = TempDir::new().unwrap();
let db = Database::open(tmp_dir.path()).unwrap();
let alice_swap = alice::swap::swap(
(
alice::swap::swap(
alice_state,
alice_swarm,
alice_btc_wallet.clone(),
@ -145,8 +148,13 @@ async fn alice_safe_restart_after_btc_is_locked() {
config,
swap_id,
db,
);
),
alice_peer_id,
)
};
let bob_swap = {
let rng = &mut OsRng;
let bob_db_dir = tempdir().unwrap();
let bob_db = Database::open(bob_db_dir.path()).unwrap();
let bob_behaviour = bob::Behaviour::default();
@ -168,7 +176,7 @@ async fn alice_safe_restart_after_btc_is_locked() {
addr: alice_multiaddr,
};
let bob_swarm = bob::new_swarm(bob_transport, bob_behaviour).unwrap();
let bob_swap = bob::swap::swap(
bob::swap::swap(
bob_state,
bob_swarm,
bob_db,
@ -176,7 +184,8 @@ async fn alice_safe_restart_after_btc_is_locked() {
bob_xmr_wallet.clone(),
OsRng,
Uuid::new_v4(),
);
)
};
try_join(alice_swap, bob_swap).await.unwrap();