| 1 |
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly> |
| 2 |
// SPDX-License-Identifier: MIT |
| 3 |
|
| 4 |
package sctp |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/stretchr/testify/assert" |
| 10 |
) |
| 11 |
|
| 12 |
func TestInterleavingSettingsWeightedFairQueueingFactorySnapshotsWeights(t *testing.T) { |
| 13 |
settings := &interleavingSettings{} |
| 14 |
assert.NoError(t, WithInterleavingWeightedFairQueueingWeight(1, 2)(settings)) |
| 15 |
|
| 16 |
settings.wfqWeights[1] = 5 |
| 17 |
|
| 18 |
scheduler, ok := settings.newStreamScheduler().(*weightedFairQueueingPendingQueuePolicy) |
| 19 |
if !assert.True(t, ok) { |
| 20 |
return |
| 21 |
} |
| 22 |
assert.Equal(t, map[uint16]uint16{1: 2}, scheduler.weights) |
| 23 |
} |
| 24 |
|
| 25 |
func TestCloneInterleavingSettingsWeightedFairQueueingFactoryUsesClonedWeights(t *testing.T) { |
| 26 |
settings := &interleavingSettings{} |
| 27 |
assert.NoError(t, WithInterleavingWeightedFairQueueingWeight(1, 2)(settings)) |
| 28 |
|
| 29 |
clone := cloneInterleavingSettings(settings) |
| 30 |
assert.NoError(t, WithInterleavingWeightedFairQueueingWeight(1, 5)(settings)) |
| 31 |
|
| 32 |
scheduler, ok := clone.newStreamScheduler().(*weightedFairQueueingPendingQueuePolicy) |
| 33 |
if !assert.True(t, ok) { |
| 34 |
return |
| 35 |
} |
| 36 |
assert.Equal(t, map[uint16]uint16{1: 2}, clone.wfqWeights) |
| 37 |
assert.Equal(t, map[uint16]uint16{1: 2}, scheduler.weights) |
| 38 |
} |