Skip to content

Commit

Permalink
Reorg so boltdb tests don't need to spin up postgres instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsafier committed Mar 29, 2024
1 parent 47aa82a commit 0acc42c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 27 deletions.
20 changes: 20 additions & 0 deletions LNUnit.Tests/AbcLightningFixtureBoltDb.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


namespace LNUnit.Tests;

[TestFixture("boltdb", "lightninglabs/lnd", "daily-testing-only", "/root/.lnd", true)]
// [TestFixture("boltdb", "custom_lnd", "latest", "/home/lnd/.lnd", false)]
public class AbcLightningAbstractTestsBoltDb : LNUnit.Tests.Abstract.AbcLightningAbstractTests
{
public AbcLightningAbstractTestsBoltDb(string dbType = "boltdb",
string lndImage = "custom_lnd",
string tag = "latest",
string lndRoot = "/root/.lnd",
bool pullImage = false
) : base(dbType, lndImage, tag, lndRoot, pullImage)
{

}


}
18 changes: 18 additions & 0 deletions LNUnit.Tests/AbcLightningFixturePostgres.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


namespace LNUnit.Tests.Fixture;

[TestFixture("postgres", "lightninglabs/lnd", "daily-testing-only", "/root/.lnd", true)]
//[TestFixture("postgres", "custom_lnd", "latest", "/home/lnd/.lnd", false)]
public class AbcLightningAbstractTestsPostgres : LNUnit.Tests.Abstract.AbcLightningAbstractTests
{
public AbcLightningAbstractTestsPostgres(string dbType = "postgres",
string lndImage = "custom_lnd",
string tag = "latest",
string lndRoot = "/root/.lnd",
bool pullImage = false
) : base(dbType, lndImage, tag, lndRoot, pullImage)
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using LNUnit.Extentions;
using LNUnit.LND;
using LNUnit.Setup;
using LNUnit.Tests.Fixture;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -18,14 +19,25 @@
using ServiceStack.Text;
using Assert = NUnit.Framework.Assert;

namespace LNUnit.Test.Fixtures;
namespace LNUnit.Tests.Abstract;

// [TestFixture("postgres", "custom_lnd", "latest", "/home/lnd/.lnd", false)]
// [TestFixture("boltdb", "custom_lnd", "latest", "/home/lnd/.lnd", false)]
// [TestFixture("postgres", "lightninglabs/lnd", "daily-testing-only", "/root/.lnd", true)]
[TestFixture("boltdb", "lightninglabs/lnd", "daily-testing-only", "/root/.lnd", true)]
public class AbcLightningFixture : IDisposable

public abstract class AbcLightningAbstractTests : IDisposable
{
public AbcLightningAbstractTests(string dbType,
string lndImage = "custom_lnd",
string tag = "latest",
string lndRoot = "/root/.lnd",
bool pullImage = false
)
{
_dbType = dbType;
_lndImage = lndImage;
_tag = tag;
_lndRoot = lndRoot;
_pullImage = pullImage;
}

[SetUp]
public async Task PerTestSetUp()
{
Expand Down Expand Up @@ -62,19 +74,7 @@ public async Task OneTimeSetup()
await SetupNetwork(_lndImage, _tag, _lndRoot, _pullImage);
}

public AbcLightningFixture(string dbType,
string lndImage = "custom_lnd",
string tag = "latest",
string lndRoot = "/root/.lnd",
bool pullImage = false
)
{
_dbType = dbType;
_lndImage = lndImage;
_tag = tag;
_lndRoot = lndRoot;
_pullImage = pullImage;
}


public string DbContainerName { get; set; } = "postgres";
private readonly DockerClient _client = new DockerClientConfiguration().CreateClient();
Expand Down Expand Up @@ -900,11 +900,11 @@ async Task Record(bool success, Payment p, LNDNodeConnection c)
}

private readonly MemoryCache _aliasCache = new(new MemoryCacheOptions { SizeLimit = 10000 });
private readonly string _dbType;
private readonly string _lndImage;
private readonly string _tag;
private readonly string _lndRoot;
private readonly bool _pullImage;
protected readonly string _dbType;
protected readonly string _lndImage;
protected readonly string _tag;
protected readonly string _lndRoot;
protected readonly bool _pullImage;

private async Task<string> ToAlias(LNDNodeConnection c, string remotePubkey)
{
Expand Down
2 changes: 1 addition & 1 deletion LNUnit.Tests/DockerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Docker.DotNet.Models;
using LNUnit.Setup;

namespace LNUnit.Tests;
namespace LNUnit.Tests.Abstract;

public class DockerTest
{
Expand Down
4 changes: 2 additions & 2 deletions LNUnit.Tests/Fixture/PostgresFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Assert = NUnit.Framework.Assert;
using HostConfig = Docker.DotNet.Models.HostConfig;

namespace LNUnit.Test.Fixtures;
namespace LNUnit.Tests.Fixture;

/// <summary>
/// Used Globally to get Postgres support
Expand Down Expand Up @@ -109,7 +109,7 @@ private async Task StartPostgres(
if (db != null)
{
_ip = db.NetworkSettings.Networks.First().Value.IPAddress;
DbConnectionStringDotNet = $"Host={_ip};Database=postgres;Username=superuser;Password=superuser";
DbConnectionStringDotNet = $"Host={_ip};Database=postgres;Username=superuser;Password=superuser;Include Error Detail=true;";
ipAddressReady = true;
}
else
Expand Down

0 comments on commit 0acc42c

Please sign in to comment.