Skip to content
Open
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
2 changes: 1 addition & 1 deletion assets/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func getClientConn(config *TapdConfig) (*grpc.ClientConn, error) {
}

// Dial the gRPC server.
conn, err := grpc.Dial(config.Host, opts...)
conn, err := grpc.NewClient(config.Host, opts...)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions loopd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
defer infof("Static address manager stopped")

err := staticAddressManager.Run(d.mainCtx, initChan)
if err != nil && !errors.Is(context.Canceled, err) {
if err != nil && !errors.Is(err, context.Canceled) {
d.internalErrChan <- err
}
}()
Expand Down Expand Up @@ -924,7 +924,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
defer infof("Static address deposit manager stopped")

err := depositManager.Run(d.mainCtx, initChan)
if err != nil && !errors.Is(context.Canceled, err) {
if err != nil && !errors.Is(err, context.Canceled) {
d.internalErrChan <- err
}
}()
Expand Down Expand Up @@ -956,7 +956,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
defer infof("Static address withdrawal manager stopped")

err := withdrawalManager.Run(d.mainCtx, initChan)
if err != nil && !errors.Is(context.Canceled, err) {
if err != nil && !errors.Is(err, context.Canceled) {
d.internalErrChan <- err
}
}()
Expand Down Expand Up @@ -992,7 +992,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
infof("Starting static address loop-in manager...")
defer infof("Static address loop-in manager stopped")
err := staticLoopInManager.Run(d.mainCtx, initChan)
if err != nil && !errors.Is(context.Canceled, err) {
if err != nil && !errors.Is(err, context.Canceled) {
d.internalErrChan <- err
}
}()
Expand Down
2 changes: 1 addition & 1 deletion loopdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func NewBoltSwapStore(dbPath string, chainParams *chaincfg.Params) (
bdb, err := bbolt.Open(path, 0600, &bbolt.Options{
Timeout: DefaultLoopDBTimeout,
})
if err == bbolt.ErrTimeout {
if errors.Is(err, bbolt.ErrTimeout) {
return nil, fmt.Errorf("%w: couldn't obtain exclusive lock on "+
"%s, timed out after %v", bbolt.ErrTimeout, path,
DefaultLoopDBTimeout)
Expand Down
4 changes: 2 additions & 2 deletions loopin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,12 @@
height := int32(600)

cfg, err, inSwap := startNewLoopIn(t, ctx, height)
require.NoError(t, err)

Check failure on line 597 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

cannot use err (variable of type *loopInSwap) as error value in argument to require.NoError: *loopInSwap does not implement error (missing method Error)

Check failure on line 597 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

cannot use err (variable of type *loopInSwap) as error value in argument to require.NoError: *loopInSwap does not implement error (missing method Error)

Check failure on line 597 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

cannot use err (variable of type *loopInSwap) as error value in argument to require.NoError: *loopInSwap does not implement error (missing method Error)

advanceToPublishedHtlc(t, ctx)

// The client requests to abandon the published htlc state.
inSwap.abandonChan <- struct{}{}

Check failure on line 602 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

inSwap.abandonChan undefined (type error has no field or method abandonChan)

Check failure on line 602 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

inSwap.abandonChan undefined (type error has no field or method abandonChan)

Check failure on line 602 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

inSwap.abandonChan undefined (type error has no field or method abandonChan)

// Ensure that the swap is now in the StateFailAbandoned state.
ctx.assertState(loopdb.StateFailAbandoned)
Expand All @@ -609,28 +609,28 @@
ctx.store.AssertLoopInState(loopdb.StateFailAbandoned)

// Ensure that the swap was abandoned and the execution stopped.
err = <-ctx.errChan

Check failure on line 612 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

cannot use <-ctx.errChan (comma, ok expression of interface type error) as *loopInSwap value in assignment

Check failure on line 612 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

cannot use <-ctx.errChan (comma, ok expression of interface type error) as *loopInSwap value in assignment

Check failure on line 612 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

cannot use <-ctx.errChan (comma, ok expression of interface type error) as *loopInSwap value in assignment
require.Error(t, err)

Check failure on line 613 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

cannot use err (variable of type *loopInSwap) as error value in argument to require.Error: *loopInSwap does not implement error (missing method Error)

Check failure on line 613 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

cannot use err (variable of type *loopInSwap) as error value in argument to require.Error: *loopInSwap does not implement error (missing method Error)

Check failure on line 613 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

cannot use err (variable of type *loopInSwap) as error value in argument to require.Error: *loopInSwap does not implement error (missing method Error)
require.Contains(t, err.Error(), "swap hash abandoned by client")

Check failure on line 614 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

err.Error undefined (type *loopInSwap has no field or method Error)

Check failure on line 614 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

err.Error undefined (type *loopInSwap has no field or method Error)

Check failure on line 614 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

err.Error undefined (type *loopInSwap has no field or method Error)

// We re-instantiate the swap and ensure that it does not progress.
pendSwap := &loopdb.LoopIn{
Contract: &inSwap.LoopInContract,

Check failure on line 618 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

inSwap.LoopInContract undefined (type error has no field or method LoopInContract)

Check failure on line 618 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

inSwap.LoopInContract undefined (type error has no field or method LoopInContract)

Check failure on line 618 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

inSwap.LoopInContract undefined (type error has no field or method LoopInContract)
Loop: loopdb.Loop{
Events: []*loopdb.LoopEvent{
{
SwapStateData: loopdb.SwapStateData{
State: inSwap.state,

Check failure on line 623 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

inSwap.state undefined (type error has no field or method state)

Check failure on line 623 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

inSwap.state undefined (type error has no field or method state)

Check failure on line 623 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

inSwap.state undefined (type error has no field or method state)
},
},
},
Hash: testPreimage.Hash(),
},
}
resumedSwap, err := resumeLoopInSwap(

Check failure on line 630 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

cannot use resumeLoopInSwap(context.Background(), cfg, pendSwap) (value of interface type error) as *loopInSwap value in assignment

Check failure on line 630 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

cannot use resumeLoopInSwap(context.Background(), cfg, pendSwap) (value of interface type error) as *loopInSwap value in assignment

Check failure on line 630 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

cannot use resumeLoopInSwap(context.Background(), cfg, pendSwap) (value of interface type error) as *loopInSwap value in assignment
context.Background(), cfg, pendSwap,
)
require.NoError(t, err)

Check failure on line 633 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

cannot use err (variable of type *loopInSwap) as error value in argument to require.NoError: *loopInSwap does not implement error (missing method Error)

Check failure on line 633 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

cannot use err (variable of type *loopInSwap) as error value in argument to require.NoError: *loopInSwap does not implement error (missing method Error)

Check failure on line 633 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

cannot use err (variable of type *loopInSwap) as error value in argument to require.NoError: *loopInSwap does not implement error (missing method Error)

// Execute the abandoned swap.
go func() {
Expand All @@ -648,7 +648,7 @@
require.Equal(t, loopdb.StateFailAbandoned, swapInfo.State)

// Ensure that the execution flagged the abandoned swap as finalized.
err = <-ctx.errChan

Check failure on line 651 in loopin_test.go

View workflow job for this annotation

GitHub Actions / build and lint code

cannot use <-ctx.errChan (comma, ok expression of interface type error) as *loopInSwap value in assignment

Check failure on line 651 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test sqlite3 race

cannot use <-ctx.errChan (comma, ok expression of interface type error) as *loopInSwap value in assignment

Check failure on line 651 in loopin_test.go

View workflow job for this annotation

GitHub Actions / run unit-test postgres race

cannot use <-ctx.errChan (comma, ok expression of interface type error) as *loopInSwap value in assignment
require.Error(t, err)
require.Equal(t, ErrSwapFinalized, err)
}
Expand Down Expand Up @@ -760,7 +760,7 @@
}

func startNewLoopIn(t *testing.T, ctx *loopInTestContext, height int32) (
*swapConfig, error, *loopInSwap) {
*swapConfig, *loopInSwap, error) {

cfg := newSwapConfig(&ctx.lnd.LndServices, ctx.store, ctx.server, nil)

Expand All @@ -783,5 +783,5 @@
}
ctx.errChan <- err
}()
return cfg, err, inSwap
return cfg, inSwap, err
}
12 changes: 8 additions & 4 deletions swap_server_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"
)

