xmr-btc-swap/xmr-btc/tests/harness/mod.rs
rishflab 39afb4196b Save and recover protocol state from disk
NOTE: This implementation saves secrets to disk! It is not
secure.

The storage API allows the caller to atomically record the state
of the protocol. The user can retrieve this recorded state and
re-commence the protocol from that point. The state is recorded
using a hard coded key, causing it to overwrite the previously
recorded state. This limitation means that this recovery
mechanism should not be used in a program that simultaneously
manages the execution of multiple swaps.

An e2e test was added to show how to save, recover and resume
protocol execution. This logic could also be integrated into the
run_until functions to automate saving but was not included at
this stage as protocol execution is currently under development.

Serialisation and deserialisation was implemented on the states
to allow the to be stored using the database. Currently the
secret's are also being stored to disk but should be recovered
from a seed or wallets.
2020-10-21 18:39:45 +11:00

38 lines
832 B
Rust

pub mod node;
pub mod storage;
pub mod transport;
pub mod wallet;
pub mod bob {
use xmr_btc::bob::State;
// TODO: use macro or generics
pub fn is_state5(state: &State) -> bool {
matches!(state, State::State5 { .. })
}
// TODO: use macro or generics
pub fn is_state3(state: &State) -> bool {
matches!(state, State::State3 { .. })
}
}
pub mod alice {
use xmr_btc::alice::State;
// TODO: use macro or generics
pub fn is_state4(state: &State) -> bool {
matches!(state, State::State4 { .. })
}
// TODO: use macro or generics
pub fn is_state5(state: &State) -> bool {
matches!(state, State::State5 { .. })
}
// TODO: use macro or generics
pub fn is_state6(state: &State) -> bool {
matches!(state, State::State6 { .. })
}
}