mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-25 06:42:13 +00:00
fix(options): make the disable providers/values options consistent
This commit is contained in:
parent
ba86f51884
commit
2a39785d3f
14
dht_test.go
14
dht_test.go
@ -1430,8 +1430,18 @@ func TestProvideDisabled(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
dhtA := setupDHT(ctx, t, false, opts.EnableProviders(enabledA))
|
||||
dhtB := setupDHT(ctx, t, false, opts.EnableProviders(enabledB))
|
||||
var (
|
||||
optsA, optsB []opts.Option
|
||||
)
|
||||
if !enabledA {
|
||||
optsA = append(optsA, opts.DisableProviders())
|
||||
}
|
||||
if !enabledB {
|
||||
optsB = append(optsB, opts.DisableProviders())
|
||||
}
|
||||
|
||||
dhtA := setupDHT(ctx, t, false, optsA...)
|
||||
dhtB := setupDHT(ctx, t, false, optsB...)
|
||||
|
||||
defer dhtA.Close()
|
||||
defer dhtB.Close()
|
||||
|
@ -182,28 +182,28 @@ func DisableAutoRefresh() Option {
|
||||
}
|
||||
}
|
||||
|
||||
// EnableProviders enables storing and retrieving provider records.
|
||||
// DisableProviders disables storing and retrieving provider records.
|
||||
//
|
||||
// Defaults to true.
|
||||
// Defaults to enabled.
|
||||
//
|
||||
// WARNING: do not change this unless you're using a forked DHT (i.e., a private
|
||||
// network and/or distinct DHT protocols with the `Protocols` option).
|
||||
func EnableProviders(enable bool) Option {
|
||||
func DisableProviders() Option {
|
||||
return func(o *Options) error {
|
||||
o.EnableProviders = enable
|
||||
o.EnableProviders = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// EnableValues enables storing and retrieving value records.
|
||||
// DisableProviders disables storing and retrieving value records.
|
||||
//
|
||||
// Defaults to true.
|
||||
// Defaults to enabled.
|
||||
//
|
||||
// WARNING: do not change this unless you're using a forked DHT (i.e., a private
|
||||
// network and/or distinct DHT protocols with the `Protocols` option).
|
||||
func EnableValues(enable bool) Option {
|
||||
func DisableValues() Option {
|
||||
return func(o *Options) error {
|
||||
o.EnableValues = enable
|
||||
o.EnableValues = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -317,8 +317,18 @@ func TestValuesDisabled(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
dhtA := setupDHT(ctx, t, false, dhtopt.EnableValues(enabledA))
|
||||
dhtB := setupDHT(ctx, t, false, dhtopt.EnableValues(enabledB))
|
||||
var (
|
||||
optsA, optsB []dhtopt.Option
|
||||
)
|
||||
if !enabledA {
|
||||
optsA = append(optsA, dhtopt.DisableValues())
|
||||
}
|
||||
if !enabledB {
|
||||
optsB = append(optsB, dhtopt.DisableValues())
|
||||
}
|
||||
|
||||
dhtA := setupDHT(ctx, t, false, optsA...)
|
||||
dhtB := setupDHT(ctx, t, false, optsB...)
|
||||
|
||||
defer dhtA.Close()
|
||||
defer dhtB.Close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user