mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2026-02-16 03:54:22 +01:00
Modifies the test cases in `TestEdgeUpdateNotification` and `TestNodeUpdateNotification` to check for the possibility of notifications being delivered out of order. This addresses some sporadic failures that were observed when running the test suite. I looked through some of the open issues but didn't see any addressing this issue in particular, but if someone could point me to any relevant issues that would be much appreciated! Issue ----- Currently the test suite validates notifications received in the order they are submitted. The check fails because the verification of each notification is statically linked to the order in which they are delivered, seen [here](1be4d67ce4/routing/notifications_test.go (L403)) and [here](1be4d67ce4/routing/notifications_test.go (L499)) in `routing/notifications_test.go`. The notifications are typically delivered in this order, but causes the test to fail otherwise. Proposed Changes ------------------- Construct an index that maps a public key to its corresponding edges and/or nodes. When a notification is received, use its identifying public key and the index to look up the edge/node to use for validation. Entries are removed from the index after they are verified to ensure that the same entry is validated twice. The logic to dynamically handle the verification of incoming notifications rests can be found here [here](https://github.com/cfromknecht/lnd/blob/order-invariant-ntfns/routing/notifications_test.go#L420) and [here](https://github.com/cfromknecht/lnd/blob/order-invariant-ntfns/routing/notifications_test.go#L539). Encountered Errors -------------------- * `TestEdgeUpdateNotification`: notifications_test.go:379: min HTLC of edge doesn't match: expected 16.7401473 BTC, got 19.4852751 BTC * `TestNodeUpdateNotification`: notifications_test.go:485: node identity keys don't match: expected 027b139b2153ac5f3c83c2022e58b3219297d0fb3170739ee6391cddf2e06fe3e7, got 03921deafb61ee13d18e9d96c3ecd9e572e59c8dbd0bb922b5b6ac609d10fe4ee4 Recreating Failing Behavior --------------------------- The failures can be somewhat difficult to recreate, I was able to reproduce them by running the unit tests repeatedly until they showed up. I used the following commands to bring them out of hiding: ``` ./gotest.sh -i go test -test.v ./routing && while [ $? -eq 0 ]; do go test -test.v ./routing; done ``` I was unable to recreate these errors, or any others in this package, after making the proposed changes and leaving the script running continuously for ~30 minutes. Previously, I could consistently generate an error after ~20 seconds had elapsed on the latest commit in master at the time of writing:78f6caf5d2. Moar stability ftw!
routing
The routing package implements authentication+validation of channel announcements, pruning of the channel graph, path finding within the network, sending outgoing payments into the network and synchronizing new peers to our channel graph state.
Installation and Updating
$ go get -u github.com/lightningnetwork/lnd/routing