From 39225a684d0a1884af2b281d67c4b19775bc919f Mon Sep 17 00:00:00 2001 From: positiveblue Date: Tue, 18 Jan 2022 19:16:40 -0800 Subject: [PATCH] venue: populate `NumChansCreated` The `AccountTally` had the `NumChansCreated` field stored and retrieved properly but its value was never set. Note: notice that, given a batch, the sum of all the `tally.NumChansCreated` is the double of the chan created in that batch. --- venue/matching/tradingfees.go | 5 +++++ venue/matching/tradingfees_test.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/venue/matching/tradingfees.go b/venue/matching/tradingfees.go index fdf9a3b6c..df011989e 100644 --- a/venue/matching/tradingfees.go +++ b/venue/matching/tradingfees.go @@ -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 } diff --git a/venue/matching/tradingfees_test.go b/venue/matching/tradingfees_test.go index f636b9df4..af206c9a0 100644 --- a/venue/matching/tradingfees_test.go +++ b/venue/matching/tradingfees_test.go @@ -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