@@ -29,6 +29,7 @@ use electrsd::{corepc_node, ElectrsD};
2929use electrum_client:: ElectrumApi ;
3030use ldk_node:: config:: { AsyncPaymentsRole , Config , ElectrumSyncConfig , EsploraSyncConfig } ;
3131use ldk_node:: entropy:: { generate_entropy_mnemonic, NodeEntropy } ;
32+ #[ cfg( feature = "sqlite" ) ]
3233use ldk_node:: io:: sqlite_store:: SqliteStore ;
3334use ldk_node:: payment:: { PaymentDirection , PaymentKind , PaymentStatus } ;
3435use ldk_node:: {
@@ -329,6 +330,7 @@ pub(crate) enum TestChainSource<'a> {
329330#[ derive( Clone , Copy ) ]
330331pub ( crate ) enum TestStoreType {
331332 TestSyncStore ,
333+ #[ cfg( feature = "sqlite" ) ]
332334 Sqlite ,
333335}
334336
@@ -486,6 +488,7 @@ pub(crate) fn setup_node(chain_source: &TestChainSource, config: TestConfig) ->
486488 let kv_store = TestSyncStore :: new ( config. node_config . storage_dir_path . into ( ) ) ;
487489 builder. build_with_store ( config. node_entropy . into ( ) , kv_store) . unwrap ( )
488490 } ,
491+ #[ cfg( feature = "sqlite" ) ]
489492 TestStoreType :: Sqlite => builder. build ( config. node_entropy . into ( ) ) . unwrap ( ) ,
490493 } ;
491494
@@ -1519,6 +1522,7 @@ struct TestSyncStoreInner {
15191522 serializer : RwLock < ( ) > ,
15201523 test_store : TestStore ,
15211524 fs_store : FilesystemStore ,
1525+ #[ cfg( feature = "sqlite" ) ]
15221526 sqlite_store : SqliteStore ,
15231527}
15241528
@@ -1528,33 +1532,46 @@ impl TestSyncStoreInner {
15281532 let mut fs_dir = dest_dir. clone ( ) ;
15291533 fs_dir. push ( "fs_store" ) ;
15301534 let fs_store = FilesystemStore :: new ( fs_dir) ;
1535+ #[ cfg( feature = "sqlite" ) ]
15311536 let mut sql_dir = dest_dir. clone ( ) ;
1537+ #[ cfg( feature = "sqlite" ) ]
15321538 sql_dir. push ( "sqlite_store" ) ;
1539+ #[ cfg( feature = "sqlite" ) ]
15331540 let sqlite_store = SqliteStore :: new (
15341541 sql_dir,
15351542 Some ( "test_sync_db" . to_string ( ) ) ,
15361543 Some ( "test_sync_table" . to_string ( ) ) ,
15371544 )
15381545 . unwrap ( ) ;
15391546 let test_store = TestStore :: new ( false ) ;
1540- Self { serializer, fs_store, sqlite_store, test_store }
1547+ #[ cfg( feature = "sqlite" ) ]
1548+ {
1549+ return Self { serializer, fs_store, sqlite_store, test_store } ;
1550+ }
1551+ #[ cfg( not( feature = "sqlite" ) ) ]
1552+ {
1553+ Self { serializer, fs_store, test_store }
1554+ }
15411555 }
15421556
15431557 fn do_list (
15441558 & self , primary_namespace : & str , secondary_namespace : & str ,
15451559 ) -> lightning:: io:: Result < Vec < String > > {
15461560 let fs_res = KVStoreSync :: list ( & self . fs_store , primary_namespace, secondary_namespace) ;
1547- let sqlite_res =
1548- KVStoreSync :: list ( & self . sqlite_store , primary_namespace, secondary_namespace) ;
1561+ # [ cfg ( feature = "sqlite" ) ]
1562+ let sqlite_res = KVStoreSync :: list ( & self . sqlite_store , primary_namespace, secondary_namespace) ;
15491563 let test_res = KVStoreSync :: list ( & self . test_store , primary_namespace, secondary_namespace) ;
15501564
15511565 match fs_res {
15521566 Ok ( mut list) => {
15531567 list. sort ( ) ;
15541568
1555- let mut sqlite_list = sqlite_res. unwrap ( ) ;
1556- sqlite_list. sort ( ) ;
1557- assert_eq ! ( list, sqlite_list) ;
1569+ #[ cfg( feature = "sqlite" ) ]
1570+ {
1571+ let mut sqlite_list = sqlite_res. unwrap ( ) ;
1572+ sqlite_list. sort ( ) ;
1573+ assert_eq ! ( list, sqlite_list) ;
1574+ }
15581575
15591576 let mut test_list = test_res. unwrap ( ) ;
15601577 test_list. sort ( ) ;
@@ -1563,6 +1580,7 @@ impl TestSyncStoreInner {
15631580 Ok ( list)
15641581 } ,
15651582 Err ( e) => {
1583+ #[ cfg( feature = "sqlite" ) ]
15661584 assert ! ( sqlite_res. is_err( ) ) ;
15671585 assert ! ( test_res. is_err( ) ) ;
15681586 Err ( e)
@@ -1576,20 +1594,25 @@ impl TestSyncStoreInner {
15761594 let _guard = self . serializer . read ( ) . unwrap ( ) ;
15771595
15781596 let fs_res = KVStoreSync :: read ( & self . fs_store , primary_namespace, secondary_namespace, key) ;
1597+ #[ cfg( feature = "sqlite" ) ]
15791598 let sqlite_res =
15801599 KVStoreSync :: read ( & self . sqlite_store , primary_namespace, secondary_namespace, key) ;
15811600 let test_res =
15821601 KVStoreSync :: read ( & self . test_store , primary_namespace, secondary_namespace, key) ;
15831602
15841603 match fs_res {
15851604 Ok ( read) => {
1605+ #[ cfg( feature = "sqlite" ) ]
15861606 assert_eq ! ( read, sqlite_res. unwrap( ) ) ;
15871607 assert_eq ! ( read, test_res. unwrap( ) ) ;
15881608 Ok ( read)
15891609 } ,
15901610 Err ( e) => {
1591- assert ! ( sqlite_res. is_err( ) ) ;
1592- assert_eq ! ( e. kind( ) , unsafe { sqlite_res. unwrap_err_unchecked( ) . kind( ) } ) ;
1611+ #[ cfg( feature = "sqlite" ) ]
1612+ {
1613+ assert ! ( sqlite_res. is_err( ) ) ;
1614+ assert_eq ! ( e. kind( ) , unsafe { sqlite_res. unwrap_err_unchecked( ) . kind( ) } ) ;
1615+ }
15931616 assert ! ( test_res. is_err( ) ) ;
15941617 assert_eq ! ( e. kind( ) , unsafe { test_res. unwrap_err_unchecked( ) . kind( ) } ) ;
15951618 Err ( e)
@@ -1608,6 +1631,7 @@ impl TestSyncStoreInner {
16081631 key,
16091632 buf. clone ( ) ,
16101633 ) ;
1634+ #[ cfg( feature = "sqlite" ) ]
16111635 let sqlite_res = KVStoreSync :: write (
16121636 & self . sqlite_store ,
16131637 primary_namespace,
@@ -1630,11 +1654,13 @@ impl TestSyncStoreInner {
16301654
16311655 match fs_res {
16321656 Ok ( ( ) ) => {
1657+ #[ cfg( feature = "sqlite" ) ]
16331658 assert ! ( sqlite_res. is_ok( ) ) ;
16341659 assert ! ( test_res. is_ok( ) ) ;
16351660 Ok ( ( ) )
16361661 } ,
16371662 Err ( e) => {
1663+ #[ cfg( feature = "sqlite" ) ]
16381664 assert ! ( sqlite_res. is_err( ) ) ;
16391665 assert ! ( test_res. is_err( ) ) ;
16401666 Err ( e)
@@ -1648,6 +1674,7 @@ impl TestSyncStoreInner {
16481674 let _guard = self . serializer . write ( ) . unwrap ( ) ;
16491675 let fs_res =
16501676 KVStoreSync :: remove ( & self . fs_store , primary_namespace, secondary_namespace, key, lazy) ;
1677+ #[ cfg( feature = "sqlite" ) ]
16511678 let sqlite_res = KVStoreSync :: remove (
16521679 & self . sqlite_store ,
16531680 primary_namespace,
@@ -1670,11 +1697,13 @@ impl TestSyncStoreInner {
16701697
16711698 match fs_res {
16721699 Ok ( ( ) ) => {
1700+ #[ cfg( feature = "sqlite" ) ]
16731701 assert ! ( sqlite_res. is_ok( ) ) ;
16741702 assert ! ( test_res. is_ok( ) ) ;
16751703 Ok ( ( ) )
16761704 } ,
16771705 Err ( e) => {
1706+ #[ cfg( feature = "sqlite" ) ]
16781707 assert ! ( sqlite_res. is_err( ) ) ;
16791708 assert ! ( test_res. is_err( ) ) ;
16801709 Err ( e)
0 commit comments