Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
af01e019
Unverified
Commit
af01e019
authored
May 25, 2020
by
Janoš Guljaš
Committed by
GitHub
May 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use testing.Cleanup in localstore tests (#203)
parent
b8c1e222
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
69 additions
and
116 deletions
+69
-116
export_test.go
pkg/localstore/export_test.go
+2
-4
gc_test.go
pkg/localstore/gc_test.go
+17
-16
index_test.go
pkg/localstore/index_test.go
+2
-4
localstore_test.go
pkg/localstore/localstore_test.go
+9
-13
mode_get_multi_test.go
pkg/localstore/mode_get_multi_test.go
+1
-2
mode_get_test.go
pkg/localstore/mode_get_test.go
+2
-4
mode_has_test.go
pkg/localstore/mode_has_test.go
+2
-4
mode_put_test.go
pkg/localstore/mode_put_test.go
+9
-19
mode_set_test.go
pkg/localstore/mode_set_test.go
+6
-12
pin_test.go
pkg/localstore/pin_test.go
+4
-8
retrieval_index_test.go
pkg/localstore/retrieval_index_test.go
+2
-4
subscription_pull_test.go
pkg/localstore/subscription_pull_test.go
+11
-22
subscription_push_test.go
pkg/localstore/subscription_push_test.go
+2
-4
No files found.
pkg/localstore/export_test.go
View file @
af01e019
...
@@ -29,8 +29,7 @@ import (
...
@@ -29,8 +29,7 @@ import (
// chunks and another one to import and validate that all chunks are
// chunks and another one to import and validate that all chunks are
// imported.
// imported.
func
TestExportImport
(
t
*
testing
.
T
)
{
func
TestExportImport
(
t
*
testing
.
T
)
{
db1
,
cleanup1
:=
newTestDB
(
t
,
nil
)
db1
:=
newTestDB
(
t
,
nil
)
defer
cleanup1
()
var
chunkCount
=
100
var
chunkCount
=
100
...
@@ -56,8 +55,7 @@ func TestExportImport(t *testing.T) {
...
@@ -56,8 +55,7 @@ func TestExportImport(t *testing.T) {
t
.
Errorf
(
"got export count %v, want %v"
,
c
,
wantChunksCount
)
t
.
Errorf
(
"got export count %v, want %v"
,
c
,
wantChunksCount
)
}
}
db2
,
cleanup2
:=
newTestDB
(
t
,
nil
)
db2
:=
newTestDB
(
t
,
nil
)
defer
cleanup2
()
c
,
err
=
db2
.
Import
(
&
buf
,
false
)
c
,
err
=
db2
.
Import
(
&
buf
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/localstore/gc_test.go
View file @
af01e019
...
@@ -57,17 +57,18 @@ func testDBCollectGarbageWorker(t *testing.T) {
...
@@ -57,17 +57,18 @@ func testDBCollectGarbageWorker(t *testing.T) {
chunkCount
:=
150
chunkCount
:=
150
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
var
closed
chan
struct
{}
Capacity
:
100
,
})
testHookCollectGarbageChan
:=
make
(
chan
uint64
)
testHookCollectGarbageChan
:=
make
(
chan
uint64
)
defer
setTestHookCollectGarbage
(
func
(
collectedCount
uint64
)
{
t
.
Cleanup
(
setTestHookCollectGarbage
(
func
(
collectedCount
uint64
)
{
select
{
select
{
case
testHookCollectGarbageChan
<-
collectedCount
:
case
testHookCollectGarbageChan
<-
collectedCount
:
case
<-
db
.
close
:
case
<-
closed
:
}
}
})()
}))
defer
cleanupFunc
()
db
:=
newTestDB
(
t
,
&
Options
{
Capacity
:
100
,
})
closed
=
db
.
close
addrs
:=
make
([]
swarm
.
Address
,
0
)
addrs
:=
make
([]
swarm
.
Address
,
0
)
...
@@ -146,17 +147,19 @@ func TestPinGC(t *testing.T) {
...
@@ -146,17 +147,19 @@ func TestPinGC(t *testing.T) {
pinChunksCount
:=
50
pinChunksCount
:=
50
dbCapacity
:=
uint64
(
100
)
dbCapacity
:=
uint64
(
100
)
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
var
closed
chan
struct
{}
Capacity
:
dbCapacity
,
})
testHookCollectGarbageChan
:=
make
(
chan
uint64
)
testHookCollectGarbageChan
:=
make
(
chan
uint64
)
defer
setTestHookCollectGarbage
(
func
(
collectedCount
uint64
)
{
defer
setTestHookCollectGarbage
(
func
(
collectedCount
uint64
)
{
select
{
select
{
case
testHookCollectGarbageChan
<-
collectedCount
:
case
testHookCollectGarbageChan
<-
collectedCount
:
case
<-
db
.
close
:
case
<-
closed
:
}
}
})()
})()
defer
cleanupFunc
()
db
:=
newTestDB
(
t
,
&
Options
{
Capacity
:
dbCapacity
,
})
closed
=
db
.
close
addrs
:=
make
([]
swarm
.
Address
,
0
)
addrs
:=
make
([]
swarm
.
Address
,
0
)
pinAddrs
:=
make
([]
swarm
.
Address
,
0
)
pinAddrs
:=
make
([]
swarm
.
Address
,
0
)
...
@@ -252,10 +255,9 @@ func TestGCAfterPin(t *testing.T) {
...
@@ -252,10 +255,9 @@ func TestGCAfterPin(t *testing.T) {
chunkCount
:=
50
chunkCount
:=
50
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
db
:=
newTestDB
(
t
,
&
Options
{
Capacity
:
100
,
Capacity
:
100
,
})
})
defer
cleanupFunc
()
pinAddrs
:=
make
([]
swarm
.
Address
,
0
)
pinAddrs
:=
make
([]
swarm
.
Address
,
0
)
...
@@ -299,10 +301,9 @@ func TestGCAfterPin(t *testing.T) {
...
@@ -299,10 +301,9 @@ func TestGCAfterPin(t *testing.T) {
// to test garbage collection runs by uploading, syncing and
// to test garbage collection runs by uploading, syncing and
// requesting a number of chunks.
// requesting a number of chunks.
func
TestDB_collectGarbageWorker_withRequests
(
t
*
testing
.
T
)
{
func
TestDB_collectGarbageWorker_withRequests
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
db
:=
newTestDB
(
t
,
&
Options
{
Capacity
:
100
,
Capacity
:
100
,
})
})
defer
cleanupFunc
()
testHookCollectGarbageChan
:=
make
(
chan
uint64
)
testHookCollectGarbageChan
:=
make
(
chan
uint64
)
defer
setTestHookCollectGarbage
(
func
(
collectedCount
uint64
)
{
defer
setTestHookCollectGarbage
(
func
(
collectedCount
uint64
)
{
...
...
pkg/localstore/index_test.go
View file @
af01e019
...
@@ -34,8 +34,7 @@ import (
...
@@ -34,8 +34,7 @@ import (
// validates that pull index iterator will iterate it the same
// validates that pull index iterator will iterate it the same
// order.
// order.
func
TestDB_pullIndex
(
t
*
testing
.
T
)
{
func
TestDB_pullIndex
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunkCount
:=
50
chunkCount
:=
50
...
@@ -79,8 +78,7 @@ func TestDB_pullIndex(t *testing.T) {
...
@@ -79,8 +78,7 @@ func TestDB_pullIndex(t *testing.T) {
// a chunk with and performing operations using synced, access and
// a chunk with and performing operations using synced, access and
// request modes.
// request modes.
func
TestDB_gcIndex
(
t
*
testing
.
T
)
{
func
TestDB_gcIndex
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunkCount
:=
50
chunkCount
:=
50
...
...
pkg/localstore/localstore_test.go
View file @
af01e019
...
@@ -60,8 +60,7 @@ func init() {
...
@@ -60,8 +60,7 @@ func init() {
// TestDB validates if the chunk can be uploaded and
// TestDB validates if the chunk can be uploaded and
// correctly retrieved.
// correctly retrieved.
func
TestDB
(
t
*
testing
.
T
)
{
func
TestDB
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
ch
:=
generateTestRandomChunk
()
ch
:=
generateTestRandomChunk
()
...
@@ -93,7 +92,7 @@ func TestDB_updateGCSem(t *testing.T) {
...
@@ -93,7 +92,7 @@ func TestDB_updateGCSem(t *testing.T) {
var
count
int
var
count
int
var
max
int
var
max
int
var
mu
sync
.
Mutex
var
mu
sync
.
Mutex
defer
setTestHookUpdateGC
(
func
()
{
t
.
Cleanup
(
setTestHookUpdateGC
(
func
()
{
mu
.
Lock
()
mu
.
Lock
()
// add to the count of current goroutines
// add to the count of current goroutines
count
++
count
++
...
@@ -109,13 +108,12 @@ func TestDB_updateGCSem(t *testing.T) {
...
@@ -109,13 +108,12 @@ func TestDB_updateGCSem(t *testing.T) {
mu
.
Lock
()
mu
.
Lock
()
count
--
count
--
mu
.
Unlock
()
mu
.
Unlock
()
})
(
)
}))
defer
func
(
m
int
)
{
maxParallelUpdateGC
=
m
}(
maxParallelUpdateGC
)
defer
func
(
m
int
)
{
maxParallelUpdateGC
=
m
}(
maxParallelUpdateGC
)
maxParallelUpdateGC
=
3
maxParallelUpdateGC
=
3
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
ch
:=
generateTestRandomChunk
()
ch
:=
generateTestRandomChunk
()
...
@@ -141,7 +139,7 @@ func TestDB_updateGCSem(t *testing.T) {
...
@@ -141,7 +139,7 @@ func TestDB_updateGCSem(t *testing.T) {
// newTestDB is a helper function that constructs a
// newTestDB is a helper function that constructs a
// temporary database and returns a cleanup function that must
// temporary database and returns a cleanup function that must
// be called to remove the data.
// be called to remove the data.
func
newTestDB
(
t
testing
.
TB
,
o
*
Options
)
(
db
*
DB
,
cleanupFunc
func
())
{
func
newTestDB
(
t
testing
.
TB
,
o
*
Options
)
*
DB
{
t
.
Helper
()
t
.
Helper
()
baseKey
:=
make
([]
byte
,
32
)
baseKey
:=
make
([]
byte
,
32
)
...
@@ -151,16 +149,15 @@ func newTestDB(t testing.TB, o *Options) (db *DB, cleanupFunc func()) {
...
@@ -151,16 +149,15 @@ func newTestDB(t testing.TB, o *Options) (db *DB, cleanupFunc func()) {
logger
:=
logging
.
New
(
ioutil
.
Discard
,
0
)
logger
:=
logging
.
New
(
ioutil
.
Discard
,
0
)
db
,
err
:=
New
(
""
,
baseKey
,
o
,
logger
)
db
,
err
:=
New
(
""
,
baseKey
,
o
,
logger
)
if
err
!=
nil
{
if
err
!=
nil
{
cleanupFunc
()
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
cleanupFunc
=
func
()
{
t
.
Cleanup
(
func
()
{
err
:=
db
.
Close
()
err
:=
db
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
}
}
}
}
)
return
db
,
cleanupFunc
return
db
}
}
var
(
var
(
...
@@ -523,8 +520,7 @@ func testIndexCounts(t *testing.T, pushIndex, pullIndex, gcIndex, gcExcludeIndex
...
@@ -523,8 +520,7 @@ func testIndexCounts(t *testing.T, pushIndex, pullIndex, gcIndex, gcExcludeIndex
// TestDBDebugIndexes tests that the index counts are correct for the
// TestDBDebugIndexes tests that the index counts are correct for the
// index debug function
// index debug function
func
TestDBDebugIndexes
(
t
*
testing
.
T
)
{
func
TestDBDebugIndexes
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
uploadTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
uploadTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
defer
setNow
(
func
()
(
t
int64
)
{
defer
setNow
(
func
()
(
t
int64
)
{
...
...
pkg/localstore/mode_get_multi_test.go
View file @
af01e019
...
@@ -37,8 +37,7 @@ func TestModeGetMulti(t *testing.T) {
...
@@ -37,8 +37,7 @@ func TestModeGetMulti(t *testing.T) {
storage
.
ModeGetPin
,
storage
.
ModeGetPin
,
}
{
}
{
t
.
Run
(
mode
.
String
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
mode
.
String
(),
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunks
:=
generateTestRandomChunks
(
chunkCount
)
chunks
:=
generateTestRandomChunks
(
chunkCount
)
...
...
pkg/localstore/mode_get_test.go
View file @
af01e019
...
@@ -27,8 +27,7 @@ import (
...
@@ -27,8 +27,7 @@ import (
// TestModeGetRequest validates ModeGetRequest index values on the provided DB.
// TestModeGetRequest validates ModeGetRequest index values on the provided DB.
func
TestModeGetRequest
(
t
*
testing
.
T
)
{
func
TestModeGetRequest
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
uploadTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
uploadTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
defer
setNow
(
func
()
(
t
int64
)
{
defer
setNow
(
func
()
(
t
int64
)
{
...
@@ -164,8 +163,7 @@ func TestModeGetRequest(t *testing.T) {
...
@@ -164,8 +163,7 @@ func TestModeGetRequest(t *testing.T) {
// TestModeGetSync validates ModeGetSync index values on the provided DB.
// TestModeGetSync validates ModeGetSync index values on the provided DB.
func
TestModeGetSync
(
t
*
testing
.
T
)
{
func
TestModeGetSync
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
uploadTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
uploadTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
defer
setNow
(
func
()
(
t
int64
)
{
defer
setNow
(
func
()
(
t
int64
)
{
...
...
pkg/localstore/mode_has_test.go
View file @
af01e019
...
@@ -29,8 +29,7 @@ import (
...
@@ -29,8 +29,7 @@ import (
// TestHas validates that Has method is returning true for
// TestHas validates that Has method is returning true for
// the stored chunk and false for one that is not stored.
// the stored chunk and false for one that is not stored.
func
TestHas
(
t
*
testing
.
T
)
{
func
TestHas
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
ch
:=
generateTestRandomChunk
()
ch
:=
generateTestRandomChunk
()
...
@@ -64,8 +63,7 @@ func TestHasMulti(t *testing.T) {
...
@@ -64,8 +63,7 @@ func TestHasMulti(t *testing.T) {
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
for
_
,
tc
:=
range
multiChunkTestCases
{
for
_
,
tc
:=
range
multiChunkTestCases
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
want
:=
make
([]
bool
,
tc
.
count
)
want
:=
make
([]
bool
,
tc
.
count
)
...
...
pkg/localstore/mode_put_test.go
View file @
af01e019
...
@@ -33,8 +33,7 @@ import (
...
@@ -33,8 +33,7 @@ import (
func
TestModePutRequest
(
t
*
testing
.
T
)
{
func
TestModePutRequest
(
t
*
testing
.
T
)
{
for
_
,
tc
:=
range
multiChunkTestCases
{
for
_
,
tc
:=
range
multiChunkTestCases
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
...
@@ -88,8 +87,7 @@ func TestModePutRequest(t *testing.T) {
...
@@ -88,8 +87,7 @@ func TestModePutRequest(t *testing.T) {
func
TestModePutSync
(
t
*
testing
.
T
)
{
func
TestModePutSync
(
t
*
testing
.
T
)
{
for
_
,
tc
:=
range
multiChunkTestCases
{
for
_
,
tc
:=
range
multiChunkTestCases
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
wantTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
wantTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
defer
setNow
(
func
()
(
t
int64
)
{
defer
setNow
(
func
()
(
t
int64
)
{
...
@@ -120,8 +118,7 @@ func TestModePutSync(t *testing.T) {
...
@@ -120,8 +118,7 @@ func TestModePutSync(t *testing.T) {
func
TestModePutUpload
(
t
*
testing
.
T
)
{
func
TestModePutUpload
(
t
*
testing
.
T
)
{
for
_
,
tc
:=
range
multiChunkTestCases
{
for
_
,
tc
:=
range
multiChunkTestCases
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
wantTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
wantTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
defer
setNow
(
func
()
(
t
int64
)
{
defer
setNow
(
func
()
(
t
int64
)
{
...
@@ -170,8 +167,7 @@ func TestModePutUpload_parallel(t *testing.T) {
...
@@ -170,8 +167,7 @@ func TestModePutUpload_parallel(t *testing.T) {
},
},
}
{
}
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
uploadsCount
:=
100
uploadsCount
:=
100
workerCount
:=
100
workerCount
:=
100
...
@@ -280,7 +276,7 @@ func TestModePut_sameChunk(t *testing.T) {
...
@@ -280,7 +276,7 @@ func TestModePut_sameChunk(t *testing.T) {
},
},
}
{
}
{
t
.
Run
(
tcn
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tcn
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
for
i
:=
0
;
i
<
10
;
i
++
{
for
i
:=
0
;
i
<
10
;
i
++
{
exist
,
err
:=
db
.
Put
(
context
.
Background
(),
tcn
.
mode
,
chunks
...
)
exist
,
err
:=
db
.
Put
(
context
.
Background
(),
tcn
.
mode
,
chunks
...
)
...
@@ -311,8 +307,6 @@ func TestModePut_sameChunk(t *testing.T) {
...
@@ -311,8 +307,6 @@ func TestModePut_sameChunk(t *testing.T) {
newItemsCountTest
(
db
.
pullIndex
,
count
(
tcn
.
pullIndex
))(
t
)
newItemsCountTest
(
db
.
pullIndex
,
count
(
tcn
.
pullIndex
))(
t
)
newItemsCountTest
(
db
.
pushIndex
,
count
(
tcn
.
pushIndex
))(
t
)
newItemsCountTest
(
db
.
pushIndex
,
count
(
tcn
.
pushIndex
))(
t
)
}
}
cleanupFunc
()
})
})
}
}
})
})
...
@@ -340,8 +334,7 @@ func TestModePut_addToGc(t *testing.T) {
...
@@ -340,8 +334,7 @@ func TestModePut_addToGc(t *testing.T) {
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
retVal
=
m
.
putToGc
retVal
=
m
.
putToGc
db
,
cleanupFunc
:=
newTestDB
(
t
,
opts
)
db
:=
newTestDB
(
t
,
opts
)
defer
cleanupFunc
()
wantTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
wantTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
defer
setNow
(
func
()
(
t
int64
)
{
defer
setNow
(
func
()
(
t
int64
)
{
...
@@ -393,8 +386,7 @@ func TestModePut_addToGcExisting(t *testing.T) {
...
@@ -393,8 +386,7 @@ func TestModePut_addToGcExisting(t *testing.T) {
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
retVal
=
m
.
putToGc
retVal
=
m
.
putToGc
db
,
cleanupFunc
:=
newTestDB
(
t
,
opts
)
db
:=
newTestDB
(
t
,
opts
)
defer
cleanupFunc
()
wantStoreTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
wantStoreTimestamp
:=
time
.
Now
()
.
UTC
()
.
UnixNano
()
defer
setNow
(
func
()
(
t
int64
)
{
defer
setNow
(
func
()
(
t
int64
)
{
...
@@ -448,8 +440,7 @@ func TestPutDuplicateChunks(t *testing.T) {
...
@@ -448,8 +440,7 @@ func TestPutDuplicateChunks(t *testing.T) {
storage
.
ModePutSync
,
storage
.
ModePutSync
,
}
{
}
{
t
.
Run
(
mode
.
String
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
mode
.
String
(),
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
ch
:=
generateTestRandomChunk
()
ch
:=
generateTestRandomChunk
()
...
@@ -541,8 +532,7 @@ func BenchmarkPutUpload(b *testing.B) {
...
@@ -541,8 +532,7 @@ func BenchmarkPutUpload(b *testing.B) {
// of chunks with specified max parallel uploads.
// of chunks with specified max parallel uploads.
func
benchmarkPutUpload
(
b
*
testing
.
B
,
o
*
Options
,
count
,
maxParallelUploads
int
)
{
func
benchmarkPutUpload
(
b
*
testing
.
B
,
o
*
Options
,
count
,
maxParallelUploads
int
)
{
b
.
StopTimer
()
b
.
StopTimer
()
db
,
cleanupFunc
:=
newTestDB
(
b
,
o
)
db
:=
newTestDB
(
b
,
o
)
defer
cleanupFunc
()
chunks
:=
make
([]
swarm
.
Chunk
,
count
)
chunks
:=
make
([]
swarm
.
Chunk
,
count
)
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
...
...
pkg/localstore/mode_set_test.go
View file @
af01e019
...
@@ -33,8 +33,7 @@ import (
...
@@ -33,8 +33,7 @@ import (
func
TestModeSetAccess
(
t
*
testing
.
T
)
{
func
TestModeSetAccess
(
t
*
testing
.
T
)
{
for
_
,
tc
:=
range
multiChunkTestCases
{
for
_
,
tc
:=
range
multiChunkTestCases
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
...
@@ -71,8 +70,7 @@ func TestModeSetAccess(t *testing.T) {
...
@@ -71,8 +70,7 @@ func TestModeSetAccess(t *testing.T) {
// as a result we should expect the tag value to remain in the pull index
// as a result we should expect the tag value to remain in the pull index
// and we expect that the tag should not be incremented by pull sync set
// and we expect that the tag should not be incremented by pull sync set
func
TestModeSetSyncPullNormalTag
(
t
*
testing
.
T
)
{
func
TestModeSetSyncPullNormalTag
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
db
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
defer
cleanupFunc
()
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
false
)
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -125,8 +123,7 @@ func TestModeSetSyncPullNormalTag(t *testing.T) {
...
@@ -125,8 +123,7 @@ func TestModeSetSyncPullNormalTag(t *testing.T) {
// TestModeSetSyncPullAnonymousTag checks that pull sync correcly increments
// TestModeSetSyncPullAnonymousTag checks that pull sync correcly increments
// counters on an anonymous tag which is expected to be handled only by pull sync
// counters on an anonymous tag which is expected to be handled only by pull sync
func
TestModeSetSyncPullAnonymousTag
(
t
*
testing
.
T
)
{
func
TestModeSetSyncPullAnonymousTag
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
db
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
defer
cleanupFunc
()
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
true
)
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -177,8 +174,7 @@ func TestModeSetSyncPullAnonymousTag(t *testing.T) {
...
@@ -177,8 +174,7 @@ func TestModeSetSyncPullAnonymousTag(t *testing.T) {
// then tries to Set both with push and pull Sync modes, but asserts that only the pull sync
// then tries to Set both with push and pull Sync modes, but asserts that only the pull sync
// increments were done to the tag
// increments were done to the tag
func
TestModeSetSyncPullPushAnonymousTag
(
t
*
testing
.
T
)
{
func
TestModeSetSyncPullPushAnonymousTag
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
db
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
defer
cleanupFunc
()
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
true
)
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -246,8 +242,7 @@ func TestModeSetSyncPullPushAnonymousTag(t *testing.T) {
...
@@ -246,8 +242,7 @@ func TestModeSetSyncPullPushAnonymousTag(t *testing.T) {
// correctly on a normal tag (that is, a tag that is expected to show progress bars
// correctly on a normal tag (that is, a tag that is expected to show progress bars
// according to push sync progress)
// according to push sync progress)
func
TestModeSetSyncPushNormalTag
(
t
*
testing
.
T
)
{
func
TestModeSetSyncPushNormalTag
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
db
:=
newTestDB
(
t
,
&
Options
{
Tags
:
tags
.
NewTags
()})
defer
cleanupFunc
()
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
false
)
tag
,
err
:=
db
.
tags
.
Create
(
"test"
,
1
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -318,8 +313,7 @@ func TestModeSetSyncPushNormalTag(t *testing.T) {
...
@@ -318,8 +313,7 @@ func TestModeSetSyncPushNormalTag(t *testing.T) {
func
TestModeSetRemove
(
t
*
testing
.
T
)
{
func
TestModeSetRemove
(
t
*
testing
.
T
)
{
for
_
,
tc
:=
range
multiChunkTestCases
{
for
_
,
tc
:=
range
multiChunkTestCases
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
chunks
:=
generateTestRandomChunks
(
tc
.
count
)
...
...
pkg/localstore/pin_test.go
View file @
af01e019
...
@@ -25,8 +25,7 @@ func TestPinning(t *testing.T) {
...
@@ -25,8 +25,7 @@ func TestPinning(t *testing.T) {
sort
.
Strings
(
addresses
)
sort
.
Strings
(
addresses
)
t
.
Run
(
"empty-db"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"empty-db"
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
// Nothing should be there in the pinned DB
// Nothing should be there in the pinned DB
_
,
err
:=
db
.
PinnedChunks
(
context
.
Background
(),
swarm
.
NewAddress
([]
byte
{
0
}))
_
,
err
:=
db
.
PinnedChunks
(
context
.
Background
(),
swarm
.
NewAddress
([]
byte
{
0
}))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -37,8 +36,7 @@ func TestPinning(t *testing.T) {
...
@@ -37,8 +36,7 @@ func TestPinning(t *testing.T) {
})
})
t
.
Run
(
"get-pinned-chunks"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"get-pinned-chunks"
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
err
:=
db
.
Set
(
context
.
Background
(),
storage
.
ModeSetPin
,
chunkAddresses
(
chunks
)
...
)
err
:=
db
.
Set
(
context
.
Background
(),
storage
.
ModeSetPin
,
chunkAddresses
(
chunks
)
...
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -66,8 +64,7 @@ func TestPinning(t *testing.T) {
...
@@ -66,8 +64,7 @@ func TestPinning(t *testing.T) {
func
TestPinInfo
(
t
*
testing
.
T
)
{
func
TestPinInfo
(
t
*
testing
.
T
)
{
chunk
:=
generateTestRandomChunk
()
chunk
:=
generateTestRandomChunk
()
t
.
Run
(
"get-pinned-chunks"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"get-pinned-chunks"
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
// pin once
// pin once
err
:=
db
.
Set
(
context
.
Background
(),
storage
.
ModeSetPin
,
swarm
.
NewAddress
(
chunk
.
Address
()
.
Bytes
()))
err
:=
db
.
Set
(
context
.
Background
(),
storage
.
ModeSetPin
,
swarm
.
NewAddress
(
chunk
.
Address
()
.
Bytes
()))
...
@@ -97,8 +94,7 @@ func TestPinInfo(t *testing.T) {
...
@@ -97,8 +94,7 @@ func TestPinInfo(t *testing.T) {
})
})
t
.
Run
(
"get-unpinned-chunks"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"get-unpinned-chunks"
,
func
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
// pin once
// pin once
err
:=
db
.
Set
(
context
.
Background
(),
storage
.
ModeSetPin
,
swarm
.
NewAddress
(
chunk
.
Address
()
.
Bytes
()))
err
:=
db
.
Set
(
context
.
Background
(),
storage
.
ModeSetPin
,
swarm
.
NewAddress
(
chunk
.
Address
()
.
Bytes
()))
...
...
pkg/localstore/retrieval_index_test.go
View file @
af01e019
...
@@ -61,8 +61,7 @@ func BenchmarkRetrievalIndexes(b *testing.B) {
...
@@ -61,8 +61,7 @@ func BenchmarkRetrievalIndexes(b *testing.B) {
// database options.
// database options.
func
benchmarkRetrievalIndexes
(
b
*
testing
.
B
,
o
*
Options
,
count
int
)
{
func
benchmarkRetrievalIndexes
(
b
*
testing
.
B
,
o
*
Options
,
count
int
)
{
b
.
StopTimer
()
b
.
StopTimer
()
db
,
cleanupFunc
:=
newTestDB
(
b
,
o
)
db
:=
newTestDB
(
b
,
o
)
defer
cleanupFunc
()
addrs
:=
make
([]
swarm
.
Address
,
count
)
addrs
:=
make
([]
swarm
.
Address
,
count
)
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
ch
:=
generateTestRandomChunk
()
ch
:=
generateTestRandomChunk
()
...
@@ -130,8 +129,7 @@ func BenchmarkUpload(b *testing.B) {
...
@@ -130,8 +129,7 @@ func BenchmarkUpload(b *testing.B) {
// database options.
// database options.
func
benchmarkUpload
(
b
*
testing
.
B
,
o
*
Options
,
count
int
)
{
func
benchmarkUpload
(
b
*
testing
.
B
,
o
*
Options
,
count
int
)
{
b
.
StopTimer
()
b
.
StopTimer
()
db
,
cleanupFunc
:=
newTestDB
(
b
,
o
)
db
:=
newTestDB
(
b
,
o
)
defer
cleanupFunc
()
chunks
:=
make
([]
swarm
.
Chunk
,
count
)
chunks
:=
make
([]
swarm
.
Chunk
,
count
)
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
chunk
:=
generateTestRandomChunk
()
chunk
:=
generateTestRandomChunk
()
...
...
pkg/localstore/subscription_pull_test.go
View file @
af01e019
...
@@ -34,8 +34,7 @@ import (
...
@@ -34,8 +34,7 @@ import (
// which means that the `SubscribePull` method should return chunk with BinID=49 via the channel, and the chunk for BinID=49 is uploaded,
// which means that the `SubscribePull` method should return chunk with BinID=49 via the channel, and the chunk for BinID=49 is uploaded,
// after the subscription, then it would have been skipped, where the correct behaviour is to not skip it and return it via the channel.
// after the subscription, then it would have been skipped, where the correct behaviour is to not skip it and return it via the channel.
func
TestDB_SubscribePull_first
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePull_first
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
var
addrsMu
sync
.
Mutex
var
addrsMu
sync
.
Mutex
...
@@ -82,8 +81,7 @@ func TestDB_SubscribePull_first(t *testing.T) {
...
@@ -82,8 +81,7 @@ func TestDB_SubscribePull_first(t *testing.T) {
// all addresses are received in the right order
// all addresses are received in the right order
// for expected proximity order bins.
// for expected proximity order bins.
func
TestDB_SubscribePull
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePull
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
var
addrsMu
sync
.
Mutex
var
addrsMu
sync
.
Mutex
...
@@ -127,8 +125,7 @@ func TestDB_SubscribePull(t *testing.T) {
...
@@ -127,8 +125,7 @@ func TestDB_SubscribePull(t *testing.T) {
// validates if all addresses are received in the right order
// validates if all addresses are received in the right order
// for expected proximity order bins.
// for expected proximity order bins.
func
TestDB_SubscribePull_multiple
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePull_multiple
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
var
addrsMu
sync
.
Mutex
var
addrsMu
sync
.
Mutex
...
@@ -178,8 +175,7 @@ func TestDB_SubscribePull_multiple(t *testing.T) {
...
@@ -178,8 +175,7 @@ func TestDB_SubscribePull_multiple(t *testing.T) {
// and validates if all expected addresses are received in the
// and validates if all expected addresses are received in the
// right order for expected proximity order bins.
// right order for expected proximity order bins.
func
TestDB_SubscribePull_since
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePull_since
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
var
addrsMu
sync
.
Mutex
var
addrsMu
sync
.
Mutex
...
@@ -257,8 +253,7 @@ func TestDB_SubscribePull_since(t *testing.T) {
...
@@ -257,8 +253,7 @@ func TestDB_SubscribePull_since(t *testing.T) {
// and validates if all expected addresses are received in the
// and validates if all expected addresses are received in the
// right order for expected proximity order bins.
// right order for expected proximity order bins.
func
TestDB_SubscribePull_until
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePull_until
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
var
addrsMu
sync
.
Mutex
var
addrsMu
sync
.
Mutex
...
@@ -336,8 +331,7 @@ func TestDB_SubscribePull_until(t *testing.T) {
...
@@ -336,8 +331,7 @@ func TestDB_SubscribePull_until(t *testing.T) {
// and until arguments, and validates if all expected addresses
// and until arguments, and validates if all expected addresses
// are received in the right order for expected proximity order bins.
// are received in the right order for expected proximity order bins.
func
TestDB_SubscribePull_sinceAndUntil
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePull_sinceAndUntil
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
var
addrsMu
sync
.
Mutex
var
addrsMu
sync
.
Mutex
...
@@ -430,8 +424,7 @@ func TestDB_SubscribePull_sinceAndUntil(t *testing.T) {
...
@@ -430,8 +424,7 @@ func TestDB_SubscribePull_sinceAndUntil(t *testing.T) {
// but before the chunks that are left
// but before the chunks that are left
// - validates that no chunks are received on subscription channel
// - validates that no chunks are received on subscription channel
func
TestDB_SubscribePull_rangeOnRemovedChunks
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePull_rangeOnRemovedChunks
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
// keeps track of available chunks in the database
// keeps track of available chunks in the database
// per bin with their bin ids
// per bin with their bin ids
...
@@ -575,13 +568,11 @@ func readPullSubscriptionBin(ctx context.Context, db *DB, bin uint8, ch <-chan s
...
@@ -575,13 +568,11 @@ func readPullSubscriptionBin(ctx context.Context, db *DB, bin uint8, ch <-chan s
})
})
if
err
!=
nil
{
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"got chunk (bin id %v in bin %v) from retrieval index %s: %v"
,
i
,
bin
,
addrs
[
bin
][
i
],
err
)
err
=
fmt
.
Errorf
(
"got chunk (bin id %v in bin %v) from retrieval index %s: %v"
,
i
,
bin
,
addrs
[
bin
][
i
],
err
)
}
else
{
}
else
if
got
.
BinID
!=
want
.
BinID
{
if
got
.
BinID
!=
want
.
BinID
{
err
=
fmt
.
Errorf
(
"got chunk bin id %v in bin %v %v, want %v"
,
i
,
bin
,
got
,
want
)
err
=
fmt
.
Errorf
(
"got chunk bin id %v in bin %v %v, want %v"
,
i
,
bin
,
got
,
want
)
}
}
}
}
}
}
}
addrsMu
.
Unlock
()
addrsMu
.
Unlock
()
i
++
i
++
// send one and only one error per received address
// send one and only one error per received address
...
@@ -617,8 +608,7 @@ func checkErrChan(ctx context.Context, t *testing.T, errChan chan error, wantedC
...
@@ -617,8 +608,7 @@ func checkErrChan(ctx context.Context, t *testing.T, errChan chan error, wantedC
// is returning the last chunk descriptor for proximity order bins by
// is returning the last chunk descriptor for proximity order bins by
// doing a few rounds of chunk uploads.
// doing a few rounds of chunk uploads.
func
TestDB_LastPullSubscriptionBinID
(
t
*
testing
.
T
)
{
func
TestDB_LastPullSubscriptionBinID
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
addrs
:=
make
(
map
[
uint8
][]
swarm
.
Address
)
...
@@ -673,8 +663,7 @@ func TestDB_LastPullSubscriptionBinID(t *testing.T) {
...
@@ -673,8 +663,7 @@ func TestDB_LastPullSubscriptionBinID(t *testing.T) {
// TestAddressInBin validates that function addressInBin
// TestAddressInBin validates that function addressInBin
// returns a valid address for every proximity order bin.
// returns a valid address for every proximity order bin.
func
TestAddressInBin
(
t
*
testing
.
T
)
{
func
TestAddressInBin
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
for
po
:=
uint8
(
0
);
po
<
swarm
.
MaxPO
;
po
++
{
for
po
:=
uint8
(
0
);
po
<
swarm
.
MaxPO
;
po
++
{
addr
:=
db
.
addressInBin
(
po
)
addr
:=
db
.
addressInBin
(
po
)
...
...
pkg/localstore/subscription_push_test.go
View file @
af01e019
...
@@ -32,8 +32,7 @@ import (
...
@@ -32,8 +32,7 @@ import (
// push syncing subscription is created and validates if
// push syncing subscription is created and validates if
// all addresses are received in the right order.
// all addresses are received in the right order.
func
TestDB_SubscribePush
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePush
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
chunks
:=
make
([]
swarm
.
Chunk
,
0
)
chunks
:=
make
([]
swarm
.
Chunk
,
0
)
var
chunksMu
sync
.
Mutex
var
chunksMu
sync
.
Mutex
...
@@ -118,8 +117,7 @@ func TestDB_SubscribePush(t *testing.T) {
...
@@ -118,8 +117,7 @@ func TestDB_SubscribePush(t *testing.T) {
// multiple push syncing subscriptions are created and
// multiple push syncing subscriptions are created and
// validates if all addresses are received in the right order.
// validates if all addresses are received in the right order.
func
TestDB_SubscribePush_multiple
(
t
*
testing
.
T
)
{
func
TestDB_SubscribePush_multiple
(
t
*
testing
.
T
)
{
db
,
cleanupFunc
:=
newTestDB
(
t
,
nil
)
db
:=
newTestDB
(
t
,
nil
)
defer
cleanupFunc
()
addrs
:=
make
([]
swarm
.
Address
,
0
)
addrs
:=
make
([]
swarm
.
Address
,
0
)
var
addrsMu
sync
.
Mutex
var
addrsMu
sync
.
Mutex
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment