@@ -13,7 +13,7 @@ use std::collections::HashMap;
1313
1414use ldk_node:: entropy:: NodeEntropy ;
1515use ldk_node:: Builder ;
16- use rand:: { rng , Rng } ;
16+ use rand:: RngCore ;
1717
1818#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
1919async fn channel_full_cycle_with_vss_store ( ) {
@@ -25,10 +25,10 @@ async fn channel_full_cycle_with_vss_store() {
2525 builder_a. set_chain_source_esplora ( esplora_url. clone ( ) , None ) ;
2626 let vss_base_url = std:: env:: var ( "TEST_VSS_BASE_URL" ) . unwrap ( ) ;
2727 let node_a = builder_a
28- . build_with_vss_store_and_fixed_headers (
28+ . build_with_vss_store (
2929 config_a. node_entropy ,
3030 vss_base_url. clone ( ) ,
31- "node_1_store" . to_string ( ) ,
31+ "" . to_owned ( ) ,
3232 HashMap :: new ( ) ,
3333 )
3434 . unwrap ( ) ;
@@ -39,12 +39,7 @@ async fn channel_full_cycle_with_vss_store() {
3939 let mut builder_b = Builder :: from_config ( config_b. node_config ) ;
4040 builder_b. set_chain_source_esplora ( esplora_url. clone ( ) , None ) ;
4141 let node_b = builder_b
42- . build_with_vss_store_and_fixed_headers (
43- config_b. node_entropy ,
44- vss_base_url,
45- "node_2_store" . to_string ( ) ,
46- HashMap :: new ( ) ,
47- )
42+ . build_with_vss_store ( config_b. node_entropy , vss_base_url, "" . to_owned ( ) , HashMap :: new ( ) )
4843 . unwrap ( ) ;
4944 node_b. start ( ) . unwrap ( ) ;
5045
@@ -60,96 +55,15 @@ async fn channel_full_cycle_with_vss_store() {
6055 . await ;
6156}
6257
63- #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
64- async fn vss_v0_schema_backwards_compatibility ( ) {
65- let ( bitcoind, electrsd) = common:: setup_bitcoind_and_electrsd ( ) ;
66- let esplora_url = format ! ( "http://{}" , electrsd. esplora_url. as_ref( ) . unwrap( ) ) ;
67- let vss_base_url = std:: env:: var ( "TEST_VSS_BASE_URL" ) . unwrap ( ) ;
68-
69- let rand_suffix: String =
70- ( 0 ..7 ) . map ( |_| rng ( ) . sample ( rand:: distr:: Alphanumeric ) as char ) . collect ( ) ;
71- let store_id = format ! ( "v0_compat_test_{}" , rand_suffix) ;
72- let storage_path = common:: random_storage_path ( ) . to_str ( ) . unwrap ( ) . to_owned ( ) ;
73- let seed_bytes = [ 42u8 ; 64 ] ;
74- let node_entropy = NodeEntropy :: from_seed_bytes ( seed_bytes) ;
75-
76- // Setup a v0.6.2 `Node` persisted with the v0 scheme.
77- let ( old_balance, old_node_id) = {
78- let mut builder_old = ldk_node_062:: Builder :: new ( ) ;
79- builder_old. set_network ( bitcoin:: Network :: Regtest ) ;
80- builder_old. set_storage_dir_path ( storage_path. clone ( ) ) ;
81- builder_old. set_entropy_seed_bytes ( seed_bytes) ;
82- builder_old. set_chain_source_esplora ( esplora_url. clone ( ) , None ) ;
83- let node_old = builder_old
84- . build_with_vss_store_and_fixed_headers (
85- vss_base_url. clone ( ) ,
86- store_id. clone ( ) ,
87- HashMap :: new ( ) ,
88- )
89- . unwrap ( ) ;
90-
91- node_old. start ( ) . unwrap ( ) ;
92- let addr_old = node_old. onchain_payment ( ) . new_address ( ) . unwrap ( ) ;
93- common:: premine_and_distribute_funds (
94- & bitcoind. client ,
95- & electrsd. client ,
96- vec ! [ addr_old] ,
97- bitcoin:: Amount :: from_sat ( 100_000 ) ,
98- )
99- . await ;
100- node_old. sync_wallets ( ) . unwrap ( ) ;
101-
102- let balance = node_old. list_balances ( ) . spendable_onchain_balance_sats ;
103- assert ! ( balance > 0 ) ;
104- let node_id = node_old. node_id ( ) ;
105-
106- // Workaround necessary as v0.6.2's VSS runtime wasn't dropsafe in a tokio context.
107- tokio:: task:: block_in_place ( move || {
108- node_old. stop ( ) . unwrap ( ) ;
109- drop ( node_old) ;
110- } ) ;
111-
112- ( balance, node_id)
113- } ;
114-
115- // Now ensure we can still reinit from the same backend.
116- let mut builder_new = Builder :: new ( ) ;
117- builder_new. set_network ( bitcoin:: Network :: Regtest ) ;
118- builder_new. set_storage_dir_path ( storage_path) ;
119- builder_new. set_chain_source_esplora ( esplora_url, None ) ;
120-
121- let node_new = builder_new
122- . build_with_vss_store_and_fixed_headers (
123- node_entropy,
124- vss_base_url,
125- store_id,
126- HashMap :: new ( ) ,
127- )
128- . unwrap ( ) ;
129-
130- node_new. start ( ) . unwrap ( ) ;
131- node_new. sync_wallets ( ) . unwrap ( ) ;
132-
133- let new_balance = node_new. list_balances ( ) . spendable_onchain_balance_sats ;
134- let new_node_id = node_new. node_id ( ) ;
135-
136- assert_eq ! ( old_node_id, new_node_id) ;
137- assert_eq ! ( old_balance, new_balance) ;
138-
139- node_new. stop ( ) . unwrap ( ) ;
140- }
141-
14258#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
14359async fn vss_node_restart ( ) {
14460 let ( bitcoind, electrsd) = common:: setup_bitcoind_and_electrsd ( ) ;
14561 let esplora_url = format ! ( "http://{}" , electrsd. esplora_url. as_ref( ) . unwrap( ) ) ;
14662 let vss_base_url = std:: env:: var ( "TEST_VSS_BASE_URL" ) . unwrap ( ) ;
14763
148- let rand_suffix: String =
149- ( 0 ..7 ) . map ( |_| rng ( ) . sample ( rand:: distr:: Alphanumeric ) as char ) . collect ( ) ;
150- let store_id = format ! ( "restart_test_{}" , rand_suffix) ;
15164 let storage_path = common:: random_storage_path ( ) . to_str ( ) . unwrap ( ) . to_owned ( ) ;
152- let seed_bytes = [ 42u8 ; 64 ] ;
65+ let mut seed_bytes = [ 42u8 ; 64 ] ;
66+ rand:: rng ( ) . fill_bytes ( & mut seed_bytes) ;
15367 let node_entropy = NodeEntropy :: from_seed_bytes ( seed_bytes) ;
15468
15569 // Setup initial node and fund it.
@@ -159,12 +73,7 @@ async fn vss_node_restart() {
15973 builder. set_storage_dir_path ( storage_path. clone ( ) ) ;
16074 builder. set_chain_source_esplora ( esplora_url. clone ( ) , None ) ;
16175 let node = builder
162- . build_with_vss_store_and_fixed_headers (
163- node_entropy,
164- vss_base_url. clone ( ) ,
165- store_id. clone ( ) ,
166- HashMap :: new ( ) ,
167- )
76+ . build_with_vss_store ( node_entropy, vss_base_url. clone ( ) , "" . to_owned ( ) , HashMap :: new ( ) )
16877 . unwrap ( ) ;
16978
17079 node. start ( ) . unwrap ( ) ;
@@ -193,12 +102,7 @@ async fn vss_node_restart() {
193102 builder. set_chain_source_esplora ( esplora_url, None ) ;
194103
195104 let node = builder
196- . build_with_vss_store_and_fixed_headers (
197- node_entropy,
198- vss_base_url,
199- store_id,
200- HashMap :: new ( ) ,
201- )
105+ . build_with_vss_store ( node_entropy, vss_base_url, "" . to_owned ( ) , HashMap :: new ( ) )
202106 . unwrap ( ) ;
203107
204108 node. start ( ) . unwrap ( ) ;
0 commit comments