Skip to content

Commit

Permalink
add: support for maxfeerate in testmempoolaccept
Browse files Browse the repository at this point in the history
  • Loading branch information
0xB10C committed Jan 17, 2024
1 parent 0866b40 commit ec42b97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,14 @@ pub trait RpcApi: Sized {
fn test_mempool_accept<R: RawTx>(
&self,
rawtxs: &[R],
maxfeerate: Option<Amount>,
) -> Result<Vec<json::TestMempoolAcceptResult>> {
let hexes: Vec<serde_json::Value> =
rawtxs.to_vec().into_iter().map(|r| r.raw_hex().into()).collect();
self.call("testmempoolaccept", &[hexes.into()])
match maxfeerate {
Some(max) => self.call("testmempoolaccept", &[hexes.into(), max.to_btc().into()]),
None => self.call("testmempoolaccept", &[hexes.into()]),
}
}

fn stop(&self) -> Result<String> {
Expand Down
4 changes: 2 additions & 2 deletions integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,12 +758,12 @@ fn test_test_mempool_accept(cl: &Client) {

let tx =
cl.create_raw_transaction(&[input.clone()], &output, Some(500_000), Some(false)).unwrap();
let res = cl.test_mempool_accept(&[&tx]).unwrap();
let res = cl.test_mempool_accept(&[&tx], None).unwrap();
assert!(!res[0].allowed);
assert!(res[0].reject_reason.is_some());
let signed =
cl.sign_raw_transaction_with_wallet(&tx, None, None).unwrap().transaction().unwrap();
let res = cl.test_mempool_accept(&[&signed]).unwrap();
let res = cl.test_mempool_accept(&[&signed], None).unwrap();
assert!(res[0].allowed, "not allowed: {:?}", res[0].reject_reason);
}

Expand Down

0 comments on commit ec42b97

Please sign in to comment.