mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2025-01-27 04:40:07 +08:00
test: use leveldb instead of badger
Badger has issues on 32bit operating systems.
This commit is contained in:
parent
8fdf7888b2
commit
99836f05e7
@ -43,7 +43,7 @@ func TestGCLookahead(t *testing.T) {
|
||||
opts.GCLookaheadInterval = 10 * time.Second
|
||||
opts.GCPurgeInterval = 1 * time.Second
|
||||
|
||||
factory := addressBookFactory(t, badgerStore, opts)
|
||||
factory := addressBookFactory(t, leveldbStore, opts)
|
||||
ab, closeFn := factory()
|
||||
gc := ab.(*dsAddrBook).gc
|
||||
defer closeFn()
|
||||
@ -90,7 +90,7 @@ func TestGCPurging(t *testing.T) {
|
||||
opts.GCLookaheadInterval = 20 * time.Second
|
||||
opts.GCPurgeInterval = 1 * time.Second
|
||||
|
||||
factory := addressBookFactory(t, badgerStore, opts)
|
||||
factory := addressBookFactory(t, leveldbStore, opts)
|
||||
ab, closeFn := factory()
|
||||
gc := ab.(*dsAddrBook).gc
|
||||
defer closeFn()
|
||||
@ -157,7 +157,7 @@ func TestGCDelay(t *testing.T) {
|
||||
opts.GCLookaheadInterval = 1 * time.Minute
|
||||
opts.GCPurgeInterval = 30 * time.Second
|
||||
|
||||
factory := addressBookFactory(t, badgerStore, opts)
|
||||
factory := addressBookFactory(t, leveldbStore, opts)
|
||||
ab, closeFn := factory()
|
||||
defer closeFn()
|
||||
|
||||
@ -188,7 +188,7 @@ func TestGCLookaheadDisabled(t *testing.T) {
|
||||
opts.GCLookaheadInterval = 0 // disable lookahead
|
||||
opts.GCPurgeInterval = 9 * time.Hour
|
||||
|
||||
factory := addressBookFactory(t, badgerStore, opts)
|
||||
factory := addressBookFactory(t, leveldbStore, opts)
|
||||
ab, closeFn := factory()
|
||||
defer closeFn()
|
||||
|
||||
@ -232,7 +232,7 @@ func BenchmarkLookaheadCycle(b *testing.B) {
|
||||
opts.GCLookaheadInterval = 2 * time.Hour
|
||||
opts.GCPurgeInterval = 6 * time.Hour
|
||||
|
||||
factory := addressBookFactory(b, badgerStore, opts)
|
||||
factory := addressBookFactory(b, leveldbStore, opts)
|
||||
ab, closeFn := factory()
|
||||
defer closeFn()
|
||||
|
||||
|
@ -18,8 +18,8 @@ import (
|
||||
type datastoreFactory func(tb testing.TB) (ds.Batching, func())
|
||||
|
||||
var dstores = map[string]datastoreFactory{
|
||||
"Badger": badgerStore,
|
||||
// "Leveldb": leveldbStore,
|
||||
//"Badger": badgerStore,
|
||||
"Leveldb": leveldbStore,
|
||||
}
|
||||
|
||||
func TestDsPeerstore(t *testing.T) {
|
||||
@ -87,6 +87,8 @@ func BenchmarkDsPeerstore(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
// Doesn't work on 32bit because badger.
|
||||
//lint:ignore U1000 disabled for now
|
||||
func badgerStore(tb testing.TB) (ds.Batching, func()) {
|
||||
dataPath, err := ioutil.TempDir(os.TempDir(), "badger")
|
||||
if err != nil {
|
||||
@ -103,8 +105,7 @@ func badgerStore(tb testing.TB) (ds.Batching, func()) {
|
||||
return store, closer
|
||||
}
|
||||
|
||||
//lint:ignore U1000 disabled for now
|
||||
func leveldbStore(tb testing.TB) (ds.TxnDatastore, func()) {
|
||||
func leveldbStore(tb testing.TB) (ds.Batching, func()) {
|
||||
dataPath, err := ioutil.TempDir(os.TempDir(), "leveldb")
|
||||
if err != nil {
|
||||
tb.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user