Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcserver+lnd_test: fixing unassigned UnsettledBalance field #2289

Merged
merged 1 commit into from Jan 11, 2019

Conversation

5 participants
@ccdle12
Copy link
Contributor

ccdle12 commented Dec 7, 2018

fixes #2274

This PR adds a loop that sums the amount of PendingHtlcs to the UnsettledBalance field for Channels. Also adds a test in lnd_test to ensure that the UnsettledBalance field is actually updated.

@cfromknecht
Copy link
Collaborator

cfromknecht left a comment

thanks for the PR @ccdle12! great to see a thorough test accompanying the change as well. left a few comments for an initial pass

@@ -2157,6 +2157,12 @@ func (r *rpcServer) ListChannels(ctx context.Context,
}
}

var unsettledBalance int64
for _, htlc := range channel.PendingHtlcs {
unsettledBalance += htlc.Amount

This comment has been minimized.

Copy link
@cfromknecht

cfromknecht Dec 7, 2018

Collaborator

is it possible to do the sumation in the for loop above?

Show resolved Hide resolved lnd_test.go
lnd_test.go Outdated
}

// Force close Alices channel with Carol.
_, _, err = net.CloseChannel(ctxb, net.Alice, chanPointAlice, true)

This comment has been minimized.

Copy link
@cfromknecht

cfromknecht Dec 7, 2018

Collaborator

This can use the closeChannelAndAssert method, which will fully teardown the channel. Here's an example from the test above:

ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout)
closeChannelAndAssert(ctxt, t, net, net.Alice, chanPoint, false)
lnd_test.go Outdated
const chanAmt = btcutil.Amount(1000000)
ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
numInvoices := 6

This comment has been minimized.

Copy link
@cfromknecht

cfromknecht Dec 7, 2018

Collaborator

suggestion: define this as const down where payAmt is defined

@ccdle12

This comment has been minimized.

Copy link
Contributor Author

ccdle12 commented Dec 7, 2018

@cfromknecht Thanks for review! appreciate the insights into the tests, I'll update according to the comments

@ccdle12 ccdle12 closed this Dec 8, 2018

@ccdle12 ccdle12 reopened this Dec 8, 2018

@ccdle12

This comment has been minimized.

Copy link
Contributor Author

ccdle12 commented Dec 8, 2018

@cfromknecht I've updated the PR according to the suggestions but it's strange I'm receiving no test failures when I run make check locally but failing in travis?

@ccdle12 ccdle12 force-pushed the ccdle12:unsettled-balance branch from c8db123 to 23fe966 Dec 11, 2018

@halseth

This comment has been minimized.

Copy link
Collaborator

halseth commented Dec 11, 2018

@ccdle12 The Travis failure is unrelated to your change, I'm working on a fix :)

@ccdle12

This comment has been minimized.

Copy link
Contributor Author

ccdle12 commented Dec 11, 2018

@halseth thanks! definitely puts my mind at ease a bit :)

@wpaulino
Copy link
Collaborator

wpaulino left a comment

Changes LGTM, mostly just nits.

When addressing review feedback, "fixup" commits would be preferred, like the case for the last three commits. Otherwise, on first glance, they look like they introduce new behavior rather than addressing an existing comment.

Show resolved Hide resolved lnd_test.go
lnd_test.go Outdated
}

return true
}, time.Second*15)

This comment has been minimized.

Copy link
@wpaulino

wpaulino Dec 11, 2018

Collaborator

Nit: can use defaultTimeout here.

This comment has been minimized.

Copy link
@ccdle12

ccdle12 Dec 13, 2018

Author Contributor

fixed

lnd_test.go Outdated
expectedBalance := numInvoices * payAmt

// Closure helper to check Unsettled Balance.
assertUnsettledBalance := func(expected int,

This comment has been minimized.

Copy link
@wpaulino

wpaulino Dec 11, 2018

Collaborator

Any reason this needs to be defined as a closure? Doesn't seem to be used anywhere else.

This comment has been minimized.

Copy link
@ccdle12

ccdle12 Dec 13, 2018

Author Contributor

fixed

Show resolved Hide resolved lnd_test.go
@ccdle12

This comment has been minimized.

Copy link
Contributor Author

ccdle12 commented Dec 12, 2018

@wpaulino thanks, appreciate the detailed review, I'll get started on the comments

@Roasbeef Roasbeef added this to In progress in High Priority via automation Dec 18, 2018

@ccdle12 ccdle12 force-pushed the ccdle12:unsettled-balance branch 2 times, most recently from 1e4507b to 90de921 Dec 18, 2018

@ccdle12 ccdle12 closed this Jan 7, 2019

@ccdle12 ccdle12 deleted the ccdle12:unsettled-balance branch Jan 7, 2019

High Priority automation moved this from In progress to Done Jan 7, 2019

@ccdle12 ccdle12 restored the ccdle12:unsettled-balance branch Jan 7, 2019

@ccdle12 ccdle12 reopened this Jan 7, 2019

High Priority automation moved this from Done to In progress Jan 7, 2019

@ccdle12 ccdle12 force-pushed the ccdle12:unsettled-balance branch from 90de921 to e2edcd4 Jan 7, 2019

@cfromknecht
Copy link
Collaborator

cfromknecht left a comment

@ccdle12 coming along nicely! a few last style/timeout changes

lnd_test.go Outdated
}

