Skip to content

Commit d62382d

Browse files
committed
f
1 parent c286f72 commit d62382d

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

lightning-transaction-sync/tests/integration_tests.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ pub fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) {
4747
}
4848

4949
pub fn generate_blocks_and_wait(bitcoind: &BitcoinD, electrsd: &ElectrsD, num: usize) {
50-
let cur_height = bitcoind.client.get_block_count().expect("failed to get current block height").into_model().unwrap().0;
51-
let address = bitcoind
50+
let cur_height = bitcoind
5251
.client
53-
.new_address()
54-
.expect("failed to get new address");
52+
.get_block_count()
53+
.expect("failed to get current block height")
54+
.into_model()
55+
.0;
56+
let address = bitcoind.client.new_address().expect("failed to get new address");
5557
// TODO: expect this Result once the WouldBlock issue is resolved upstream.
5658
let _block_hashes_res = bitcoind.client.generate_to_address(num, &address);
5759
wait_for_block(electrsd, cur_height as usize + num);
@@ -174,10 +176,7 @@ macro_rules! test_syncing {
174176
assert_eq!(events.len(), 1);
175177

176178
// Check registered confirmed transactions are marked confirmed
177-
let new_address = $bitcoind
178-
.client
179-
.new_address()
180-
.unwrap();
179+
let new_address = $bitcoind.client.new_address().unwrap();
181180
let txid = $bitcoind
182181
.client
183182
.send_to_address(&new_address, Amount::from_sat(5000))
@@ -214,12 +213,8 @@ macro_rules! test_syncing {
214213
let block_hash = tx_res.block_hash.unwrap();
215214
let tx = tx_res.tx;
216215
let prev_outpoint = tx.input.first().unwrap().previous_output;
217-
let prev_tx = $bitcoind
218-
.client
219-
.get_transaction(prev_outpoint.txid)
220-
.unwrap()
221-
.into_model()
222-
.unwrap().tx;
216+
let prev_tx =
217+
$bitcoind.client.get_transaction(prev_outpoint.txid).unwrap().into_model().unwrap().tx;
223218
let prev_script_pubkey = prev_tx.output[prev_outpoint.vout as usize].script_pubkey.clone();
224219
let output = WatchedOutput {
225220
block_hash: Some(block_hash),
@@ -237,19 +232,26 @@ macro_rules! test_syncing {
237232
assert!($confirmable.unconfirmed_txs.lock().unwrap().is_empty());
238233

239234
// Check previously confirmed transactions are marked unconfirmed when they are reorged.
240-
let best_block_hash = $bitcoind.client.get_best_block_hash().unwrap();
241-
$bitcoind.client.invalidate_block(&best_block_hash).unwrap();
235+
let best_block_hash =
236+
$bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0;
237+
$bitcoind.client.invalidate_block(best_block_hash).unwrap();
242238

243239
// We're getting back to the previous height with a new tip, but best block shouldn't change.
244240
generate_blocks_and_wait(&$bitcoind, &$electrsd, 1);
245-
assert_ne!($bitcoind.client.get_best_block_hash().unwrap(), best_block_hash);
241+
assert_ne!(
242+
$bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0,
243+
best_block_hash
244+
);
246245
maybe_await!($tx_sync.sync(vec![&$confirmable])).unwrap();
247246
let events = std::mem::take(&mut *$confirmable.events.lock().unwrap());
248247
assert_eq!(events.len(), 0);
249248

250249
// Now we're surpassing previous height, getting new tip.
251250
generate_blocks_and_wait(&$bitcoind, &$electrsd, 1);
252-
assert_ne!($bitcoind.client.get_best_block_hash().unwrap(), best_block_hash);
251+
assert_ne!(
252+
$bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0,
253+
best_block_hash
254+
);
253255
maybe_await!($tx_sync.sync(vec![&$confirmable])).unwrap();
254256

255257
// Transactions still confirmed but under new tip.

0 commit comments

Comments
 (0)