lnwallet: bring processFeeUpdate in line with process[Add|Remove]Entry

This commit redoes the API and semantics of processFeeUpdate to make
it consistent with the semantics of it's sister functions. This is
part of an ongoing series of commits to remove mutateState arguments
pervasively from the codebase.

As with the previous commit this makes state mutation the caller's
responsibility. This temporarily increases code duplication at the
call-sites, but this will unlock other refactor opportunities.
This commit is contained in:
Keagan McClelland committed 2024-10-11 11:25:58 +02:00
1 parent 49add0f57b
commit 05347c8392
2 files changed
+64 -35

No files matched your search

+22 -3
View File
@@ -9204,11 +9204,30 @@ func TestProcessFeeUpdate(t *testing.T) {
view := &HtlcView{
FeePerKw: chainfee.SatPerKWeight(feePerKw),
}
processFeeUpdate(
update, nextHeight, test.whoseCommitChain,
test.mutate, view,
h := update.addCommitHeights.GetForParty(
test.whoseCommitChain,
)
if h == 0 {
processFeeUpdate(
update, &view.FeePerKw, nextHeight,
test.whoseCommitChain,
)
if test.mutate {
update.addCommitHeights.SetForParty(
test.whoseCommitChain,
nextHeight,
)
update.removeCommitHeights.SetForParty(
test.whoseCommitChain,
nextHeight,
)
}
}
if view.FeePerKw != test.expectedFee {
t.Fatalf("expected fee: %v, got: %v",
test.expectedFee, feePerKw)