Skip to content

Commit d717a98

Browse files
committed
sqlite support
1 parent 01dc818 commit d717a98

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
3+
using System.Security.Cryptography;
4+
using Google.Protobuf;
5+
// using LNBolt;
6+
using Lnrpc;
7+
using LNUnit.LND;
8+
using NBitcoin;
9+
using Routerrpc;
10+
using ServiceStack;
11+
using ServiceStack.Text;
12+
using Feature = ServiceStack.Feature;
13+
14+
namespace LNUnit.Tests;
15+
16+
//[Ignore("only local")]
17+
//[TestFixture("boltdb", "custom_lnd", "latest", "/home/lnd/.lnd", false)]
18+
[TestFixture("sqlite", "lightninglabs/lnd", "v0.19.3-beta", "/root/.lnd", true)]
19+
public class AbcLightningAbstractTestsSqlite : LNUnit.Tests.Abstract.AbcLightningAbstractTests
20+
{
21+
public AbcLightningAbstractTestsSqlite(string dbType = "sqlite",
22+
string lndImage = "custom_lnd",
23+
string tag = "latest",
24+
string lndRoot = "/root/.lnd",
25+
bool pullImage = false
26+
) : base(dbType, lndImage, tag, lndRoot, pullImage)
27+
{
28+
29+
}
30+
31+
32+
33+
}

LNUnit.Tests/Abstract/AbcLightningAbstractTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public async Task SetupNetwork(string lndImage = "lightninglabs/lnd", string lnd
150150
RemoteName = "bob"
151151
}
152152
], imageName: lndImage, tagName: lndTag, pullImage: false, acceptKeysend: true, mapTotmp: false,
153-
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["alice"] : null, lndkSupport: false, nativeSql: _dbType == "postgres", storeFinalHtlcResolutions: true);
153+
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["alice"] : null, lndkSupport: false, nativeSql: _dbType != "boltdb", storeFinalHtlcResolutions: true);
154154

155155
Builder.AddPolarLNDNode("bob",
156156
[
@@ -161,7 +161,7 @@ public async Task SetupNetwork(string lndImage = "lightninglabs/lnd", string lnd
161161
RemoteName = "alice"
162162
}
163163
], imageName: lndImage, tagName: lndTag, pullImage: false, acceptKeysend: true, mapTotmp: false,
164-
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["bob"] : null, lndkSupport: false, nativeSql: _dbType == "postgres");
164+
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["bob"] : null, lndkSupport: false, nativeSql: _dbType != "boltdb");
165165

166166
Builder.AddPolarLNDNode("carol",
167167
[
@@ -190,7 +190,7 @@ public async Task SetupNetwork(string lndImage = "lightninglabs/lnd", string lnd
190190
RemoteName = "bob"
191191
}
192192
], imageName: lndImage, tagName: lndTag, pullImage: false, acceptKeysend: true, mapTotmp: false,
193-
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["carol"] : null, lndkSupport: false, nativeSql: _dbType == "postgres");
193+
postgresDSN: _dbType == "postgres" ? PostgresFixture.LNDConnectionStrings["carol"] : null, lndkSupport: false, nativeSql: _dbType != "boltdb");
194194

195195
await Builder.Build(lndRoot: lndRoot);
196196

LNUnit/Setup/LNUnitBuilder.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,11 +973,11 @@ public static LNUnitBuilder AddPolarLNDNode(this LNUnitBuilder b, string aliasHo
973973
"--gossip.max-channel-update-burst=100",
974974
"--gossip.channel-update-interval=1s"
975975
};
976-
// if (nativeSql)
977-
// {
978-
// cmd.Add("--db.use-native-sql");
979-
//
980-
// }
976+
if (nativeSql)
977+
{
978+
cmd.Add("--db.use-native-sql");
979+
980+
}
981981
if (lndkSupport) //TODO: must compile LND with 'dev' flags before can play with this
982982
{
983983
cmd.Add("--protocol.custom-message=513");
@@ -996,6 +996,11 @@ public static LNUnitBuilder AddPolarLNDNode(this LNUnitBuilder b, string aliasHo
996996
cmd.Add("--db.postgres.timeout=300s");
997997
cmd.Add("--db.postgres.maxconnections=16");
998998
}
999+
else if (postgresDSN.IsEmpty() && nativeSql)
1000+
{
1001+
//Sqlite mode
1002+
cmd.Add("--db.backend=sqlite");
1003+
}
9991004

10001005
if (gcInvoiceOnStartup) cmd.Add("--gc-canceled-invoices-on-startup");
10011006
if (gcInvoiceOnFly) cmd.Add("--gc-canceled-invoices-on-the-fly");

0 commit comments

Comments
 (0)