Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
go-version: '~${{ env.GO_VERSION }}'

- name: run unit tests
run: make unit
run: make unit-race

- name: run unit test with postgres
run: make unit-postgres
run: make unit-postgres-race
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,22 @@ clean:
# TESTING
# =======

unit:
unit:
@$(call print, "Running unit tests.")
$(UNIT)

unit-race:
@$(call print, "Running unit race tests.")
$(UNIT) -race

unit-postgres:
@$(call print, "Running unit tests with postgres.")
$(UNIT) -tags=test_db_postgres

unit-postgres-race:
@$(call print, "Running unit race tests with postgres.")
$(UNIT) -race -tags=test_db_postgres

# =========
# UTILITIES
# =========
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c // indirect
github.com/btcsuite/btcwallet v0.16.10-0.20241127094224-93c858b2ad63
github.com/btcsuite/btcwallet/wtxmgr v1.5.4
github.com/coreos/bbolt v1.3.3
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/fortytw2/leaktest v1.3.0
Expand All @@ -35,6 +34,7 @@ require (
github.com/ory/dockertest/v3 v3.10.0
github.com/stretchr/testify v1.9.0
github.com/urfave/cli v1.22.9
go.etcd.io/bbolt v1.3.11
golang.org/x/net v0.36.0
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.2
Expand Down Expand Up @@ -164,7 +164,6 @@ require (
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
go.etcd.io/bbolt v1.3.11 // indirect
go.etcd.io/etcd/api/v3 v3.5.12 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
go.etcd.io/etcd/client/v2 v2.305.12 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,6 @@ github.com/cockroachdb/datadriven v1.0.2 h1:H9MtNqVoVhvd9nCBwOyDjUEdZCREqbIdCJD9
github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY=
github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
Expand Down
8 changes: 3 additions & 5 deletions instantout/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ type Manager struct {
}

// NewInstantOutManager creates a new instantout manager.
func NewInstantOutManager(cfg *Config) *Manager {
func NewInstantOutManager(cfg *Config, height int32) *Manager {
return &Manager{
cfg: cfg,
activeInstantOuts: make(map[lntypes.Hash]*FSM),
blockEpochChan: make(chan int32),
currentHeight: height,
}
}

// Run runs the instantout manager.
func (m *Manager) Run(ctx context.Context, initChan chan struct{},
height int32) error {

func (m *Manager) Run(ctx context.Context, initChan chan struct{}) error {
log.Debugf("Starting instantout manager")
defer func() {
log.Debugf("Stopping instantout manager")
Expand All @@ -62,7 +61,6 @@ func (m *Manager) Run(ctx context.Context, initChan chan struct{},
defer cancel()

m.runCtx = runCtx
m.currentHeight = height

err := m.recoverInstantOuts(runCtx)
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions instantout/reservation/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package reservation
import (
"context"
"encoding/hex"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -72,13 +73,14 @@ func TestManager(t *testing.T) {
require.NoError(t, err)

// We'll now expect a spend registration.
spendReg := <-testContext.mockLnd.RegisterSpendChannel
require.Equal(t, spendReg.PkScript, pkScript)
var spendReg atomic.Pointer[test.SpendRegistration]
spendReg.Store(<-testContext.mockLnd.RegisterSpendChannel)
require.Equal(t, spendReg.Load().PkScript, pkScript)

go func() {
// We'll expect a second spend registration.
spendReg = <-testContext.mockLnd.RegisterSpendChannel
require.Equal(t, spendReg.PkScript, pkScript)
spendReg.Store(<-testContext.mockLnd.RegisterSpendChannel)
require.Equal(t, spendReg.Load().PkScript, pkScript)
}()

// We'll now try to lock the reservation.
Expand All @@ -90,7 +92,7 @@ func TestManager(t *testing.T) {
require.Error(t, err)

testContext.mockLnd.SpendChannel <- &chainntnfs.SpendDetail{
SpentOutPoint: spendReg.Outpoint,
SpentOutPoint: spendReg.Load().Outpoint,
}

// We'll now expect the reservation to be expired.
Expand Down
6 changes: 3 additions & 3 deletions loopd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func getTLSConfig(cfg *Config) (*tls.Config, *credentials.TransportCredentials,
// If the certificate expired or it was outdated, delete it and the TLS
// key and generate a new pair.
if time.Now().After(parsedCert.NotAfter) {
log.Info("TLS certificate is expired or outdated, " +
infof("TLS certificate is expired or outdated, " +
"removing old file then generating a new one")

err := os.Remove(cfg.TLSCertPath)
Expand Down Expand Up @@ -464,7 +464,7 @@ func loadCertWithCreate(cfg *Config) (tls.Certificate, *x509.Certificate,
if !lnrpc.FileExists(cfg.TLSCertPath) &&
!lnrpc.FileExists(cfg.TLSKeyPath) {

log.Infof("Generating TLS certificates...")
infof("Generating TLS certificates...")
certBytes, keyBytes, err := cert.GenCertPair(
defaultSelfSignedOrganization, cfg.TLSExtraIPs,
cfg.TLSExtraDomains, cfg.TLSDisableAutofill,
Expand All @@ -481,7 +481,7 @@ func loadCertWithCreate(cfg *Config) (tls.Certificate, *x509.Certificate,
return tls.Certificate{}, nil, err
}

log.Infof("Done generating TLS certificates")
infof("Done generating TLS certificates")
}

return cert.LoadCert(cfg.TLSCertPath, cfg.TLSKeyPath)
Expand Down
Loading