discovery: split sendBatch into local and remote
This commit refactors the method `sendBatch` into `sendLocalBatch` and `sendRemoteBatch` for clarity. The batch size calculation is also moved into `splitAnnouncementBatches`.
This commit is contained in:
2 files changed
+52
-38
No files matched your search
@@ -3531,7 +3531,10 @@ func assertMessage(t *testing.T, expected, got lnwire.Message) {
|
||||
// TestSplitAnnouncementsCorrectSubBatches checks that we split a given
|
||||
// sizes of announcement list into the correct number of batches.
|
||||
func TestSplitAnnouncementsCorrectSubBatches(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create our test harness.
|
||||
const blockHeight = 100
|
||||
ctx, err := createTestCtx(t, blockHeight)
|
||||
require.NoError(t, err, "can't create context")
|
||||
|
||||
const subBatchSize = 10
|
||||
|
||||
@@ -3541,6 +3544,12 @@ func TestSplitAnnouncementsCorrectSubBatches(t *testing.T) {
|
||||
lengthAnnouncementBatchSizes := len(announcementBatchSizes)
|
||||
lengthExpectedNumberMiniBatches := len(expectedNumberMiniBatches)
|
||||
|
||||
batchSizeCalculator = func(totalDelay, subBatchDelay time.Duration,
|
||||
minimumBatchSize, batchSize int) int {
|
||||
|
||||
return subBatchSize
|
||||
}
|
||||
|
||||
if lengthAnnouncementBatchSizes != lengthExpectedNumberMiniBatches {
|
||||
t.Fatal("Length of announcementBatchSizes and " +
|
||||
"expectedNumberMiniBatches should be equal")
|
||||
@@ -3550,15 +3559,16 @@ func TestSplitAnnouncementsCorrectSubBatches(t *testing.T) {
|
||||
var batchSize = announcementBatchSizes[testIndex]
|
||||
announcementBatch := make([]msgWithSenders, batchSize)
|
||||
|
||||
splitAnnouncementBatch := splitAnnouncementBatches(
|
||||
subBatchSize, announcementBatch,
|
||||
splitAnnouncementBatch := ctx.gossiper.splitAnnouncementBatches(
|
||||
announcementBatch,
|
||||
)
|
||||
|
||||
lengthMiniBatches := len(splitAnnouncementBatch)
|
||||
|
||||
if lengthMiniBatches != expectedNumberMiniBatches[testIndex] {
|
||||
t.Fatalf("Expecting %d mini batches, actual %d",
|
||||
expectedNumberMiniBatches[testIndex], lengthMiniBatches)
|
||||
expectedNumberMiniBatches[testIndex],
|
||||
lengthMiniBatches)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user