Skip to content

Commit

Permalink
fix: give the coordinator more UTXOs
Browse files Browse the repository at this point in the history
  • Loading branch information
bonomat committed Feb 12, 2024
1 parent c453800 commit 9dd757e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions crates/tests-e2e/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ impl TestSetup {
}
}

pub async fn fund_coordinator(&self, amount: Amount) {
/// Funds the coordinator with [`amount`/`in_utxos`] utxos
///
/// E.g. if amount = 3 BTC, and in_utxos = 3, it would create 3 UTXOs a 1 BTC
pub async fn fund_coordinator(&self, amount: Amount, in_utxos: u64) {
// Ensure that the coordinator has a free UTXO available.
let address = self.coordinator.get_new_address().await.unwrap();

self.bitcoind
.send_to_address(&address, amount)
.await
.unwrap();
let sats_per_fund = amount.to_sat() / in_utxos;
for _ in 0..in_utxos {
self.bitcoind
.send_to_address(&address, Amount::from_sat(sats_per_fund))
.await
.unwrap();
}

self.bitcoind.mine(1).await.unwrap();

Expand Down Expand Up @@ -99,7 +105,7 @@ impl TestSetup {
pub async fn new_after_funding() -> Self {
let setup = Self::new().await;

setup.fund_coordinator(Amount::ONE_BTC).await;
setup.fund_coordinator(Amount::ONE_BTC, 2).await;

setup.fund_app(Amount::ONE_BTC).await;

Expand Down
2 changes: 1 addition & 1 deletion crates/tests-e2e/tests/e2e_open_position_small_utxos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn can_open_position_with_multiple_small_utxos() {

let setup = TestSetup::new().await;

setup.fund_coordinator(Amount::ONE_BTC).await;
setup.fund_coordinator(Amount::ONE_BTC, 2).await;

let app = &setup.app;

Expand Down
2 changes: 1 addition & 1 deletion crates/tests-e2e/tests/e2e_reject_offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tokio::task::spawn_blocking;
#[ignore = "need to be run with 'just e2e' command"]
async fn reject_offer() {
let test = TestSetup::new().await;
test.fund_coordinator(Amount::ONE_BTC).await;
test.fund_coordinator(Amount::ONE_BTC, 2).await;
test.fund_app(Amount::from_sat(250_000)).await;

let app = &test.app;
Expand Down

0 comments on commit 9dd757e

Please sign in to comment.