mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 22:27:22 +01:00
sqldb+go.mod: update sqldb test methods
Update the test methods to take a `testing.TB` param instead of a `*testing.T` so that the test functions can be used for all the graph's tests including benchmark tests. We also add a temporary replace so that we can make use of these changes and also since we will soon be adding graph related schemas and queries in this submodule that we'll want to have access to.
This commit is contained in:
4
go.mod
4
go.mod
@@ -199,6 +199,10 @@ require (
|
|||||||
sigs.k8s.io/yaml v1.2.0 // indirect
|
sigs.k8s.io/yaml v1.2.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO(elle): remove once all the schemas and queries for the graph
|
||||||
|
// store have been included in a tagged sqldb version.
|
||||||
|
replace github.com/lightningnetwork/lnd/sqldb => ./sqldb
|
||||||
|
|
||||||
// This replace is for https://github.com/advisories/GHSA-25xm-hr59-7c27
|
// This replace is for https://github.com/advisories/GHSA-25xm-hr59-7c27
|
||||||
replace github.com/ulikunitz/xz => github.com/ulikunitz/xz v0.5.11
|
replace github.com/ulikunitz/xz => github.com/ulikunitz/xz v0.5.11
|
||||||
|
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -375,8 +375,6 @@ github.com/lightningnetwork/lnd/kvdb v1.4.16 h1:9BZgWdDfjmHRHLS97cz39bVuBAqMc4/p
|
|||||||
github.com/lightningnetwork/lnd/kvdb v1.4.16/go.mod h1:HW+bvwkxNaopkz3oIgBV6NEnV4jCEZCACFUcNg4xSjM=
|
github.com/lightningnetwork/lnd/kvdb v1.4.16/go.mod h1:HW+bvwkxNaopkz3oIgBV6NEnV4jCEZCACFUcNg4xSjM=
|
||||||
github.com/lightningnetwork/lnd/queue v1.1.1 h1:99ovBlpM9B0FRCGYJo6RSFDlt8/vOkQQZznVb18iNMI=
|
github.com/lightningnetwork/lnd/queue v1.1.1 h1:99ovBlpM9B0FRCGYJo6RSFDlt8/vOkQQZznVb18iNMI=
|
||||||
github.com/lightningnetwork/lnd/queue v1.1.1/go.mod h1:7A6nC1Qrm32FHuhx/mi1cieAiBZo5O6l8IBIoQxvkz4=
|
github.com/lightningnetwork/lnd/queue v1.1.1/go.mod h1:7A6nC1Qrm32FHuhx/mi1cieAiBZo5O6l8IBIoQxvkz4=
|
||||||
github.com/lightningnetwork/lnd/sqldb v1.0.9 h1:7OHi+Hui823mB/U9NzCdlZTAGSVdDCbjp33+6d/Q+G0=
|
|
||||||
github.com/lightningnetwork/lnd/sqldb v1.0.9/go.mod h1:OG09zL/PHPaBJefp4HsPz2YLUJ+zIQHbpgCtLnOx8I4=
|
|
||||||
github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
|
github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
|
||||||
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA=
|
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA=
|
||||||
github.com/lightningnetwork/lnd/tlv v1.3.1 h1:o7CZg06y+rJZfUMAo0WzBLr0pgBWCzrt0f9gpujYUzk=
|
github.com/lightningnetwork/lnd/tlv v1.3.1 h1:o7CZg06y+rJZfUMAo0WzBLr0pgBWCzrt0f9gpujYUzk=
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ type TestPgFixture struct {
|
|||||||
// NewTestPgFixture constructs a new TestPgFixture starting up a docker
|
// NewTestPgFixture constructs a new TestPgFixture starting up a docker
|
||||||
// container running Postgres 11. The started container will expire in after
|
// container running Postgres 11. The started container will expire in after
|
||||||
// the passed duration.
|
// the passed duration.
|
||||||
func NewTestPgFixture(t *testing.T, expiry time.Duration) *TestPgFixture {
|
func NewTestPgFixture(t testing.TB, expiry time.Duration) *TestPgFixture {
|
||||||
// Use a sensible default on Windows (tcp/http) and linux/osx (socket)
|
// Use a sensible default on Windows (tcp/http) and linux/osx (socket)
|
||||||
// by specifying an empty endpoint.
|
// by specifying an empty endpoint.
|
||||||
pool, err := dockertest.NewPool("")
|
pool, err := dockertest.NewPool("")
|
||||||
@@ -119,13 +119,13 @@ func (f *TestPgFixture) GetConfig(dbName string) *PostgresConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TearDown stops the underlying docker container.
|
// TearDown stops the underlying docker container.
|
||||||
func (f *TestPgFixture) TearDown(t *testing.T) {
|
func (f *TestPgFixture) TearDown(t testing.TB) {
|
||||||
err := f.pool.Purge(f.resource)
|
err := f.pool.Purge(f.resource)
|
||||||
require.NoError(t, err, "Could not purge resource")
|
require.NoError(t, err, "Could not purge resource")
|
||||||
}
|
}
|
||||||
|
|
||||||
// randomDBName generates a random database name.
|
// randomDBName generates a random database name.
|
||||||
func randomDBName(t *testing.T) string {
|
func randomDBName(t testing.TB) string {
|
||||||
randBytes := make([]byte, 8)
|
randBytes := make([]byte, 8)
|
||||||
_, err := rand.Read(randBytes)
|
_, err := rand.Read(randBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -135,7 +135,7 @@ func randomDBName(t *testing.T) string {
|
|||||||
|
|
||||||
// NewTestPostgresDB is a helper function that creates a Postgres database for
|
// NewTestPostgresDB is a helper function that creates a Postgres database for
|
||||||
// testing using the given fixture.
|
// testing using the given fixture.
|
||||||
func NewTestPostgresDB(t *testing.T, fixture *TestPgFixture) *PostgresStore {
|
func NewTestPostgresDB(t testing.TB, fixture *TestPgFixture) *PostgresStore {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
dbName := randomDBName(t)
|
dbName := randomDBName(t)
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ func (s *SqliteStore) SetSchemaVersion(version int, dirty bool) error {
|
|||||||
|
|
||||||
// NewTestSqliteDB is a helper function that creates an SQLite database for
|
// NewTestSqliteDB is a helper function that creates an SQLite database for
|
||||||
// testing.
|
// testing.
|
||||||
func NewTestSqliteDB(t *testing.T) *SqliteStore {
|
func NewTestSqliteDB(t testing.TB) *SqliteStore {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
t.Logf("Creating new SQLite DB for testing")
|
t.Logf("Creating new SQLite DB for testing")
|
||||||
|
|||||||
Reference in New Issue
Block a user