@ -18,6 +18,7 @@ mod tests {
use monero_harness ::Monero ;
use monero_harness ::Monero ;
use rand ::rngs ::OsRng ;
use rand ::rngs ::OsRng ;
use crate ::harness ::storage ::Database ;
use std ::{ convert ::TryInto , path ::Path } ;
use std ::{ convert ::TryInto , path ::Path } ;
use testcontainers ::clients ::Cli ;
use testcontainers ::clients ::Cli ;
use tracing_subscriber ::util ::SubscriberInitExt ;
use tracing_subscriber ::util ::SubscriberInitExt ;
@ -251,8 +252,10 @@ mod tests {
let cli = Cli ::default ( ) ;
let cli = Cli ::default ( ) ;
let ( monero , _container ) = Monero ::new ( & cli ) ;
let ( monero , _container ) = Monero ::new ( & cli ) ;
let bitcoind = init_bitcoind ( & cli ) . await ;
let bitcoind = init_bitcoind ( & cli ) . await ;
let alice_db = harness ::storage ::Database ::open ( Path ::new ( ALICE_TEST_DB_FOLDER ) ) . unwrap ( ) ;
let alice_db : Database < alice ::State > =
let bob_db = harness ::storage ::Database ::open ( Path ::new ( BOB_TEST_DB_FOLDER ) ) . unwrap ( ) ;
harness ::storage ::Database ::open ( Path ::new ( ALICE_TEST_DB_FOLDER ) ) . unwrap ( ) ;
let bob_db : Database < bob ::State > =
harness ::storage ::Database ::open ( Path ::new ( BOB_TEST_DB_FOLDER ) ) . unwrap ( ) ;
let (
let (
alice_state0 ,
alice_state0 ,
@ -281,29 +284,26 @@ mod tests {
. await
. await
. unwrap ( ) ;
. unwrap ( ) ;
let alice_state5 : alice ::State5 = alice_state . try_into ( ) . unwrap ( ) ;
let bob_state3 : bob ::State3 = bob_state . try_into ( ) . unwrap ( ) ;
// save state to db
// save state to db
alice_db . insert_latest_state ( & alice_state 5 ) . await . unwrap ( ) ;
alice_db . insert_latest_state ( & alice_state ) . await . unwrap ( ) ;
bob_db . insert_latest_state ( & bob_state 3 ) . await . unwrap ( ) ;
bob_db . insert_latest_state ( & bob_state ) . await . unwrap ( ) ;
} ;
} ;
let ( alice_state6 , bob_state5 ) = {
let ( alice_state6 , bob_state5 ) = {
// recover state from db
// recover state from db
let alice_state 5: alice ::State5 = alice_db . get_latest_state ( ) . unwrap ( ) ;
let alice_state = alice_db . get_latest_state ( ) . unwrap ( ) ;
let bob_state 3: bob ::State3 = bob_db . get_latest_state ( ) . unwrap ( ) ;
let bob_state = bob_db . get_latest_state ( ) . unwrap ( ) ;
let ( alice_state , bob_state ) = future ::try_join (
let ( alice_state , bob_state ) = future ::try_join (
run_alice_until (
run_alice_until (
& mut alice_node ,
& mut alice_node ,
alice_state 5. into ( ) ,
alice_state ,
harness ::alice ::is_state6 ,
harness ::alice ::is_state6 ,
& mut OsRng ,
& mut OsRng ,
) ,
) ,
run_bob_until (
run_bob_until (
& mut bob_node ,
& mut bob_node ,
bob_state 3. into ( ) ,
bob_state ,
harness ::bob ::is_state5 ,
harness ::bob ::is_state5 ,
& mut OsRng ,
& mut OsRng ,
) ,
) ,