Skip to content

Commit e035e9a

Browse files
committed
test: cleaner target bits
Signed-off-by: dzdidi <[email protected]>
1 parent 4e42f14 commit e035e9a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

teos/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ async fn main() {
267267
dbm.clone(),
268268
));
269269

270-
let mut poller = ChainPoller::new(&mut derefed, Network::from_core_arg(&conf.btc_network).unwrap());
270+
let mut poller = ChainPoller::new(
271+
&mut derefed,
272+
Network::from_core_arg(&conf.btc_network).unwrap(),
273+
);
271274
let (responder, watcher) = {
272275
let last_n_blocks = get_last_n_blocks(&mut poller, tip, IRREVOCABLY_RESOLVED as usize)
273276
.await.unwrap_or_else(|e| {

teos/src/responder.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
use std::collections::HashSet;
44
use std::sync::{Arc, Mutex};
55

6+
use bitcoin::hashes::Hash;
67
use bitcoin::{consensus, BlockHash};
78
use bitcoin::{Transaction, Txid};
8-
use bitcoin::hashes::Hash;
99

1010
use lightning::chain;
1111
use lightning_block_sync::poll::ValidatedBlock;
@@ -95,8 +95,18 @@ impl TransactionTracker {
9595
impl From<TransactionTracker> for common_msgs::Tracker {
9696
fn from(t: TransactionTracker) -> Self {
9797
common_msgs::Tracker {
98-
dispute_txid: t.dispute_tx.compute_txid().to_raw_hash().to_byte_array().to_vec(),
99-
penalty_txid: t.penalty_tx.compute_txid().to_raw_hash().to_byte_array().to_vec(),
98+
dispute_txid: t
99+
.dispute_tx
100+
.compute_txid()
101+
.to_raw_hash()
102+
.to_byte_array()
103+
.to_vec(),
104+
penalty_txid: t
105+
.penalty_tx
106+
.compute_txid()
107+
.to_raw_hash()
108+
.to_byte_array()
109+
.to_vec(),
100110
penalty_rawtx: consensus::serialize(&t.penalty_tx),
101111
}
102112
}

teos/src/test_utils.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ impl Blockchain {
189189
}
190190

191191
pub fn generate(&mut self, txs: Option<Vec<Transaction>>) -> Block {
192-
// FIXME: replace this magic number with something meaningul
193-
let bits = bitcoin::CompactTarget::from_consensus(553713663);
192+
let bits = bitcoin::Target::from_be_bytes([0xff; 32]).to_compact_lossy();
194193

195194
let prev_block = self.blocks.last().unwrap();
196195
let prev_blockhash = prev_block.block_hash();

0 commit comments

Comments
 (0)