Create network::Seed from swap::Seed instead of abstracting over byte array

This commit is contained in:
Daniel Karzel 2021-01-08 14:52:29 +11:00
parent f18d01dfaf
commit 664958939d
9 changed files with 23 additions and 23 deletions

View file

@ -66,7 +66,7 @@ async fn happy_path() {
xmr_alice,
alice_multiaddr.clone(),
config,
&Seed::random().unwrap(),
Seed::random().unwrap(),
)
.await;

View file

@ -59,7 +59,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
alice_xmr_starting_balance,
alice_multiaddr.clone(),
config,
&alice_seed,
alice_seed,
)
.await;
@ -128,7 +128,7 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
};
let (mut event_loop_after_restart, event_loop_handle_after_restart) =
testutils::init_alice_event_loop(alice_multiaddr, &alice_seed);
testutils::init_alice_event_loop(alice_multiaddr, alice_seed);
tokio::spawn(async move { event_loop_after_restart.run().await });
let alice_state = alice::swap::swap(

View file

@ -58,7 +58,7 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
alice_xmr_starting_balance,
alice_multiaddr.clone(),
config,
&Seed::random().unwrap(),
Seed::random().unwrap(),
)
.await;

View file

@ -60,7 +60,7 @@ async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
alice_xmr_starting_balance,
alice_multiaddr.clone(),
Config::regtest(),
&Seed::random().unwrap(),
Seed::random().unwrap(),
)
.await;

View file

@ -64,7 +64,7 @@ async fn alice_punishes_if_bob_never_acts_after_fund() {
alice_xmr_starting_balance,
alice_multiaddr.clone(),
config,
&Seed::random().unwrap(),
Seed::random().unwrap(),
)
.await;

View file

@ -64,7 +64,7 @@ async fn given_alice_restarts_after_xmr_is_locked_abort_swap() {
alice_xmr_starting_balance,
alice_multiaddr.clone(),
Config::regtest(),
&alice_seed,
alice_seed,
)
.await;
@ -124,7 +124,7 @@ async fn given_alice_restarts_after_xmr_is_locked_abort_swap() {
};
let (mut alice_event_loop_2, alice_event_loop_handle_2) =
testutils::init_alice_event_loop(alice_multiaddr, &alice_seed);
testutils::init_alice_event_loop(alice_multiaddr, alice_seed);
let alice_final_state = {
let alice_db = Database::open(alice_db_datadir.path()).unwrap();

View file

@ -107,12 +107,12 @@ pub async fn init_alice_state(
pub fn init_alice_event_loop(
listen: Multiaddr,
seed: &Seed,
seed: Seed,
) -> (
alice::event_loop::EventLoop,
alice::event_loop::EventLoopHandle,
) {
let alice_behaviour = alice::Behaviour::new(network::Seed::new(seed.bytes()));
let alice_behaviour = alice::Behaviour::new(network::Seed::new(seed));
let alice_transport = build(alice_behaviour.identity()).unwrap();
alice::event_loop::EventLoop::new(alice_transport, alice_behaviour, listen).unwrap()
}
@ -126,7 +126,7 @@ pub async fn init_alice(
xmr_starting_balance: monero::Amount,
listen: Multiaddr,
config: Config,
seed: &Seed,
seed: Seed,
) -> (
AliceState,
alice::event_loop::EventLoop,
@ -193,7 +193,7 @@ pub fn init_bob_event_loop(
alice_addr: Multiaddr,
) -> (bob::event_loop::EventLoop, bob::event_loop::EventLoopHandle) {
let seed = Seed::random().unwrap();
let bob_behaviour = bob::Behaviour::new(network::Seed::new(seed.bytes()));
let bob_behaviour = bob::Behaviour::new(network::Seed::new(seed));
let bob_transport = build(bob_behaviour.identity()).unwrap();
bob::event_loop::EventLoop::new(bob_transport, bob_behaviour, alice_peer_id, alice_addr)
.unwrap()