From 690992043b31a5c526b5bd5642d0dcdb2e3b52dd Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 26 Apr 2018 14:19:57 +0200 Subject: [PATCH] breacharbiter_test: add double handoff event --- breacharbiter_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/breacharbiter_test.go b/breacharbiter_test.go index d94a8b72..216bf36c 100644 --- a/breacharbiter_test.go +++ b/breacharbiter_test.go @@ -1018,6 +1018,32 @@ func TestBreachHandoffSuccess(t *testing.T) { // retribution information and the channel should be shown as pending // force closed. assertArbiterBreach(t, brar, chanPoint) + + // Send another breach event. Since the handoff for this channel was + // already ACKed, the breach arbiter should immediately ACK and ignore + // this event. + breach = &ContractBreachEvent{ + ChanPoint: *chanPoint, + ProcessACK: make(chan error, 1), + BreachRetribution: &lnwallet.BreachRetribution{ + BreachTransaction: bobClose.CloseTx, + }, + } + + contractBreaches <- breach + + // We'll also wait to consume the ACK back from the breach arbiter. + select { + case err := <-breach.ProcessACK: + if err != nil { + t.Fatalf("handoff failed: %v", err) + } + case <-time.After(time.Second * 15): + t.Fatalf("breach arbiter didn't send ack back") + } + + // State should not have changed. + assertArbiterBreach(t, brar, chanPoint) } // TestBreachHandoffFail tests that a channel's close observer properly