Skip to content

Commit

Permalink
tests(tx-graph): check assert data tx weights
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajil1213 committed Jan 16, 2025
1 parent e480c29 commit 4fe32e2
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions crates/tx-graph/src/peg_out_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ mod tests {
use std::{collections::BTreeMap, fs, str::FromStr, sync::Arc};

use bitcoin::{
consensus, sighash::SighashCache, OutPoint, ScriptBuf, TapSighashType, Transaction, TxOut,
consensus, policy::MAX_STANDARD_TX_WEIGHT, sighash::SighashCache, OutPoint, ScriptBuf,
TapSighashType, Transaction, TxOut,
};
use corepc_node::{
serde_json::{self, json},
Expand Down Expand Up @@ -714,16 +715,24 @@ mod tests {
"number of assert data transactions must match"
);

signed_assert_data_txs.iter().for_each(|tx| {
btc_client
.send_raw_transaction(tx)
.expect("must be able to send assert data tx");

// generate a block so that the mempool size limit is not hit
btc_client
.generate_to_address(1, &btc_addr)
.expect("must be able to mine assert data tx");
});
signed_assert_data_txs
.iter()
.enumerate()
.for_each(|(i, tx)| {
assert!(
tx.weight().to_wu() < MAX_STANDARD_TX_WEIGHT as u64,
"assert data tx {i} must be within standardness limit"
);

btc_client
.send_raw_transaction(tx)
.expect("must be able to send assert data tx");

// generate a block so that the mempool size limit is not hit
btc_client
.generate_to_address(1, &btc_addr)
.expect("must be able to mine assert data tx");
});

btc_client
.generate_to_address(5, &btc_addr)
Expand Down

0 comments on commit 4fe32e2

Please sign in to comment.