routing: add new error for failed funding tx validation

In this commit we add a new error for when we fail to validate the
funding transaction (invalid script, etc) and mark it as a zombie like
the other failed validation cases.
This commit is contained in:
Olaoluwa Osuntokun
2021-04-22 18:41:15 -05:00
parent 92c47983cb
commit e0ce384f02
3 changed files with 59 additions and 32 deletions

View File

@@ -3149,6 +3149,10 @@ const (
// edgeCreationNoUTXO is used to skip adding the UTXO of a channel to
// the UTXO set.
edgeCreationNoUTXO
// edgeCreationBadScript is used to create the edge, but use the wrong
// scrip which should cause it to fail output validation.
edgeCreationBadScript
)
// newChannelEdgeInfo is a helper function used to create a new channel edge,
@@ -3196,6 +3200,10 @@ func newChannelEdgeInfo(ctx *testCtx, fundingHeight uint32,
})
}
if ecm == edgeCreationBadScript {
fundingTx.TxOut[0].PkScript[0] ^= 1
}
return edge, nil
}
@@ -3247,4 +3255,10 @@ func TestChannelOnChainRejectionZombie(t *testing.T) {
// Instead now, we'll remove it from the set of UTXOs which should
// cause the spentness validation to fail.
assertChanChainRejection(t, ctx, edge, ErrChannelSpent)
// If we cause the funding transaction the chain to fail validation, we
// should see similar behavior.
edge, err = newChannelEdgeInfo(ctx, 3, edgeCreationBadScript)
require.Nil(t, err)
assertChanChainRejection(t, ctx, edge, ErrInvalidFundingOutput)
}