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:
Joost Jager 2019-02-22 18:37:33 +01:00
parent 3b5c2f44c6
commit e464ed18c7
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -1066,22 +1066,15 @@ func TestChannelLinkMultiHopUnknownPaymentHash(t *testing.T) {
t.Fatal(err)
}
// Generate payment: invoice and htlc.
invoice, htlc, err := generatePayment(amount, htlcAmt, totalTimelock,
// Generate payment invoice and htlc, but don't add this invoice to the
// receiver registry. This should trigger an unknown payment hash
// failure.
_, htlc, err := generatePayment(amount, htlcAmt, totalTimelock,
blob)
if err != nil {
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.
_, err = n.aliceServer.htlcSwitch.SendHTLC(
n.firstBobChannelLink.ShortChanID(), htlc,
@ -1095,12 +1088,6 @@ func TestChannelLinkMultiHopUnknownPaymentHash(t *testing.T) {
// Wait for Alice to receive the revocation.
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 {
t.Fatal("the bandwidth of alice channel link which handles " +
"alice->bob channel should be the same")