mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
swarm/storage: test with request channel
This commit is contained in:
parent
47cfe074f0
commit
1c3597f26a
2 changed files with 25 additions and 9 deletions
|
|
@ -34,7 +34,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
loglevel = flag.Int("loglevel", 2, "verbosity of logs")
|
loglevel = flag.Int("loglevel", 3, "verbosity of logs")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
||||||
|
|
@ -60,34 +60,43 @@ func TestMemStoreAndLDBStore(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
n int // number of chunks to push to memStore
|
n int // number of chunks to push to memStore
|
||||||
chunkSize uint64 // size of chunk (by default in Swarm - 4096)
|
chunkSize uint64 // size of chunk (by default in Swarm - 4096)
|
||||||
|
request bool // whether or not to set the ReqC channel on the random chunks
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
n: 1,
|
n: 1,
|
||||||
chunkSize: 4096,
|
chunkSize: 4096,
|
||||||
|
request: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
n: 201,
|
n: 201,
|
||||||
chunkSize: 4096,
|
chunkSize: 4096,
|
||||||
|
request: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
n: 9999,
|
n: 60001,
|
||||||
chunkSize: 4096,
|
chunkSize: 4096,
|
||||||
|
request: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
n: 20001,
|
n: 60001,
|
||||||
chunkSize: 4096,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
n: 80001,
|
|
||||||
chunkSize: 4096,
|
chunkSize: 4096,
|
||||||
|
request: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for i, tt := range tests {
|
||||||
|
log.Info("running test", "idx", i, "tt", tt)
|
||||||
var chunks []*Chunk
|
var chunks []*Chunk
|
||||||
|
|
||||||
for i := 0; i < tt.n; i++ {
|
for i := 0; i < tt.n; i++ {
|
||||||
chunks = append(chunks, NewRandomChunk(tt.chunkSize))
|
var c *Chunk
|
||||||
|
if tt.request {
|
||||||
|
c = NewRandomRequestChunk(tt.chunkSize)
|
||||||
|
} else {
|
||||||
|
c = NewRandomChunk(tt.chunkSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
chunks = append(chunks, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < tt.n; i++ {
|
for i := 0; i < tt.n; i++ {
|
||||||
|
|
@ -135,3 +144,10 @@ func NewRandomChunk(chunkSize uint64) *Chunk {
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewRandomRequestChunk(chunkSize uint64) *Chunk {
|
||||||
|
c := NewRandomChunk(chunkSize)
|
||||||
|
c.ReqC = make(chan bool)
|
||||||
|
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue