mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Remove unneeded peer id argument
This commit is contained in:
parent
9323f22009
commit
a22efaa7bc
@ -116,44 +116,61 @@ async fn alice_safe_restart_after_btc_is_locked() {
|
|||||||
xmr: xmr_to_swap,
|
xmr: xmr_to_swap,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (alice_swap, alice_peer_id) = {
|
let alice_swap = {
|
||||||
let rng = &mut OsRng;
|
let rng = &mut OsRng;
|
||||||
let alice_behaviour = alice::Behaviour::default();
|
let (alice_state, alice_behaviour) = {
|
||||||
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 a = bitcoin::SecretKey::new_random(rng);
|
||||||
let s_a = cross_curve_dleq::Scalar::random(rng);
|
let s_a = cross_curve_dleq::Scalar::random(rng);
|
||||||
let v_a = xmr_btc::monero::PrivateViewKey::new_random(rng);
|
let v_a = xmr_btc::monero::PrivateViewKey::new_random(rng);
|
||||||
AliceState::Started {
|
let redeem_address = alice_btc_wallet.as_ref().new_address().await.unwrap();
|
||||||
amounts,
|
let punish_address = redeem_address.clone();
|
||||||
|
let state0 = xmr_btc::alice::State0::new(
|
||||||
a,
|
a,
|
||||||
s_a,
|
s_a,
|
||||||
v_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 =
|
let alice_transport = build(alice_behaviour.identity()).unwrap();
|
||||||
alice::new_swarm(alice_multiaddr.clone(), alice_transport, alice_behaviour).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 config = xmr_btc::config::Config::regtest();
|
||||||
let swap_id = Uuid::new_v4();
|
let swap_id = Uuid::new_v4();
|
||||||
let tmp_dir = TempDir::new().unwrap();
|
let tmp_dir = TempDir::new().unwrap();
|
||||||
let db = Database::open(tmp_dir.path()).unwrap();
|
let db = Database::open(tmp_dir.path()).unwrap();
|
||||||
|
|
||||||
(
|
|
||||||
alice::swap::swap(
|
alice::swap::swap(
|
||||||
alice_state,
|
alice_state,
|
||||||
alice_swarm,
|
alice_event_loop_handle,
|
||||||
alice_btc_wallet.clone(),
|
alice_btc_wallet.clone(),
|
||||||
alice_xmr_wallet.clone(),
|
alice_xmr_wallet.clone(),
|
||||||
config,
|
config,
|
||||||
swap_id,
|
swap_id,
|
||||||
db,
|
db,
|
||||||
),
|
|
||||||
alice_peer_id,
|
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let bob_swap = {
|
let (bob_swap, bob_event_loop) = {
|
||||||
let rng = &mut OsRng;
|
let rng = &mut OsRng;
|
||||||
let bob_db_dir = tempdir().unwrap();
|
let bob_db_dir = tempdir().unwrap();
|
||||||
let bob_db = Database::open(bob_db_dir.path()).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 {
|
let bob_state = BobState::Started {
|
||||||
state0,
|
state0,
|
||||||
amounts,
|
amounts,
|
||||||
peer_id: alice_peer_id,
|
|
||||||
addr: alice_multiaddr,
|
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::swap::swap(
|
||||||
bob_state,
|
bob_state,
|
||||||
bob_swarm,
|
bob_event_loop_handle,
|
||||||
bob_db,
|
bob_db,
|
||||||
bob_btc_wallet.clone(),
|
bob_btc_wallet.clone(),
|
||||||
bob_xmr_wallet.clone(),
|
bob_xmr_wallet.clone(),
|
||||||
OsRng,
|
OsRng,
|
||||||
Uuid::new_v4(),
|
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();
|
try_join(alice_swap, bob_swap).await.unwrap();
|
||||||
|
|
||||||
let btc_alice_final = alice_btc_wallet.balance().await.unwrap();
|
let btc_alice_final = alice_btc_wallet.balance().await.unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user