multi: formatting and comment fixes
This commit is contained in:
160 files changed
+159
-260
No files matched your search
@@ -295,7 +295,7 @@ func (cfg *BaseNodeConfig) GenArgs() []string {
|
||||
// ]
|
||||
// },
|
||||
// "chanPoint2": ...
|
||||
// }
|
||||
// }.
|
||||
type policyUpdateMap map[string]map[string][]*lnrpc.RoutingPolicy
|
||||
|
||||
// HarnessNode represents an instance of lnd running within our test network
|
||||
@@ -1189,7 +1189,6 @@ func (hn *HarnessNode) stop() error {
|
||||
return fmt.Errorf("error attempting to stop "+
|
||||
"grpc client: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -1207,7 +1206,7 @@ func (hn *HarnessNode) shutdown() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// kill kills the lnd process
|
||||
// kill kills the lnd process.
|
||||
func (hn *HarnessNode) kill() error {
|
||||
return hn.cmd.Process.Kill()
|
||||
}
|
||||
@@ -1244,7 +1243,6 @@ type chanWatchRequest struct {
|
||||
}
|
||||
|
||||
func (hn *HarnessNode) checkChanPointInGraph(chanPoint wire.OutPoint) bool {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -1288,7 +1286,6 @@ func (hn *HarnessNode) lightningNetworkWatcher() {
|
||||
|
||||
for {
|
||||
select {
|
||||
|
||||
// A new graph update has just been received, so we'll examine
|
||||
// the current set of registered clients to see if we can
|
||||
// dispatch any requests.
|
||||
@@ -1767,7 +1764,6 @@ func (hn *HarnessNode) handlePolicyUpdateWatchRequest(req *chanWatchRequest) {
|
||||
// getChannelPolicies queries the channel graph and formats the policies into
|
||||
// the format defined in type policyUpdateMap.
|
||||
func (hn *HarnessNode) getChannelPolicies(include bool) policyUpdateMap {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(hn.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -1782,7 +1778,6 @@ func (hn *HarnessNode) getChannelPolicies(include bool) policyUpdateMap {
|
||||
policyUpdates := policyUpdateMap{}
|
||||
|
||||
for _, e := range graph.Edges {
|
||||
|
||||
policies := policyUpdates[e.ChanPoint]
|
||||
|
||||
// If the map[op] is nil, we need to initialize the map first.
|
||||
|
||||
@@ -527,7 +527,6 @@ func assertConnected(t *harnessTest, alice, bob *lntest.HarnessNode) {
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}, defaultTimeout)
|
||||
require.NoError(t.t, err)
|
||||
}
|
||||
@@ -1004,6 +1003,7 @@ func assertChannelConstraintsEqual(
|
||||
func assertAmountPaid(t *harnessTest, channelName string,
|
||||
node *lntest.HarnessNode, chanPoint wire.OutPoint, amountSent,
|
||||
amountReceived int64) {
|
||||
|
||||
ctxb := context.Background()
|
||||
|
||||
checkAmountPaid := func() error {
|
||||
@@ -1027,6 +1027,7 @@ func assertAmountPaid(t *harnessTest, channelName string,
|
||||
}
|
||||
if channel.TotalSatoshisReceived !=
|
||||
amountReceived {
|
||||
|
||||
return fmt.Errorf("%v: incorrect amount"+
|
||||
" received: %v != %v",
|
||||
channelName,
|
||||
@@ -1068,6 +1069,7 @@ func assertAmountPaid(t *harnessTest, channelName string,
|
||||
// node reports the expected number of pending channels.
|
||||
func assertNumPendingChannels(t *harnessTest, node *lntest.HarnessNode,
|
||||
expWaitingClose, expPendingForceClose int) {
|
||||
|
||||
ctxb := context.Background()
|
||||
|
||||
var predErr error
|
||||
@@ -1394,6 +1396,7 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
|
||||
case *lnrpc.ChannelEventUpdate_ClosedChannel:
|
||||
if chanUpdate.Type !=
|
||||
lnrpc.ChannelEventUpdate_CLOSED_CHANNEL {
|
||||
|
||||
return fmt.Errorf("update type mismatch: expected %v, got %v",
|
||||
lnrpc.ChannelEventUpdate_CLOSED_CHANNEL,
|
||||
chanUpdate.Type)
|
||||
@@ -1432,6 +1435,7 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
|
||||
// reaches the desired number of total channels.
|
||||
func assertNodeNumChannels(t *harnessTest, node *lntest.HarnessNode,
|
||||
numChannels int) {
|
||||
|
||||
ctxb := context.Background()
|
||||
|
||||
// Poll node for its list of channels.
|
||||
|
||||
@@ -1085,7 +1085,6 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
numBlocks := uint32(defaultCSV - 1)
|
||||
if channelType == lnrpc.CommitmentType_ANCHORS {
|
||||
numBlocks = defaultCSV - 2
|
||||
|
||||
}
|
||||
_, err = net.Miner.Client.Generate(numBlocks)
|
||||
if err != nil {
|
||||
|
||||
@@ -909,5 +909,4 @@ func testUpdateChannelPolicyFeeRateAccuracy(net *lntest.NetworkHarness,
|
||||
assertPolicyUpdate(
|
||||
t, nodes, net.Alice.PubKeyStr, expectedPolicy, chanPoint,
|
||||
)
|
||||
|
||||
}
|
||||
@@ -153,7 +153,6 @@ func testEtcdFailoverCase(net *lntest.NetworkHarness, ht *harnessTest,
|
||||
}
|
||||
|
||||
failoverTimeout = 2 * time.Minute
|
||||
|
||||
} else {
|
||||
shutdownAndAssert(net, ht, carol1)
|
||||
failoverTimeout = 30 * time.Second
|
||||
|
||||
@@ -425,7 +425,6 @@ func testForwardInterceptorBasic(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
return err == nil && len(channels.Channels) > 0
|
||||
}, defaultTimeout)
|
||||
require.NoError(t.t, err, "alice <> bob channel didn't re-activate")
|
||||
|
||||
}
|
||||
|
||||
// interceptorTestContext is a helper struct to hold the test context and
|
||||
|
||||
@@ -77,7 +77,6 @@ func testBasicChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
expType := carolCommitType
|
||||
|
||||
switch daveCommitType {
|
||||
|
||||
// Dave supports anchors, type will be what
|
||||
// Carol supports.
|
||||
case lnrpc.CommitmentType_ANCHORS:
|
||||
|
||||
@@ -473,7 +473,6 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
assertChannelConstraintsEqual(
|
||||
t, aliceChannel.RemoteConstraints, bobChannel.LocalConstraints,
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
// testMaxPendingChannels checks that error is returned from remote peer if
|
||||
@@ -523,6 +522,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
} else if !strings.Contains(
|
||||
err.Error(), lnwire.ErrMaxPendingChannels.Error(),
|
||||
) {
|
||||
|
||||
t.Fatalf("not expected error was received: %v", err)
|
||||
}
|
||||
|
||||
@@ -773,7 +773,6 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
predErr = checkNumForceClosedChannels(pendingChanResp, 0)
|
||||
|
||||
return predErr == nil
|
||||
|
||||
}, defaultTimeout)
|
||||
if err != nil {
|
||||
t.Fatalf("channels not marked as fully resolved: %v", predErr)
|
||||
|
||||
@@ -369,6 +369,7 @@ func assertHtlcEvents(t *harnessTest, fwdCount, fwdFailCount, settleCount int,
|
||||
// type is different from the htlc event type (forward, link failure etc).
|
||||
func assertEventAndType(t *harnessTest, eventType routerrpc.HtlcEvent_EventType,
|
||||
client routerrpc.Router_SubscribeHtlcEventsClient) *routerrpc.HtlcEvent {
|
||||
|
||||
event, err := client.Recv()
|
||||
if err != nil {
|
||||
t.Fatalf("could not get event")
|
||||
|
||||
@@ -299,7 +299,6 @@ func testMultiHopHtlcAggregation(net *lntest.NetworkHarness, t *harnessTest,
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// In case of anchor we expect all the timeout and success second
|
||||
@@ -311,7 +310,6 @@ func testMultiHopHtlcAggregation(net *lntest.NetworkHarness, t *harnessTest,
|
||||
} else {
|
||||
require.Len(t.t, timeoutTxs, numInvoices)
|
||||
require.Len(t.t, successTxs, numInvoices)
|
||||
|
||||
}
|
||||
|
||||
// All mempool transactions should be spending from the commitment
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
)
|
||||
|
||||
func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
|
||||
type testCase struct {
|
||||
name string
|
||||
test func(net *lntest.NetworkHarness, t *harnessTest, alice,
|
||||
@@ -180,7 +179,6 @@ func checkPaymentStatus(node *lntest.HarnessNode, preimage lntypes.Preimage,
|
||||
}
|
||||
|
||||
switch status {
|
||||
|
||||
// If this expected status is SUCCEEDED, we expect the final preimage.
|
||||
case lnrpc.Payment_SUCCEEDED:
|
||||
if p.PaymentPreimage != preimage.String() {
|
||||
@@ -195,7 +193,6 @@ func checkPaymentStatus(node *lntest.HarnessNode, preimage lntypes.Preimage,
|
||||
p.PaymentPreimage)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if !found {
|
||||
|
||||
@@ -77,6 +77,7 @@ func testGetRecoveryInfo(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if recoveryMode != expectedRecoveryMode ||
|
||||
recoveryFinished != expectedRecoveryFinished ||
|
||||
progress != expectedProgress {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -1072,7 +1072,6 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
if bkpStats == nil {
|
||||
return errors.New("no active backup sessions")
|
||||
|
||||
@@ -725,9 +725,8 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
|
||||
|
||||
// At this place we should get an rpc error with notification
|
||||
// that edge is not found on hop(0)
|
||||
if _, err := alicePayStream.Recv(); err != nil && strings.Contains(err.Error(),
|
||||
"edge not found") {
|
||||
|
||||
_, err = alicePayStream.Recv()
|
||||
if err != nil && strings.Contains(err.Error(), "edge not found") {
|
||||
} else if err != nil {
|
||||
t.Fatalf("payment stream has been closed but fake route has consumed: %v", err)
|
||||
}
|
||||
@@ -1423,7 +1422,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
|
||||
closeChannelAndAssert(t, net, carol, chanPointCarol, false)
|
||||
}
|
||||
|
||||
// computeFee calculates the payment fee as specified in BOLT07
|
||||
// computeFee calculates the payment fee as specified in BOLT07.
|
||||
func computeFee(baseFee, feeRate, amt lnwire.MilliSatoshi) lnwire.MilliSatoshi {
|
||||
return baseFee + amt*feeRate/1000000
|
||||
}
|
||||
|
||||
@@ -129,7 +129,6 @@ func testSendMultiPathPayment(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
if htlc.State == lnrpc.InvoiceHTLCState_SETTLED {
|
||||
settled++
|
||||
}
|
||||
|
||||
}
|
||||
if settled != succeeded {
|
||||
t.Fatalf("expected invoice to be settled "+
|
||||
|
||||
@@ -211,7 +211,6 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
err = wait.Predicate(func() bool {
|
||||
predErr = assertNumActiveHtlcs(nodes, 0)
|
||||
return predErr == nil
|
||||
|
||||
}, defaultTimeout)
|
||||
if err != nil {
|
||||
t.Fatalf("htlc mismatch: %v", predErr)
|
||||
@@ -737,7 +736,6 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
|
||||
err = wait.Predicate(func() bool {
|
||||
predErr = assertNumActiveHtlcs(nodes, numPayments)
|
||||
return predErr == nil
|
||||
|
||||
}, defaultTimeout)
|
||||
if err != nil {
|
||||
t.Fatalf("htlc mismatch: %v", predErr)
|
||||
|
||||
@@ -42,7 +42,7 @@ var (
|
||||
"split test cases with the given (0-based) index",
|
||||
)
|
||||
|
||||
// dbBackendFlag specifies the backend to use
|
||||
// dbBackendFlag specifies the backend to use.
|
||||
dbBackendFlag = flag.String("dbbackend", "bbolt", "Database backend "+
|
||||
"(bbolt, etcd, postgres)")
|
||||
)
|
||||
|
||||
@@ -97,7 +97,6 @@ func (h *harnessTest) Fatalf(format string, a ...interface{}) {
|
||||
// RunTestCase executes a harness test case. Any errors or panics will be
|
||||
// represented as fatal.
|
||||
func (h *harnessTest) RunTestCase(testCase *testCase) {
|
||||
|
||||
h.testCase = testCase
|
||||
defer func() {
|
||||
h.testCase = nil
|
||||
|
||||
@@ -136,7 +136,7 @@ func completePaymentRequests(client lnrpc.LightningClient,
|
||||
return nil
|
||||
}
|
||||
|
||||
// makeFakePayHash creates random pre image hash
|
||||
// makeFakePayHash creates random pre image hash.
|
||||
func makeFakePayHash(t *harnessTest) []byte {
|
||||
randBuf := make([]byte, 32)
|
||||
|
||||
@@ -190,7 +190,6 @@ func createPayReqs(node *lntest.HarnessNode, paymentAmt btcutil.Amount,
|
||||
// getChanInfo is a helper method for getting channel info for a node's sole
|
||||
// channel.
|
||||
func getChanInfo(node *lntest.HarnessNode) (*lnrpc.Channel, error) {
|
||||
|
||||
ctxb := context.Background()
|
||||
ctx, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
@@ -301,7 +300,6 @@ func calculateMaxHtlc(chanCap btcutil.Amount) uint64 {
|
||||
// waitForNodeBlockHeight queries the node for its current block height until
|
||||
// it reaches the passed height.
|
||||
func waitForNodeBlockHeight(node *lntest.HarnessNode, height int32) error {
|
||||
|
||||
ctxb := context.Background()
|
||||
ctx, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
Reference in new issue
Block a user