Skip to content

Commit f42264a

Browse files
committed
test: add send_raw_transaction rebroadcast test, #6250
1 parent 5224137 commit f42264a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

stacks-node/src/tests/bitcoin_rpc_integrations.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,49 @@ fn test_get_block_hash_ok() {
617617
.expect("Should return regtest genesis block hash!");
618618
assert_eq!(BITCOIN_REGTEST_FIRST_BLOCK_HASH, hash);
619619
}
620+
621+
#[ignore]
622+
#[test]
623+
fn test_send_raw_transaction_rebroadcast_ok() {
624+
if env::var("BITCOIND_TEST") != Ok("1".into()) {
625+
return;
626+
}
627+
628+
let mut config = utils::create_stx_config();
629+
config.burnchain.wallet_name = "my_wallet".to_string();
630+
631+
let mut btcd_controller = BitcoinCoreController::from_stx_config(config.clone());
632+
btcd_controller
633+
.add_arg("-fallbackfee=0.0002")
634+
.start_bitcoind_v2()
635+
.expect("bitcoind should be started!");
636+
637+
let client = BitcoinRpcClient::from_stx_config(&config).expect("Client creation ok!");
638+
client
639+
.create_wallet("my_wallet", Some(false))
640+
.expect("create wallet ok!");
641+
642+
let address = client
643+
.get_new_address(None, Some(AddressType::Legacy))
644+
.expect("get new address ok!");
645+
646+
//Create 1 UTXO
647+
_ = client
648+
.generate_to_address(101, &address)
649+
.expect("generate to address ok!");
650+
651+
//Need `fallbackfee` arg
652+
let txid = client
653+
.send_to_address(&address, 2.0)
654+
.expect("send to address ok!");
655+
656+
let raw_tx = client
657+
.get_raw_transaction(&txid)
658+
.expect("get raw transaction ok!");
659+
660+
let txid = client
661+
.send_raw_transaction(&raw_tx, None, None)
662+
.expect("send raw transaction (rebroadcast) ok!");
663+
664+
assert_eq!(txid.to_bitcoin_hex(), raw_tx.txid().to_string());
665+
}

0 commit comments

Comments
 (0)