breacharbiter_test: assert publication of adjusted justice tx
Since the breacharbiter will publish an adjusted justice tx after detecing a spend from the breached commitment, we could get into a race where sometime it would not get the second spend before publication, resulting in a deadlock on the publTx channel. Now we instead wait for the publication of this adjusted tx before notifying the second spend.
This commit is contained in:
parent
b74c1ca822
commit
fb99994720
@ -1978,13 +1978,34 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
|
|||||||
require.Len(t, spending, len(justiceTx.TxIn))
|
require.Len(t, spending, len(justiceTx.TxIn))
|
||||||
require.Len(t, splits, 2)
|
require.Len(t, splits, 2)
|
||||||
|
|
||||||
// Finally notify that they confirm, making the breach arbiter clean
|
// Notify that the first split confirm, making the breach arbiter
|
||||||
// up.
|
// publish another TX with the remaining inputs.
|
||||||
for _, tx := range splits {
|
for _, in := range splits[0].TxIn {
|
||||||
for _, in := range tx.TxIn {
|
op := &in.PreviousOutPoint
|
||||||
op := &in.PreviousOutPoint
|
notifier.Spend(op, blockHeight+5, splits[0])
|
||||||
notifier.Spend(op, blockHeight+5, tx)
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
|
||||||
|
// The published tx should spend the same inputs as our second split.
|
||||||
|
case tx := <-publTx:
|
||||||
|
require.Len(t, tx.TxIn, len(splits[1].TxIn))
|
||||||
|
for i := range tx.TxIn {
|
||||||
|
require.Equal(
|
||||||
|
t, tx.TxIn[i].PreviousOutPoint,
|
||||||
|
splits[1].TxIn[i].PreviousOutPoint,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.Fatalf("tx not published")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally notify that the second split confirms, making the breach
|
||||||
|
// arbiter clean up since all inputs have been swept.
|
||||||
|
for _, in := range splits[1].TxIn {
|
||||||
|
op := &in.PreviousOutPoint
|
||||||
|
notifier.Spend(op, blockHeight+6, splits[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that the channel is fully resolved.
|
// Assert that the channel is fully resolved.
|
||||||
|
Loading…
Reference in New Issue
Block a user