htlcswitch: finish remainder of TestUpdateForwardingPolicy test case
In this commit, we address a lingering TODO within the TestUpdateForwardingPolicy test case to ensure that Bob will reject the payment the second time around due to an update in his fee policy.
This commit is contained in:
parent
57b9b78ce3
commit
21446c2872
@ -629,8 +629,7 @@ func TestUpdateForwardingPolicy(t *testing.T) {
|
|||||||
n.firstBobChannelLink, n.carolChannelLink)
|
n.firstBobChannelLink, n.carolChannelLink)
|
||||||
|
|
||||||
// First, send this 1 BTC payment over the three hops, the payment
|
// First, send this 1 BTC payment over the three hops, the payment
|
||||||
// should succeed, and all balances should be updated
|
// should succeed, and all balances should be updated accordingly.
|
||||||
// accordingly.
|
|
||||||
invoice, err := n.makePayment(n.aliceServer, n.carolServer,
|
invoice, err := n.makePayment(n.aliceServer, n.carolServer,
|
||||||
n.bobServer.PubKey(), hops, amountNoFee, htlcAmt,
|
n.bobServer.PubKey(), hops, amountNoFee, htlcAmt,
|
||||||
htlcExpiry)
|
htlcExpiry)
|
||||||
@ -675,7 +674,25 @@ func TestUpdateForwardingPolicy(t *testing.T) {
|
|||||||
newPolicy.BaseFee = lnwire.NewMSatFromSatoshis(1000)
|
newPolicy.BaseFee = lnwire.NewMSatFromSatoshis(1000)
|
||||||
n.firstBobChannelLink.UpdateForwardingPolicy(newPolicy)
|
n.firstBobChannelLink.UpdateForwardingPolicy(newPolicy)
|
||||||
|
|
||||||
// TODO(roasbeef): should send again an ensure rejected?
|
// Next, we'll send the payment again, using the exact same per-hop
|
||||||
|
// payload for each node. This payment should fail as it wont' factor
|
||||||
|
// in Bob's new fee policy.
|
||||||
|
_, err = n.makePayment(n.aliceServer, n.carolServer,
|
||||||
|
n.bobServer.PubKey(), hops, amountNoFee, htlcAmt,
|
||||||
|
htlcExpiry)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("payment should've been rejected")
|
||||||
|
}
|
||||||
|
|
||||||
|
ferr, ok := err.(*ForwardingError)
|
||||||
|
if !ok {
|
||||||
|
t.Fatalf("expected a ForwardingError, instead got: %T", err)
|
||||||
|
}
|
||||||
|
switch ferr.FailureMessage.(type) {
|
||||||
|
case *lnwire.FailFeeInsufficient:
|
||||||
|
default:
|
||||||
|
t.Fatalf("expected FailFeeInsufficient instead got: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestChannelLinkMultiHopInsufficientPayment checks that we receive error if
|
// TestChannelLinkMultiHopInsufficientPayment checks that we receive error if
|
||||||
|
@ -384,14 +384,10 @@ func generateHops(payAmt lnwire.MilliSatoshi, startingHeight uint32,
|
|||||||
fee := ExpectedFee(path[i].cfg.FwrdingPolicy, prevAmount)
|
fee := ExpectedFee(path[i].cfg.FwrdingPolicy, prevAmount)
|
||||||
runningAmt += fee
|
runningAmt += fee
|
||||||
|
|
||||||
// If the this the first hop, then we don't need to
|
// Otherwise, for a node to forward an HTLC, then
|
||||||
// apply any fee, otherwise, the amount to forward
|
// following inequality most hold true:
|
||||||
// needs to take into account the fees.
|
// * amt_in - fee >= amt_to_forward
|
||||||
if i == 0 {
|
amount = runningAmt - fee
|
||||||
amount = prevAmount
|
|
||||||
} else {
|
|
||||||
amount = prevAmount + fee
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hops[i] = ForwardingInfo{
|
hops[i] = ForwardingInfo{
|
||||||
|
Loading…
Reference in New Issue
Block a user