Skip to content

Commit 68494fd

Browse files
authored
Merge pull request #8839 from ellemouton/abandonChanItestFix
itest+lntest: let abandoned channel be either not found or in zombie
2 parents cbe1c15 + f3cdbbe commit 68494fd

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

itest/lnd_misc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ func testAbandonChannel(ht *lntest.HarnessTest) {
729729
require.Len(ht, aliceClosedList.Channels, 1, "alice closed channels")
730730

731731
// Ensure that the channel can no longer be found in the channel graph.
732-
ht.AssertZombieChannel(alice, chanID)
732+
ht.AssertNotInGraph(alice, chanID)
733733

734734
// Make sure the channel is no longer in the channel backup list.
735735
err = wait.NoError(func() error {

lntest/harness_assertion.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,37 @@ func (h *HarnessTest) AssertZombieChannel(hn *node.HarnessNode, chanID uint64) {
18201820
require.NoError(h, err, "timeout while checking zombie channel")
18211821
}
18221822

1823+
// AssertNotInGraph asserts that a given channel is either not found at all in
1824+
// the graph or that it has been marked as a zombie.
1825+
func (h *HarnessTest) AssertNotInGraph(hn *node.HarnessNode, chanID uint64) {
1826+
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
1827+
defer cancel()
1828+
1829+
err := wait.NoError(func() error {
1830+
_, err := hn.RPC.LN.GetChanInfo(
1831+
ctxt, &lnrpc.ChanInfoRequest{ChanId: chanID},
1832+
)
1833+
if err == nil {
1834+
return fmt.Errorf("expected error but got nil")
1835+
}
1836+
1837+
switch {
1838+
case strings.Contains(err.Error(), "marked as zombie"):
1839+
return nil
1840+
1841+
case strings.Contains(err.Error(), "edge not found"):
1842+
return nil
1843+
1844+
default:
1845+
return fmt.Errorf("expected error to contain either "+
1846+
"'%s' or '%s' but was: '%v'", "marked as i"+
1847+
"zombie", "edge not found", err)
1848+
}
1849+
}, DefaultTimeout)
1850+
require.NoError(h, err, "timeout while checking that channel is not "+
1851+
"found in graph")
1852+
}
1853+
18231854
// AssertTxAtHeight gets all of the transactions that a node's wallet has a
18241855
// record of at the target height, and finds and returns the tx with the target
18251856
// txid, failing if it is not found.

0 commit comments

Comments
 (0)