htlcswitch/test: make unknown hash test independent of mock
In the TestChannelLinkMultiHopUnknownPaymentHash test, a preimage was modified to trigger an unknown payment hash failure. The way the mock is implemented, it would take the hash of that modified preimage and store it. It basically stores a completely different invoice. For this test, it is just as good to store no invoice at all.
This commit is contained in:
parent
3b5c2f44c6
commit
e464ed18c7
@ -1066,22 +1066,15 @@ func TestChannelLinkMultiHopUnknownPaymentHash(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate payment: invoice and htlc.
|
// Generate payment invoice and htlc, but don't add this invoice to the
|
||||||
invoice, htlc, err := generatePayment(amount, htlcAmt, totalTimelock,
|
// receiver registry. This should trigger an unknown payment hash
|
||||||
|
// failure.
|
||||||
|
_, htlc, err := generatePayment(amount, htlcAmt, totalTimelock,
|
||||||
blob)
|
blob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to have wrong rhash for that reason we should change the
|
|
||||||
// preimage. Inverse first byte by xoring with 0xff.
|
|
||||||
invoice.Terms.PaymentPreimage[0] ^= byte(255)
|
|
||||||
|
|
||||||
// Check who is last in the route and add invoice to server registry.
|
|
||||||
if err := n.carolServer.registry.AddInvoice(*invoice); err != nil {
|
|
||||||
t.Fatalf("unable to add invoice in carol registry: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send payment and expose err channel.
|
// Send payment and expose err channel.
|
||||||
_, err = n.aliceServer.htlcSwitch.SendHTLC(
|
_, err = n.aliceServer.htlcSwitch.SendHTLC(
|
||||||
n.firstBobChannelLink.ShortChanID(), htlc,
|
n.firstBobChannelLink.ShortChanID(), htlc,
|
||||||
@ -1095,12 +1088,6 @@ func TestChannelLinkMultiHopUnknownPaymentHash(t *testing.T) {
|
|||||||
// Wait for Alice to receive the revocation.
|
// Wait for Alice to receive the revocation.
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
// Check that alice invoice wasn't settled and bandwidth of htlc
|
|
||||||
// links hasn't been changed.
|
|
||||||
if invoice.Terms.State == channeldb.ContractSettled {
|
|
||||||
t.Fatal("alice invoice was settled")
|
|
||||||
}
|
|
||||||
|
|
||||||
if n.aliceChannelLink.Bandwidth() != aliceBandwidthBefore {
|
if n.aliceChannelLink.Bandwidth() != aliceBandwidthBefore {
|
||||||
t.Fatal("the bandwidth of alice channel link which handles " +
|
t.Fatal("the bandwidth of alice channel link which handles " +
|
||||||
"alice->bob channel should be the same")
|
"alice->bob channel should be the same")
|
||||||
|
Loading…
Reference in New Issue
Block a user