lntest+itest: extend CloseChannelAssertPending
In this commit, we extend `CloseChannelAssertPending` with new args that returns the raw close status update (as we have more things we'd like to assert), and also allows us to pass in a custom fee rate.
This commit is contained in:
1 parent
2899a757c4
commit
fbc67f7610
4 files changed
+60
-21
No files matched your search
+32
-7
@@ -1208,14 +1208,40 @@ func (h *HarnessTest) OpenChannelAssertErr(srcNode, destNode *node.HarnessNode,
|
||||
"error returned, want %v, got %v", expectedErr, err)
|
||||
}
|
||||
|
||||
// closeChannelOpts holds the options for closing a channel.
|
||||
type closeChannelOpts struct {
|
||||
feeRate fn.Option[chainfee.SatPerVByte]
|
||||
}
|
||||
|
||||
// CloseChanOpt is a functional option to modify the way we close a channel.
|
||||
type CloseChanOpt func(*closeChannelOpts)
|
||||
|
||||
// WithCoopCloseFeeRate is a functional option to set the fee rate for a coop
|
||||
// close attempt.
|
||||
func WithCoopCloseFeeRate(rate chainfee.SatPerVByte) CloseChanOpt {
|
||||
return func(o *closeChannelOpts) {
|
||||
o.feeRate = fn.Some(rate)
|
||||
}
|
||||
}
|
||||
|
||||
// defaultCloseOpts returns the set of default close options.
|
||||
func defaultCloseOpts() *closeChannelOpts {
|
||||
return &closeChannelOpts{}
|
||||
}
|
||||
|
||||
// CloseChannelAssertPending attempts to close the channel indicated by the
|
||||
// passed channel point, initiated by the passed node. Once the CloseChannel
|
||||
// rpc is called, it will consume one event and assert it's a close pending
|
||||
// event. In addition, it will check that the closing tx can be found in the
|
||||
// mempool.
|
||||
func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
||||
cp *lnrpc.ChannelPoint,
|
||||
force bool) (rpc.CloseChanClient, chainhash.Hash) {
|
||||
cp *lnrpc.ChannelPoint, force bool,
|
||||
opts ...CloseChanOpt) (rpc.CloseChanClient, *lnrpc.CloseStatusUpdate) {
|
||||
|
||||
closeOpts := defaultCloseOpts()
|
||||
for _, optFunc := range opts {
|
||||
optFunc(closeOpts)
|
||||
}
|
||||
|
||||
// Calls the rpc to close the channel.
|
||||
closeReq := &lnrpc.CloseChannelRequest{
|
||||
@@ -1224,10 +1250,9 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
||||
NoWait: true,
|
||||
}
|
||||
|
||||
// For coop close, we use a default confg target of 6.
|
||||
if !force {
|
||||
closeReq.TargetConf = 6
|
||||
}
|
||||
closeOpts.feeRate.WhenSome(func(feeRate chainfee.SatPerVByte) {
|
||||
closeReq.SatPerVbyte = uint64(feeRate)
|
||||
})
|
||||
|
||||
var (
|
||||
stream rpc.CloseChanClient
|
||||
@@ -1260,7 +1285,7 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
||||
// Assert the closing tx is in the mempool.
|
||||
h.miner.AssertTxInMempool(*closeTxid)
|
||||
|
||||
return stream, *closeTxid
|
||||
return stream, event
|
||||
}
|
||||
|
||||
// CloseChannel attempts to coop close a non-anchored channel identified by the
|
||||
|
||||
Reference in new issue
Block a user