@@ -29,10 +29,11 @@ use electrsd::corepc_node::{Client as BitcoindClient, Node as BitcoinD};
2929use electrsd:: { corepc_node, ElectrsD } ;
3030use electrum_client:: ElectrumApi ;
3131use ldk_node:: config:: { AsyncPaymentsRole , Config , ElectrumSyncConfig , EsploraSyncConfig } ;
32- use ldk_node:: io:: sqlite_store:: SqliteStore ;
32+ use ldk_node:: io:: sqlite_store:: { SqliteStore , KV_TABLE_NAME , SQLITE_DB_FILE_NAME } ;
3333use ldk_node:: payment:: { PaymentDirection , PaymentKind , PaymentStatus } ;
3434use ldk_node:: {
35- Builder , CustomTlvRecord , Event , LightningBalance , Node , NodeError , PendingSweepBalance ,
35+ Builder , CustomTlvRecord , DynStore , Event , LightningBalance , Node , NodeError ,
36+ PendingSweepBalance ,
3637} ;
3738use lightning:: io;
3839use lightning:: ln:: msgs:: SocketAddress ;
@@ -262,10 +263,23 @@ pub(crate) enum TestChainSource<'a> {
262263 BitcoindRestSync ( & ' a BitcoinD ) ,
263264}
264265
266+ #[ derive( Clone , Copy ) ]
267+ pub ( crate ) enum TestStoreType {
268+ TestSyncStore ,
269+ Sqlite ,
270+ }
271+
272+ impl Default for TestStoreType {
273+ fn default ( ) -> Self {
274+ TestStoreType :: TestSyncStore
275+ }
276+ }
277+
265278#[ derive( Clone , Default ) ]
266279pub ( crate ) struct TestConfig {
267280 pub node_config : Config ,
268281 pub log_writer : TestLogWriter ,
282+ pub store_type : TestStoreType ,
269283}
270284
271285macro_rules! setup_builder {
@@ -282,13 +296,28 @@ pub(crate) use setup_builder;
282296pub ( crate ) fn setup_two_nodes (
283297 chain_source : & TestChainSource , allow_0conf : bool , anchor_channels : bool ,
284298 anchors_trusted_no_reserve : bool ,
299+ ) -> ( TestNode , TestNode ) {
300+ setup_two_nodes_with_store (
301+ chain_source,
302+ allow_0conf,
303+ anchor_channels,
304+ anchors_trusted_no_reserve,
305+ TestStoreType :: TestSyncStore ,
306+ )
307+ }
308+
309+ pub ( crate ) fn setup_two_nodes_with_store (
310+ chain_source : & TestChainSource , allow_0conf : bool , anchor_channels : bool ,
311+ anchors_trusted_no_reserve : bool , store_type : TestStoreType ,
285312) -> ( TestNode , TestNode ) {
286313 println ! ( "== Node A ==" ) ;
287- let config_a = random_config ( anchor_channels) ;
314+ let mut config_a = random_config ( anchor_channels) ;
315+ config_a. store_type = store_type;
288316 let node_a = setup_node ( chain_source, config_a, None ) ;
289317
290318 println ! ( "\n == Node B ==" ) ;
291319 let mut config_b = random_config ( anchor_channels) ;
320+ config_b. store_type = store_type;
292321 if allow_0conf {
293322 config_b. node_config . trusted_peers_0conf . push ( node_a. node_id ( ) ) ;
294323 }
@@ -381,8 +410,14 @@ pub(crate) fn setup_node_for_async_payments(
381410
382411 builder. set_async_payments_role ( async_payments_role) . unwrap ( ) ;
383412
384- let test_sync_store = Arc :: new ( TestSyncStore :: new ( config. node_config . storage_dir_path . into ( ) ) ) ;
385- let node = builder. build_with_store ( test_sync_store) . unwrap ( ) ;
413+ let node = match config. store_type {
414+ TestStoreType :: TestSyncStore => {
415+ let kv_store = Arc :: new ( TestSyncStore :: new ( config. node_config . storage_dir_path . into ( ) ) ) ;
416+ builder. build_with_store ( kv_store) . unwrap ( )
417+ } ,
418+ TestStoreType :: Sqlite => builder. build ( ) . unwrap ( ) ,
419+ } ;
420+
386421 node. start ( ) . unwrap ( ) ;
387422 assert ! ( node. status( ) . is_running) ;
388423 assert ! ( node. status( ) . latest_fee_rate_cache_update_timestamp. is_some( ) ) ;
0 commit comments