Skip to content

Commit

Permalink
Merge pull request lightninglabs#354 from lightninglabs/populate-num-…
Browse files Browse the repository at this point in the history
…chans-created

venue: populate `NumChansCreated`
  • Loading branch information
guggero authored Jan 20, 2022
2 parents 4558f3f + 39225a6 commit 7ac2444
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions venue/matching/tradingfees.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ func NewTradingFeeReport(subBatches map[uint32][]MatchedOrder,
order.Details.Bid.LeaseDuration(),
)

// Increase the number of channels that the participant
// took part of.
takerDiff.AccountTally.NumChansCreated++
makerDiff.AccountTally.NumChansCreated++

accountDiffs[taker.AccountKey] = takerDiff
accountDiffs[maker.AccountKey] = makerDiff
}
Expand Down
15 changes: 15 additions & 0 deletions venue/matching/tradingfees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ func TestTradingReportGeneration(t *testing.T) {
subBatches, feeSchedule, clearingPrices,
)

numOfChannels := uint32(0)
for _, traderDiff := range report.AccountDiffs {
numOfChannels += traderDiff.AccountTally.NumChansCreated
}

// Every channels is double counted (from the maker's
// and taker's side). numOfChannels must then be the double of
// matched orders.
if numOfChannels != uint32(len(matchedOrders)*2) {
t.Logf("expected %v new channels, instead num of new "+
"channels is %v", len(matchedOrders),
numOfChannels/2)
return false
}

// The total amount of fees that each trader paid should
// properly sum up to the total amount of fees the auctioneer
// takes
Expand Down

0 comments on commit 7ac2444

Please sign in to comment.