// Force and assert the channel closure.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)

This comment has been minimized.

Copy link
@cfromknecht

cfromknecht Jan 7, 2019

Collaborator

should use channelCloseTimeout instead

This comment has been minimized.

Copy link
@ccdle12

ccdle12 Jan 8, 2019

Author Contributor

fixed!

lnd_test.go Outdated
}

// Open a channel between Alice and Carol.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)

This comment has been minimized.

Copy link
@cfromknecht

cfromknecht Jan 7, 2019

Collaborator

can use channelOpenTimeout here

This comment has been minimized.

Copy link
@ccdle12

ccdle12 Jan 7, 2019

Author Contributor

fixed!

lnd_test.go Outdated

// Create a paystream from Alice to Carol to enable Alice to make
// a series of payments.
alicePayStream, err := net.Alice.SendPayment(ctxb)

This comment has been minimized.

Copy link
@cfromknecht

cfromknecht Jan 7, 2019

Collaborator

should probably have a ctxt with defaultTimeout

This comment has been minimized.

Copy link
@ccdle12

ccdle12 Jan 7, 2019

Author Contributor

fixed!

lnd_test.go Outdated
ctxb := context.Background()

// Create carol in hodl mode.
carol, err := net.NewNode("Carol", []string{"--debughtlc", "--hodl.exit-settle"})

This comment has been minimized.

Copy link
@cfromknecht

cfromknecht Jan 7, 2019

Collaborator

this line looks a little long to me. i'd suggest wrapping the args like:

carol, err := new.NewNode("Carol", []string{
        "--debughtlc",
        "--hodl.exit-settle",
})

This comment has been minimized.

Copy link
@ccdle12

ccdle12 Jan 8, 2019

Author Contributor

fixed!

@ccdle12

This comment has been minimized.

Copy link
Contributor Author

ccdle12 commented Jan 7, 2019

@cfromknecht Thanks! I'll fixup according to the reviews and respond to the comments accordingly.

@cfromknecht

This comment has been minimized.

Copy link
Collaborator

cfromknecht commented Jan 8, 2019

Awesome thanks @ccdle12! I'm happy with these changes, @wpaulino do you have anything else?

@wpaulino

This comment has been minimized.

Copy link
Collaborator

wpaulino commented Jan 8, 2019

LGTM after a squash and rebase 🕺🏻

@cfromknecht

This comment has been minimized.

Copy link
Collaborator

cfromknecht commented Jan 10, 2019

Indeed this should be ready to land after a rebase!

@ccdle12 ccdle12 force-pushed the ccdle12:unsettled-balance branch from 40e3efb to cc02bf7 Jan 11, 2019

rpcserver+lnd_test: adding PendingHtlcs to UnsetteldBalance
rpcserver: summing PendingHtlcs and assigning to UnsettledBalance

lnd_test: adding tests for UnsettledBalance

@ccdle12 ccdle12 force-pushed the ccdle12:unsettled-balance branch from cc02bf7 to 264293f Jan 11, 2019

@ccdle12

This comment has been minimized.

Copy link
Contributor Author

ccdle12 commented Jan 11, 2019

@cfromknecht, @wpaulino

Squashed and rebased,

thanks guy, really appreciate all the help and the reviews!

@cfromknecht
Copy link
Collaborator

cfromknecht left a comment

Thanks for tackling this @ccdle12, LGTM! 🦒

High Priority automation moved this from In progress to Final Testing -- Ready For Merge Jan 11, 2019

@halseth
Copy link
Collaborator

halseth left a comment

Great work, @ccdle12! A one-line fix with a solid test addition 👏

LGTM 💯

@halseth halseth merged commit a324691 into lightningnetwork:master Jan 11, 2019

1 of 2 checks passed

coverage/coveralls Coverage decreased (-0.005%) to 56.267%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

High Priority automation moved this from Final Testing -- Ready For Merge to Done Jan 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.