From 002e7b38c39bbb76fccde34b0f1838c316eaa8f1 Mon Sep 17 00:00:00 2001 From: Philipp Hoenisch Date: Wed, 28 Apr 2021 14:52:34 +1000 Subject: [PATCH] Define TX_FEE within test files only. --- swap/tests/harness/bitcoind.rs | 4 ++++ swap/tests/harness/mod.rs | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/swap/tests/harness/bitcoind.rs b/swap/tests/harness/bitcoind.rs index 9f1fcd03..91490f1a 100644 --- a/swap/tests/harness/bitcoind.rs +++ b/swap/tests/harness/bitcoind.rs @@ -8,6 +8,10 @@ pub const RPC_PORT: u16 = 18443; pub const PORT: u16 = 18886; pub const DATADIR: &str = "/home/bdk"; +// Bitcoin regtest TX fee. The fee itself does not matter for our tests. It just +// has to be static so that we can assert on the amounts. +pub const TX_FEE: u64 = 10_000; + #[derive(Debug)] pub struct Bitcoind { args: BitcoindArgs, diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index fcdc77bb..eda8c504 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -634,12 +634,12 @@ impl TestContext { let alice_submitted_cancel = btc_balance_after_swap == self.bob_starting_balances.btc - lock_tx_bitcoin_fee - - bitcoin::Amount::from_sat(bitcoin::TX_FEE); + - bitcoin::Amount::from_sat(bitcoind::TX_FEE); let bob_submitted_cancel = btc_balance_after_swap == self.bob_starting_balances.btc - lock_tx_bitcoin_fee - - bitcoin::Amount::from_sat(2 * bitcoin::TX_FEE); + - bitcoin::Amount::from_sat(2 * bitcoind::TX_FEE); // The cancel tx can be submitted by both Alice and Bob. // Since we cannot be sure who submitted it we have to assert accordingly @@ -678,7 +678,7 @@ impl TestContext { fn alice_redeemed_btc_balance(&self) -> bitcoin::Amount { self.alice_starting_balances.btc + self.btc_amount - - bitcoin::Amount::from_sat(bitcoin::TX_FEE) + - bitcoin::Amount::from_sat(bitcoind::TX_FEE) } fn bob_redeemed_xmr_balance(&self) -> monero::Amount { @@ -717,7 +717,7 @@ impl TestContext { fn alice_punished_btc_balance(&self) -> bitcoin::Amount { self.alice_starting_balances.btc + self.btc_amount - - bitcoin::Amount::from_sat(2 * bitcoin::TX_FEE) + - bitcoin::Amount::from_sat(2 * bitcoind::TX_FEE) } fn bob_punished_xmr_balance(&self) -> monero::Amount {