1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 14:34:24 +08:00

fix: routing mock accuracy

routing interface doesn't wait for value to appear in network, but value
doesn't appear in network until time as passed

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
This commit is contained in:
Brian Tiger Chow
2014-12-15 20:30:18 -08:00
parent 5b56a67dbb
commit 34b11a3b07
6 changed files with 84 additions and 17 deletions

View File

@ -28,13 +28,25 @@ type Client interface {
// NewServer returns a mockrouting Server
func NewServer() Server {
return NewServerWithDelay(delay.Fixed(0))
return NewServerWithDelay(DelayConfig{
ValueVisibility: delay.Fixed(0),
Query: delay.Fixed(0),
})
}
// NewServerWithDelay returns a mockrouting Server with a delay!
func NewServerWithDelay(d delay.D) Server {
func NewServerWithDelay(conf DelayConfig) Server {
return &s{
providers: make(map[u.Key]peer.Map),
delay: d,
providers: make(map[u.Key]map[u.Key]providerRecord),
delayConf: conf,
}
}
type DelayConfig struct {
// ValueVisibility is the time it takes for a value to be visible in the network
// FIXME there _must_ be a better term for this
ValueVisibility delay.D
// Query is the time it takes to receive a response from a routing query
Query delay.D
}