Remove unneeded peer id argument

This commit is contained in:
Franck Royer 2020-12-04 16:04:24 +11:00
parent 9323f22009
commit a22efaa7bc
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4

View File

@ -116,44 +116,61 @@ async fn alice_safe_restart_after_btc_is_locked() {
xmr: xmr_to_swap,
};
let (alice_swap, alice_peer_id) = {
let alice_swap = {
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 (alice_state, alice_behaviour) = {
let a = bitcoin::SecretKey::new_random(rng);
let s_a = cross_curve_dleq::Scalar::random(rng);
let v_a = xmr_btc::monero::PrivateViewKey::new_random(rng);
AliceState::Started {
amounts,
let redeem_address = alice_btc_wallet.as_ref().new_address().await.unwrap();
let punish_address = redeem_address.clone();
let state0 = xmr_btc::alice::State0::new(
a,
s_a,
v_a,
}
amounts.btc,
amounts.xmr,
REFUND_TIMELOCK,
PUNISH_TIMELOCK,
redeem_address,
punish_address,
);
(
AliceState::Started {
amounts,
state0: state0.clone(),
},
alice::Behaviour::new(state0),
)
};
let alice_swarm =
alice::new_swarm(alice_multiaddr.clone(), alice_transport, alice_behaviour).unwrap();
let alice_transport = build(alice_behaviour.identity()).unwrap();
let (mut alice_event_loop, alice_event_loop_handle) = alice::event_loop::EventLoop::new(
alice_transport,
alice_behaviour,
alice_multiaddr.clone(),
)
.unwrap();
let _alice_swarm_fut = tokio::spawn(async move { alice_event_loop.run().await });
let config = xmr_btc::config::Config::regtest();
let swap_id = Uuid::new_v4();
let tmp_dir = TempDir::new().unwrap();
let db = Database::open(tmp_dir.path()).unwrap();
(
alice::swap::swap(
alice_state,
alice_swarm,
alice_event_loop_handle,
alice_btc_wallet.clone(),
alice_xmr_wallet.clone(),
config,
swap_id,
db,
),
alice_peer_id,
)
};
let bob_swap = {
let (bob_swap, bob_event_loop) = {
let rng = &mut OsRng;
let bob_db_dir = tempdir().unwrap();
let bob_db = Database::open(bob_db_dir.path()).unwrap();
@ -172,21 +189,27 @@ async fn alice_safe_restart_after_btc_is_locked() {
let bob_state = BobState::Started {
state0,
amounts,
peer_id: alice_peer_id,
addr: alice_multiaddr,
};
let bob_swarm = bob::new_swarm(bob_transport, bob_behaviour).unwrap();
let (bob_event_loop, bob_event_loop_handle) =
bob::event_loop::EventLoop::new(bob_transport, bob_behaviour).unwrap();
(
bob::swap::swap(
bob_state,
bob_swarm,
bob_event_loop_handle,
bob_db,
bob_btc_wallet.clone(),
bob_xmr_wallet.clone(),
OsRng,
Uuid::new_v4(),
),
bob_event_loop,
)
};
let _bob_event_loop = tokio::spawn(async move { bob_event_loop.run().await });
try_join(alice_swap, bob_swap).await.unwrap();
let btc_alice_final = alice_btc_wallet.balance().await.unwrap();