mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Upgrade toolchain
Needed to use libp2p-async-await
This commit is contained in:
parent
e82383bcf6
commit
c316ea5244
@ -1,7 +1,7 @@
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
condense_wildcard_suffixes = true
|
condense_wildcard_suffixes = true
|
||||||
format_macro_matchers = true
|
format_macro_matchers = true
|
||||||
merge_imports = true
|
imports_granularity = "Crate"
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
format_code_in_doc_comments = true
|
format_code_in_doc_comments = true
|
||||||
normalize_comments = true
|
normalize_comments = true
|
||||||
|
@ -303,14 +303,11 @@ impl IntoIterator for Args {
|
|||||||
type IntoIter = ::std::vec::IntoIter<String>;
|
type IntoIter = ::std::vec::IntoIter<String>;
|
||||||
|
|
||||||
fn into_iter(self) -> <Self as IntoIterator>::IntoIter {
|
fn into_iter(self) -> <Self as IntoIterator>::IntoIter {
|
||||||
let mut args = Vec::new();
|
vec![
|
||||||
|
"/bin/bash".to_string(),
|
||||||
args.push("/bin/bash".into());
|
"-c".to_string(),
|
||||||
args.push("-c".into());
|
format!("{} ", self.image_args.args()),
|
||||||
|
]
|
||||||
let cmd = format!("{} ", self.image_args.args());
|
.into_iter()
|
||||||
args.push(cmd);
|
|
||||||
|
|
||||||
args.into_iter()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
nightly-2020-08-13
|
nightly-2021-01-31
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
condense_wildcard_suffixes = true
|
condense_wildcard_suffixes = true
|
||||||
format_macro_matchers = true
|
format_macro_matchers = true
|
||||||
merge_imports = true
|
imports_granularity = "Crate"
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
format_code_in_doc_comments = true
|
format_code_in_doc_comments = true
|
||||||
normalize_comments = true
|
normalize_comments = true
|
||||||
|
@ -157,8 +157,7 @@ impl TransactionBlockHeight for Wallet {
|
|||||||
.await
|
.await
|
||||||
.map_err(|_| backoff::Error::Transient(Error::Io))?;
|
.map_err(|_| backoff::Error::Transient(Error::Io))?;
|
||||||
|
|
||||||
let block_height =
|
let block_height = block_height.ok_or(backoff::Error::Transient(Error::NotYetMined))?;
|
||||||
block_height.ok_or_else(|| backoff::Error::Transient(Error::NotYetMined))?;
|
|
||||||
|
|
||||||
Result::<_, backoff::Error<Error>>::Ok(block_height)
|
Result::<_, backoff::Error<Error>>::Ok(block_height)
|
||||||
})
|
})
|
||||||
|
@ -17,7 +17,7 @@ impl Seed {
|
|||||||
Ok(Seed(seed::Seed::random()?))
|
Ok(Seed(seed::Seed::random()?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_file_or_generate(data_dir: &PathBuf) -> Result<Self, Error> {
|
pub fn from_file_or_generate(data_dir: &Path) -> Result<Self, Error> {
|
||||||
let file_path_buf = data_dir.join("seed.pem");
|
let file_path_buf = data_dir.join("seed.pem");
|
||||||
let file_path = Path::new(&file_path_buf);
|
let file_path = Path::new(&file_path_buf);
|
||||||
|
|
||||||
|
@ -247,9 +247,7 @@ async fn run_until_internal(
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
match publishded_redeem_tx {
|
match publishded_redeem_tx {
|
||||||
Ok(_) => {
|
Ok(_) => AliceState::BtcRedeemed,
|
||||||
AliceState::BtcRedeemed
|
|
||||||
}
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
bail!("Waiting for Bitcoin transaction finality failed with {}! The redeem transaction was published, but it is not ensured that the transaction was included! You're screwed.", e)
|
bail!("Waiting for Bitcoin transaction finality failed with {}! The redeem transaction was published, but it is not ensured that the transaction was included! You're screwed.", e)
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ async fn given_alice_restarts_after_encsig_is_learned_resume_swap() {
|
|||||||
let alice_state = alice::run_until(alice_swap, is_encsig_learned)
|
let alice_state = alice::run_until(alice_swap, is_encsig_learned)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(matches!(alice_state, AliceState::EncSigLearned {..}));
|
assert!(matches!(alice_state, AliceState::EncSigLearned { .. }));
|
||||||
|
|
||||||
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
||||||
assert!(matches!(alice_swap.state, AliceState::EncSigLearned {..}));
|
assert!(matches!(alice_swap.state, AliceState::EncSigLearned { .. }));
|
||||||
|
|
||||||
let alice_state = alice::run(alice_swap).await.unwrap();
|
let alice_state = alice::run(alice_swap).await.unwrap();
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ async fn given_bob_restarts_after_encsig_is_sent_resume_swap() {
|
|||||||
|
|
||||||
let bob_state = bob::run_until(bob_swap, is_encsig_sent).await.unwrap();
|
let bob_state = bob::run_until(bob_swap, is_encsig_sent).await.unwrap();
|
||||||
|
|
||||||
assert!(matches!(bob_state, BobState::EncSigSent {..}));
|
assert!(matches!(bob_state, BobState::EncSigSent { .. }));
|
||||||
|
|
||||||
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
||||||
assert!(matches!(bob_swap.state, BobState::EncSigSent {..}));
|
assert!(matches!(bob_swap.state, BobState::EncSigSent { .. }));
|
||||||
|
|
||||||
let bob_state = bob::run(bob_swap).await.unwrap();
|
let bob_state = bob::run(bob_swap).await.unwrap();
|
||||||
|
|
||||||
|
@ -16,11 +16,13 @@ async fn given_bob_restarts_after_lock_proof_received_resume_swap() {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert!(matches!(bob_state, BobState::XmrLockProofReceived {..}));
|
assert!(matches!(bob_state, BobState::XmrLockProofReceived { .. }));
|
||||||
|
|
||||||
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
||||||
assert!(matches!(bob_swap.state, BobState::XmrLockProofReceived
|
assert!(matches!(
|
||||||
{..}));
|
bob_swap.state,
|
||||||
|
BobState::XmrLockProofReceived { .. }
|
||||||
|
));
|
||||||
|
|
||||||
let bob_state = bob::run(bob_swap).await.unwrap();
|
let bob_state = bob::run(bob_swap).await.unwrap();
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ async fn given_bob_restarts_after_xmr_is_locked_resume_swap() {
|
|||||||
|
|
||||||
let bob_state = bob::run_until(bob_swap, is_xmr_locked).await.unwrap();
|
let bob_state = bob::run_until(bob_swap, is_xmr_locked).await.unwrap();
|
||||||
|
|
||||||
assert!(matches!(bob_state, BobState::XmrLocked {..}));
|
assert!(matches!(bob_state, BobState::XmrLocked { .. }));
|
||||||
|
|
||||||
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
||||||
assert!(matches!(bob_swap.state, BobState::XmrLocked {..}));
|
assert!(matches!(bob_swap.state, BobState::XmrLocked { .. }));
|
||||||
|
|
||||||
let bob_state = bob::run(bob_swap).await.unwrap();
|
let bob_state = bob::run(bob_swap).await.unwrap();
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ async fn alice_punishes_if_bob_never_acts_after_fund() {
|
|||||||
|
|
||||||
let bob_state = bob::run_until(bob_swap, is_btc_locked).await.unwrap();
|
let bob_state = bob::run_until(bob_swap, is_btc_locked).await.unwrap();
|
||||||
|
|
||||||
assert!(matches!(bob_state, BobState::BtcLocked {..}));
|
assert!(matches!(bob_state, BobState::BtcLocked { .. }));
|
||||||
|
|
||||||
let alice_state = alice_handle.await.unwrap();
|
let alice_state = alice_handle.await.unwrap();
|
||||||
ctx.assert_alice_punished(alice_state.unwrap()).await;
|
ctx.assert_alice_punished(alice_state.unwrap()).await;
|
||||||
@ -24,7 +24,7 @@ async fn alice_punishes_if_bob_never_acts_after_fund() {
|
|||||||
// Restart Bob after Alice punished to ensure Bob transitions to
|
// Restart Bob after Alice punished to ensure Bob transitions to
|
||||||
// punished and does not run indefinitely
|
// punished and does not run indefinitely
|
||||||
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
let bob_swap = ctx.stop_and_resume_bob_from_db(bob_join_handle).await;
|
||||||
assert!(matches!(bob_swap.state, BobState::BtcLocked {..}));
|
assert!(matches!(bob_swap.state, BobState::BtcLocked { .. }));
|
||||||
|
|
||||||
let bob_state = bob::run(bob_swap).await.unwrap();
|
let bob_state = bob::run(bob_swap).await.unwrap();
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ async fn given_alice_restarts_after_xmr_is_locked_refund_swap() {
|
|||||||
let bob_handle = tokio::spawn(bob);
|
let bob_handle = tokio::spawn(bob);
|
||||||
|
|
||||||
let alice_state = alice::run_until(alice_swap, is_xmr_locked).await.unwrap();
|
let alice_state = alice::run_until(alice_swap, is_xmr_locked).await.unwrap();
|
||||||
assert!(matches!(alice_state,
|
assert!(matches!(alice_state, AliceState::XmrLocked { .. }));
|
||||||
AliceState::XmrLocked {..}));
|
|
||||||
|
|
||||||
// Alice does not act, Bob refunds
|
// Alice does not act, Bob refunds
|
||||||
let bob_state = bob_handle.await.unwrap();
|
let bob_state = bob_handle.await.unwrap();
|
||||||
@ -24,7 +23,7 @@ async fn given_alice_restarts_after_xmr_is_locked_refund_swap() {
|
|||||||
|
|
||||||
// Once bob has finished Alice is restarted and refunds as well
|
// Once bob has finished Alice is restarted and refunds as well
|
||||||
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
||||||
assert!(matches!(alice_swap.state, AliceState::XmrLocked {..}));
|
assert!(matches!(alice_swap.state, AliceState::XmrLocked { .. }));
|
||||||
|
|
||||||
let alice_state = alice::run(alice_swap).await.unwrap();
|
let alice_state = alice::run(alice_swap).await.unwrap();
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ async fn given_alice_restarts_after_enc_sig_learned_and_bob_already_cancelled_re
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
matches!(alice_state, AliceState::EncSigLearned {..}),
|
matches!(alice_state, AliceState::EncSigLearned { .. }),
|
||||||
"Alice state is not EncSigLearned: {:?}",
|
"Alice state is not EncSigLearned: {:?}",
|
||||||
alice_state
|
alice_state
|
||||||
);
|
);
|
||||||
@ -34,8 +34,7 @@ async fn given_alice_restarts_after_enc_sig_learned_and_bob_already_cancelled_re
|
|||||||
// Once bob has finished Alice is restarted and refunds as well
|
// Once bob has finished Alice is restarted and refunds as well
|
||||||
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
let alice_swap = ctx.stop_and_resume_alice_from_db(alice_join_handle).await;
|
||||||
assert!(
|
assert!(
|
||||||
matches!(alice_swap.state, AliceState::EncSigLearned
|
matches!(alice_swap.state, AliceState::EncSigLearned { .. }),
|
||||||
{..}),
|
|
||||||
"Alice state is not EncSigLearned: {:?}",
|
"Alice state is not EncSigLearned: {:?}",
|
||||||
alice_state
|
alice_state
|
||||||
);
|
);
|
||||||
|
@ -478,17 +478,11 @@ pub mod alice_run_until {
|
|||||||
use swap::protocol::alice::AliceState;
|
use swap::protocol::alice::AliceState;
|
||||||
|
|
||||||
pub fn is_xmr_locked(state: &AliceState) -> bool {
|
pub fn is_xmr_locked(state: &AliceState) -> bool {
|
||||||
matches!(
|
matches!(state, AliceState::XmrLocked { .. })
|
||||||
state,
|
|
||||||
AliceState::XmrLocked{..}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_encsig_learned(state: &AliceState) -> bool {
|
pub fn is_encsig_learned(state: &AliceState) -> bool {
|
||||||
matches!(
|
matches!(state, AliceState::EncSigLearned { .. })
|
||||||
state,
|
|
||||||
AliceState::EncSigLearned{..}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user