From 1edf8123e4dec44e97b1685844aefcbd7edb06d7 Mon Sep 17 00:00:00 2001 From: George Tsagkarelis Date: Thu, 18 Dec 2025 17:09:51 +0100 Subject: [PATCH] lnwallet: add aux test utils We add this constructor for an AuxHtlcDescriptor that allows setting some of the internal fields. This is useful for testing purposes for code external to this package that may need to extensively test the AuxHtlcView. --- lnwallet/aux_test_utils.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lnwallet/aux_test_utils.go diff --git a/lnwallet/aux_test_utils.go b/lnwallet/aux_test_utils.go new file mode 100644 index 000000000..1e76a522e --- /dev/null +++ b/lnwallet/aux_test_utils.go @@ -0,0 +1,31 @@ +package lnwallet + +import ( + "github.com/lightningnetwork/lnd/lnwire" +) + +// NewTestAuxHtlcDescriptor creates an AuxHtlcDescriptor for testing purposes. +// This function allows tests to create descriptors with specific commit heights +// and entry types, which are normally unexported fields. +func NewTestAuxHtlcDescriptor(chanID lnwire.ChannelID, + rHash PaymentHash, timeout uint32, + amount lnwire.MilliSatoshi, htlcIndex, parentIndex uint64, + entryType uint8, customRecords lnwire.CustomRecords, + addHeightLocal, addHeightRemote, removeHeightLocal, + removeHeightRemote uint64) AuxHtlcDescriptor { + + return AuxHtlcDescriptor{ + ChanID: chanID, + RHash: rHash, + Timeout: timeout, + Amount: amount, + HtlcIndex: htlcIndex, + ParentIndex: parentIndex, + EntryType: updateType(entryType), + CustomRecords: customRecords, + addCommitHeightLocal: addHeightLocal, + addCommitHeightRemote: addHeightRemote, + removeCommitHeightLocal: removeHeightLocal, + removeCommitHeightRemote: removeHeightRemote, + } +}