Expand Down Expand Up @@ -896,7 +897,7 @@ func rpcRouteCancel(details *outCancelDetails) (
// getSwapServerConn returns a connection to the swap server. A non-empty
// proxyAddr indicates that a SOCKS proxy found at the address should be used to
// establish the connection.
func getSwapServerConn(address, proxyAddress string, insecure bool,
func getSwapServerConn(address, proxyAddress string, insec bool,
tlsPath string, interceptor *l402.ClientInterceptor) (*grpc.ClientConn,
error) {

Expand All @@ -914,8 +915,11 @@ func getSwapServerConn(address, proxyAddress string, insecure bool,
// using a self-signed certificate or with a certificate signed by a
// public CA.
switch {
case insecure:
opts = append(opts, grpc.WithInsecure())
case insec:
opts = append(opts, grpc.WithTransportCredentials(
insecure.NewCredentials(),
),
)

case tlsPath != "":
// Load the specified TLS certificate and build
Expand Down Expand Up @@ -945,7 +949,7 @@ func getSwapServerConn(address, proxyAddress string, insecure bool,
opts = append(opts, grpc.WithContextDialer(torDialer))
}

conn, err := grpc.Dial(address, opts...)
conn, err := grpc.NewClient(address, opts...)
if err != nil {
return nil, fmt.Errorf("unable to connect to RPC server: %v",
err)
Expand Down
14 changes: 7 additions & 7 deletions sweepbatcher/sweep_batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,15 @@ type testTransactionPublisher struct {
attempts int
}

var testPublishError = errors.New("test publish error")
var errTestPublish = errors.New("test publish error")

// PublishTransaction publishes the transaction or fails it's the first attempt.
func (p *testTransactionPublisher) PublishTransaction(ctx context.Context,
tx *wire.MsgTx, label string) error {

p.attempts++
if p.attempts == 1 {
return testPublishError
return errTestPublish
}

return p.WalletKitClient.PublishTransaction(ctx, tx, label)
Expand Down Expand Up @@ -733,7 +733,7 @@ func testPublishErrorHandler(t *testing.T, store testStore,
}, test.Timeout, eventuallyCheckFrequency)

// The first attempt to publish the batch tx is expected to fail.
require.ErrorIs(t, <-publishErrorChan, testPublishError)
require.ErrorIs(t, <-publishErrorChan, errTestPublish)

// Mine a block to trigger another publishing attempt.
err = lnd.NotifyHeight(601)
Expand Down Expand Up @@ -4072,8 +4072,8 @@ func testSweepBatcherHandleSweepRace(t *testing.T, store testStore,
<-batcher.initDone

const (
sweepValue btcutil.Amount = 1_000_000
confHeight = 605
sweepValue = btcutil.Amount(1_000_000)
confHeight = 605
)

sweepOutpoint := wire.OutPoint{
Expand Down Expand Up @@ -4534,8 +4534,8 @@ func TestSweepBatcherConfirmedBatchIncompleteSweeps(t *testing.T) {
swapStore := newLoopdbStore(t, sqlDB)

const (
sweepValue btcutil.Amount = 1_000_000
confHeight = 777
sweepValue = btcutil.Amount(1_000_000)
confHeight = 777
)

ctx := context.Background()
Expand Down
1 change: 0 additions & 1 deletion uncharge_state.go

This file was deleted.

Loading