Introduce WalletBuilder for creating test instances of wallet

This commit is contained in:
Thomas Eizinger 2021-08-12 18:08:06 +10:00
parent 148fdb8d0a
commit e4b5e28a93
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
3 changed files with 73 additions and 33 deletions

View file

@ -183,11 +183,12 @@ impl Watchable for TxLock {
mod tests {
use super::*;
use crate::bitcoin::wallet::StaticFeeRate;
use crate::bitcoin::WalletBuilder;
#[tokio::test]
async fn given_bob_sends_good_psbt_when_reconstructing_then_succeeeds() {
let (A, B) = alice_and_bob();
let wallet = Wallet::new_funded_default_fees(50000);
let wallet = WalletBuilder::new(50_000).build();
let agreed_amount = Amount::from_sat(10000);
let psbt = bob_make_psbt(A, B, &wallet, agreed_amount).await;
@ -201,7 +202,7 @@ mod tests {
let (A, B) = alice_and_bob();
let fees = 610;
let agreed_amount = Amount::from_sat(10000);
let wallet = Wallet::new_funded_default_fees(agreed_amount.as_sat() + fees);
let wallet = WalletBuilder::new(agreed_amount.as_sat() + fees).build();
let psbt = bob_make_psbt(A, B, &wallet, agreed_amount).await;
assert_eq!(
@ -217,7 +218,7 @@ mod tests {
#[tokio::test]
async fn given_bob_is_sending_less_than_agreed_when_reconstructing_txlock_then_fails() {
let (A, B) = alice_and_bob();
let wallet = Wallet::new_funded_default_fees(50000);
let wallet = WalletBuilder::new(50_000).build();
let agreed_amount = Amount::from_sat(10000);
let bad_amount = Amount::from_sat(5000);
@ -230,7 +231,7 @@ mod tests {
#[tokio::test]
async fn given_bob_is_sending_to_a_bad_output_reconstructing_txlock_then_fails() {
let (A, B) = alice_and_bob();
let wallet = Wallet::new_funded_default_fees(50000);
let wallet = WalletBuilder::new(50_000).build();
let agreed_amount = Amount::from_sat(10000);
let E = eve();