mirror of
https://github.com/luxfi/p2p.git
synced 2026-10-30 15:22:55 +00:00
29 lines
594 B
Go
29 lines
594 B
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package throttlingmock
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
// Targeter is a mock targeter for testing
|
|
type Targeter struct {
|
|
T *testing.T
|
|
TargetUsageF func(ids.NodeID) float64
|
|
}
|
|
|
|
// NewTargeter creates a new mock targeter
|
|
func NewTargeter(t *testing.T) *Targeter {
|
|
return &Targeter{T: t}
|
|
}
|
|
|
|
func (t *Targeter) TargetUsage(nodeID ids.NodeID) float64 {
|
|
if t.TargetUsageF != nil {
|
|
return t.TargetUsageF(nodeID)
|
|
}
|
|
return 0.5 // Default target usage
|
|
}
|