@@ -5,19 +5,17 @@ mod utils;
55use data:: TEST_SEED ;
66use json:: JsonValue ;
77use tokio:: runtime:: Runtime ;
8- use utils:: setup:: {
9- basic_no_spendable, saplingcoinbasebacked_spendcapable, two_clients_one_saplingcoinbase_backed,
10- } ;
8+ use utils:: setup;
119#[ test]
1210fn create_network_disconnected_client ( ) {
1311 let ( _regtest_manager_1, _child_process_handler_1, _client_builder) =
14- saplingcoinbasebacked_spendcapable ( ) ;
12+ setup :: saplingcoinbasebacked_spendcapable ( ) ;
1513}
1614
1715#[ test]
1816fn zcashd_sapling_commitment_tree ( ) {
1917 let ( regtest_manager, _child_process_handler, _client_builder) =
20- saplingcoinbasebacked_spendcapable ( ) ;
18+ setup :: saplingcoinbasebacked_spendcapable ( ) ;
2119 let trees = regtest_manager
2220 . get_cli_handle ( )
2321 . args ( [ "z_gettreestate" , "1" ] )
@@ -39,7 +37,7 @@ fn actual_empty_zcashd_sapling_commitment_tree() {
3937 "2fd8e51a03d9bbe2dd809831b1497aeb68a6e37ddf707ced4aa2d8dff13529ae" ;
4038 let finalstates = "000000" ;
4139 // Setup
42- let ( regtest_manager, _child_process_handler, _client) = basic_no_spendable ( ) ;
40+ let ( regtest_manager, _child_process_handler, _client) = setup :: basic_no_spendable ( ) ;
4341 // Execution:
4442 let trees = regtest_manager
4543 . get_cli_handle ( )
@@ -78,7 +76,7 @@ fn actual_empty_zcashd_sapling_commitment_tree() {
7876#[ test]
7977fn mine_sapling_to_self ( ) {
8078 let ( regtest_manager, _child_process_handler, mut client_builder) =
81- saplingcoinbasebacked_spendcapable ( ) ;
79+ setup :: saplingcoinbasebacked_spendcapable ( ) ;
8280 let client = client_builder. new_sameseed_client ( 0 , false ) ;
8381 Runtime :: new ( ) . unwrap ( ) . block_on ( async {
8482 utils:: increase_height_and_sync_client ( & regtest_manager, & client, 5 ) . await ;
@@ -90,24 +88,44 @@ fn mine_sapling_to_self() {
9088
9189#[ test]
9290fn send_mined_sapling_to_orchard ( ) {
91+ //! This test shows the 5th confirmation changing the state of balance by
92+ //! debiting unverified_orchard_balance and crediting verified_orchard_balance. The debit amount is
93+ //! consistent with all the notes in the relevant block changing state.
94+ //! NOTE that the balance doesn't give insight into the distribution across notes.
9395 let ( regtest_manager, _child_process_handler, mut client_builder) =
94- saplingcoinbasebacked_spendcapable ( ) ;
96+ setup :: saplingcoinbasebacked_spendcapable ( ) ;
9597 let client = client_builder. new_sameseed_client ( 0 , false ) ;
9698 Runtime :: new ( ) . unwrap ( ) . block_on ( async {
9799 utils:: increase_height_and_sync_client ( & regtest_manager, & client, 5 ) . await ;
98100
99101 let o_addr = client. do_new_address ( "o" ) . await . unwrap ( ) [ 0 ] . take ( ) ;
102+ let amount_to_send = 5_000 ;
100103 client
101104 . do_send ( vec ! [ (
102105 o_addr. to_string( ) . as_str( ) ,
103- 5000 ,
106+ amount_to_send ,
104107 Some ( "Scenario test: engage!" . to_string( ) ) ,
105108 ) ] )
106109 . await
107110 . unwrap ( ) ;
108111
109- utils:: increase_height_and_sync_client ( & regtest_manager, & client, 4 ) . await ;
112+ utils:: increase_height_and_sync_client ( & regtest_manager, & client, 1 ) . await ;
113+ // We just sent 5_000 zats to our own orchard address...
114+ let client_notes = dbg ! ( client. do_list_notes( false ) . await ) ;
115+ let first_value = client_notes[ "unspent_orchard_notes" ] [ 0 ] [ "value" ]
116+ . as_fixed_point_u64 ( 0 )
117+ . unwrap ( ) ;
118+ let second_value = client_notes[ "unspent_orchard_notes" ] [ 1 ] [ "value" ]
119+ . as_fixed_point_u64 ( 0 )
120+ . unwrap ( ) ;
121+ assert_eq ! ( first_value, amount_to_send) ;
122+ // Show that the total is split among notes 1 and 2.
123+ assert_eq ! (
124+ second_value,
125+ 625_000_000 - ( amount_to_send + u64 :: from( DEFAULT_FEE ) )
126+ ) ;
110127 let balance = client. do_balance ( ) . await ;
128+ utils:: increase_height_and_sync_client ( & regtest_manager, & client, 4 ) . await ;
111129 // We send change to orchard now, so we should have the full value of the note
112130 // we spent, minus the transaction fee
113131 assert_eq ! (
@@ -137,7 +155,7 @@ fn note_selection_order() {
137155 //! * sends to a sapling address
138156 //! * sends back to the original sender's UA
139157 let ( regtest_manager, client_1, client_2, child_process_handler, _) =
140- two_clients_one_saplingcoinbase_backed ( ) ;
158+ setup :: two_clients_one_saplingcoinbase_backed ( ) ;
141159
142160 Runtime :: new ( ) . unwrap ( ) . block_on ( async {
143161 utils:: increase_height_and_sync_client ( & regtest_manager, & client_1, 5 ) . await ;
@@ -253,7 +271,7 @@ fn note_selection_order() {
253271#[ test]
254272fn send_orchard_back_and_forth ( ) {
255273 let ( regtest_manager, client_a, client_b, child_process_handler, _) =
256- two_clients_one_saplingcoinbase_backed ( ) ;
274+ setup :: two_clients_one_saplingcoinbase_backed ( ) ;
257275 Runtime :: new ( ) . unwrap ( ) . block_on ( async {
258276 utils:: increase_height_and_sync_client ( & regtest_manager, & client_a, 5 ) . await ;
259277
@@ -303,7 +321,7 @@ fn send_orchard_back_and_forth() {
303321#[ test]
304322fn diversified_addresses_receive_funds_in_best_pool ( ) {
305323 let ( regtest_manager, client_a, client_b, child_process_handler, _) =
306- two_clients_one_saplingcoinbase_backed ( ) ;
324+ setup :: two_clients_one_saplingcoinbase_backed ( ) ;
307325 Runtime :: new ( ) . unwrap ( ) . block_on ( async {
308326 client_b. do_new_address ( "o" ) . await . unwrap ( ) ;
309327 client_b. do_new_address ( "zo" ) . await . unwrap ( ) ;
@@ -344,7 +362,7 @@ fn diversified_addresses_receive_funds_in_best_pool() {
344362#[ test]
345363fn rescan_still_have_outgoing_metadata ( ) {
346364 let ( regtest_manager, client_one, client_two, child_process_handler, _) =
347- two_clients_one_saplingcoinbase_backed ( ) ;
365+ setup :: two_clients_one_saplingcoinbase_backed ( ) ;
348366 Runtime :: new ( ) . unwrap ( ) . block_on ( async {
349367 utils:: increase_height_and_sync_client ( & regtest_manager, & client_one, 5 ) . await ;
350368 let sapling_addr_of_two = client_two. do_new_address ( "tz" ) . await . unwrap ( ) ;
@@ -370,7 +388,7 @@ fn rescan_still_have_outgoing_metadata() {
370388#[ test]
371389fn rescan_still_have_outgoing_metadata_with_sends_to_self ( ) {
372390 let ( regtest_manager, child_process_handler, mut client_builder) =
373- saplingcoinbasebacked_spendcapable ( ) ;
391+ setup :: saplingcoinbasebacked_spendcapable ( ) ;
374392 let client = client_builder. new_sameseed_client ( 0 , false ) ;
375393 Runtime :: new ( ) . unwrap ( ) . block_on ( async {
376394 utils:: increase_height_and_sync_client ( & regtest_manager, & client, 5 ) . await ;
@@ -424,7 +442,7 @@ fn rescan_still_have_outgoing_metadata_with_sends_to_self() {
424442#[ test]
425443fn handling_of_nonregenerated_diversified_addresses_after_seed_restore ( ) {
426444 let ( regtest_manager, sender, recipient, child_process_handler, mut client_builder) =
427- two_clients_one_saplingcoinbase_backed ( ) ;
445+ setup :: two_clients_one_saplingcoinbase_backed ( ) ;
428446 let mut expected_unspent_sapling_notes = json:: object! {
429447
430448 "created_in_block" => 7 ,
@@ -537,7 +555,7 @@ fn handling_of_nonregenerated_diversified_addresses_after_seed_restore() {
537555#[ test]
538556fn ensure_taddrs_from_old_seeds_work ( ) {
539557 let ( _regtest_manager, child_process_handler, mut client_builder) =
540- saplingcoinbasebacked_spendcapable ( ) ;
558+ setup :: saplingcoinbasebacked_spendcapable ( ) ;
541559 // The first taddr generated on commit 9e71a14eb424631372fd08503b1bd83ea763c7fb
542560 let transparent_address = "tmFLszfkjgim4zoUMAXpuohnFBAKy99rr2i" ;
543561
@@ -576,7 +594,7 @@ fn ensure_taddrs_from_old_seeds_work() {
576594#[ test]
577595fn cross_compat ( ) {
578596 let ( _regtest_manager, current_client, fixed_taddr_client, child_process_handler) =
579- utils :: setup:: cross_version_setup ( ) ;
597+ setup:: cross_version_setup ( ) ;
580598
581599 tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) . block_on ( async {
582600 let fixed_taddr_seed = fixed_taddr_client. do_seed_phrase ( ) . await . unwrap ( ) ;
@@ -592,7 +610,7 @@ fn cross_compat() {
592610#[ test]
593611fn t_incoming_t_outgoing ( ) {
594612 let ( regtest_manager, sender, recipient, child_process_handler, _client_builder) =
595- two_clients_one_saplingcoinbase_backed ( ) ;
613+ setup :: two_clients_one_saplingcoinbase_backed ( ) ;
596614
597615 tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) . block_on ( async {
598616 utils:: increase_height_and_sync_client ( & regtest_manager, & sender, 9 ) . await ;
@@ -728,7 +746,7 @@ fn t_incoming_t_outgoing() {
728746#[ test]
729747fn send_to_ua_saves_full_ua_in_wallet ( ) {
730748 let ( regtest_manager, sender, recipient, child_process_handler, _client_builder) =
731- two_clients_one_saplingcoinbase_backed ( ) ;
749+ setup :: two_clients_one_saplingcoinbase_backed ( ) ;
732750 tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) . block_on ( async {
733751 utils:: increase_height_and_sync_client ( & regtest_manager, & sender, 5 ) . await ;
734752 let recipient_address = recipient. do_addresses ( ) . await [ 0 ] [ "address" ] . take ( ) ;
0 commit comments