htlcswitch: update TestChannelRetransmission to print out expected balance when failure

This commit is contained in:
Olaoluwa Osuntokun 2017-11-10 15:21:11 -08:00
parent 9a6e3b5d9c
commit 431f6fc2c8
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -1890,8 +1890,8 @@ func TestChannelRetransmission(t *testing.T) {
htlcAmt, totalTimelock, hops := generateHops(amount, testStartingHeight, htlcAmt, totalTimelock, hops := generateHops(amount, testStartingHeight,
n.firstBobChannelLink) n.firstBobChannelLink)
// Send payment which should fail because we intercept the update and // Send payment which should fail because we intercept the
// commit messages. // update and commit messages.
receiver := n.bobServer receiver := n.bobServer
rhash, err := n.makePayment(n.aliceServer, receiver, rhash, err := n.makePayment(n.aliceServer, receiver,
n.bobServer.PubKey(), hops, amount, htlcAmt, n.bobServer.PubKey(), hops, amount, htlcAmt,
@ -1900,10 +1900,11 @@ func TestChannelRetransmission(t *testing.T) {
t.Fatalf("payment shouldn't haven been finished") t.Fatalf("payment shouldn't haven been finished")
} }
// Stop network cluster and create new one, with the old channels // Stop network cluster and create new one, with the old
// states. Also do the *hack* - save the payment receiver to pass it // channels states. Also do the *hack* - save the payment
// in new channel link, otherwise payment will be failed because of the // receiver to pass it in new channel link, otherwise payment
// unknown payment hash. Hack will be removed with sphinx payment. // will be failed because of the unknown payment hash. Hack
// will be removed with sphinx payment.
bobRegistry := n.bobServer.registry bobRegistry := n.bobServer.registry
n.stop() n.stop()
@ -1947,15 +1948,17 @@ func TestChannelRetransmission(t *testing.T) {
continue continue
} }
if aliceBandwidthBefore-amount != n.aliceChannelLink.Bandwidth() { aliceExpectedBandwidth := aliceBandwidthBefore - htlcAmt
err = errors.Errorf("alice bandwidth should have been increased" + if aliceExpectedBandwidth != n.aliceChannelLink.Bandwidth() {
" on payment amount") err = errors.Errorf("expected alice to have %v, instead has %v",
aliceExpectedBandwidth, n.aliceChannelLink.Bandwidth())
continue continue
} }
bobExpectedBandwidth := bobBandwidthBefore + htlcAmt
if bobBandwidthBefore+amount != n.firstBobChannelLink.Bandwidth() { if bobBandwidthBefore+amount != n.firstBobChannelLink.Bandwidth() {
err = errors.Errorf("bob bandwidth should have been increased " + err = errors.Errorf("expected bob to have %v, instead has %v",
"on payment amount") bobExpectedBandwidth, n.firstBobChannelLink.Bandwidth())
continue continue
} }
@ -1965,7 +1968,6 @@ func TestChannelRetransmission(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
for _, test := range retransmissionTests { for _, test := range retransmissionTests {