From 0a0c11e3e934e3c1027bb134c7bea4f502f3b858 Mon Sep 17 00:00:00 2001 From: Luiz Parreira Date: Wed, 29 Sep 2021 16:38:25 -0300 Subject: [PATCH] Write test cases for new send_to_address --- integration_test/run.sh | 4 ++-- integration_test/src/main.rs | 39 +++++++++++++++++++----------------- json/src/lib.rs | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/integration_test/run.sh b/integration_test/run.sh index a442ae47..4c2c15bb 100755 --- a/integration_test/run.sh +++ b/integration_test/run.sh @@ -19,12 +19,12 @@ PID1=$! sleep 3 BLOCKFILTERARG="" -if bitcoind -version | grep -q "v0\.\(19\|2\)"; then +if bitcoind -version | grep -q "v0.\\(19\|20\|21\)"; then BLOCKFILTERARG="-blockfilterindex=1" fi FALLBACKFEEARG="" -if bitcoind -version | grep -q "v0\.2"; then +if bitcoind -version | grep -q "v0.\\(20\|21\\)"; then FALLBACKFEEARG="-fallbackfee=0.00001000" fi diff --git a/integration_test/src/main.rs b/integration_test/src/main.rs index a8b7a33e..834378ad 100644 --- a/integration_test/src/main.rs +++ b/integration_test/src/main.rs @@ -393,17 +393,20 @@ fn test_set_label(cl: &Client) { fn test_send_to_address(cl: &Client) { let addr = cl.get_new_address(None, None).unwrap(); let est = json::EstimateMode::Conservative; - let _ = cl.send_to_address(&addr, btc(1), Some("cc"), None, None, None, None, None).unwrap(); - let _ = cl.send_to_address(&addr, btc(1), None, Some("tt"), None, None, None, None).unwrap(); - let _ = cl.send_to_address(&addr, btc(1), None, None, Some(true), None, None, None).unwrap(); - let _ = cl.send_to_address(&addr, btc(1), None, None, None, Some(true), None, None).unwrap(); - let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, Some(3), None).unwrap(); - let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, None, Some(est)).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), Some("cc"), None, None, None, None, None, None, None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, Some("tt"), None, None, None, None, None, None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, Some(true), None, None, None, None, None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, None, Some(true), None, None, None, None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, Some(3), None, None, None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, None, Some(est), None, None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, Some(false), None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, None, Some(5)).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, None, None).unwrap(); } fn test_get_received_by_address(cl: &Client) { let addr = cl.get_new_address(None, None).unwrap(); - let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None).unwrap(); + let _ = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, None, None).unwrap(); assert_eq!(cl.get_received_by_address(&addr, Some(0)).unwrap(), btc(1)); assert_eq!(cl.get_received_by_address(&addr, Some(1)).unwrap(), btc(0)); let _ = cl.generate_to_address(7, &cl.get_new_address(None, None).unwrap()).unwrap(); @@ -413,13 +416,13 @@ fn test_get_received_by_address(cl: &Client) { fn test_list_unspent(cl: &Client) { let addr = cl.get_new_address(None, None).unwrap(); - let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None).unwrap(); + let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, None, None).unwrap(); let unspent = cl.list_unspent(Some(0), None, Some(&[&addr]), None, None).unwrap(); assert_eq!(unspent[0].txid, txid); assert_eq!(unspent[0].address.as_ref(), Some(&addr)); assert_eq!(unspent[0].amount, btc(1)); - let txid = cl.send_to_address(&addr, btc(7), None, None, None, None, None, None).unwrap(); + let txid = cl.send_to_address(&addr, btc(7), None, None, None, None, None, None, None, None).unwrap(); let options = json::ListUnspentQueryOptions { minimum_amount: Some(btc(7)), maximum_amount: Some(btc(7)), @@ -442,7 +445,7 @@ fn test_get_connection_count(cl: &Client) { fn test_get_raw_transaction(cl: &Client) { let addr = cl.get_new_address(None, None).unwrap(); - let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None).unwrap(); + let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, None, None).unwrap(); let tx = cl.get_raw_transaction(&txid, None).unwrap(); let hex = cl.get_raw_transaction_hex(&txid, None).unwrap(); assert_eq!(tx, deserialize(&Vec::::from_hex(&hex).unwrap()).unwrap()); @@ -461,7 +464,7 @@ fn test_get_raw_mempool(cl: &Client) { fn test_get_transaction(cl: &Client) { let txid = - cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None).unwrap(); + cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None, None, None).unwrap(); let tx = cl.get_transaction(&txid, None).unwrap(); assert_eq!(tx.amount, sbtc(-1.0)); assert_eq!(tx.info.txid, txid); @@ -486,7 +489,7 @@ fn test_list_since_block(cl: &Client) { fn test_get_tx_out(cl: &Client) { let txid = - cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None).unwrap(); + cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None, None, None).unwrap(); let out = cl.get_tx_out(&txid, 0, Some(false)).unwrap(); assert!(out.is_none()); let out = cl.get_tx_out(&txid, 0, Some(true)).unwrap(); @@ -496,9 +499,9 @@ fn test_get_tx_out(cl: &Client) { fn test_get_tx_out_proof(cl: &Client) { let txid1 = - cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None).unwrap(); + cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None, None, None).unwrap(); let txid2 = - cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None).unwrap(); + cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None, None, None).unwrap(); let blocks = cl.generate_to_address(7, &cl.get_new_address(None, None).unwrap()).unwrap(); let proof = cl.get_tx_out_proof(&[txid1, txid2], Some(&blocks[0])).unwrap(); assert!(!proof.is_empty()); @@ -506,7 +509,7 @@ fn test_get_tx_out_proof(cl: &Client) { fn test_get_mempool_entry(cl: &Client) { let txid = - cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None).unwrap(); + cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None, None, None).unwrap(); let entry = cl.get_mempool_entry(&txid).unwrap(); assert!(entry.spent_by.is_empty()); @@ -516,7 +519,7 @@ fn test_get_mempool_entry(cl: &Client) { fn test_lock_unspent_unlock_unspent(cl: &Client) { let addr = cl.get_new_address(None, None).unwrap(); - let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None).unwrap(); + let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, None, None).unwrap(); assert!(cl.lock_unspent(&[OutPoint::new(txid, 0)]).unwrap()); assert!(cl.unlock_unspent(&[OutPoint::new(txid, 0)]).unwrap()); @@ -832,7 +835,7 @@ fn test_finalize_psbt(cl: &Client) { fn test_list_received_by_address(cl: &Client) { let addr = cl.get_new_address(None, None).unwrap(); - let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None).unwrap(); + let txid = cl.send_to_address(&addr, btc(1), None, None, None, None, None, None, None, None).unwrap(); let _ = cl.list_received_by_address(Some(&addr), None, None, None).unwrap(); let _ = cl.list_received_by_address(Some(&addr), None, Some(true), None).unwrap(); @@ -1124,7 +1127,7 @@ fn test_getblocktemplate(cl: &Client) { // contains an entry in the vector of GetBlockTemplateResultTransaction. // Otherwise the GetBlockTemplateResultTransaction deserialization wouldn't // be tested. - cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None).unwrap(); + cl.send_to_address(&RANDOM_ADDRESS, btc(1), None, None, None, None, None, None, None, None).unwrap(); cl.get_block_template(GetBlockTemplateModes::Template, &[GetBlockTemplateRules::SegWit], &[]) .unwrap(); diff --git a/json/src/lib.rs b/json/src/lib.rs index 58e8933c..f919985d 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -1095,7 +1095,7 @@ impl<'a> serde::Serialize for ImportMultiRequestScriptPubkey<'a> { #[derive(Serialize)] struct Tmp<'a> { pub address: &'a Address, - } + }; serde::Serialize::serialize( &Tmp { address: addr,