swarm/network, swarm/storage: validate chunk size (#17397)
* swarm/network, swarm/storage: validate default chunk size * swarm/bmt, swarm/network, swarm/storage: update BMT hash initialisation * swarm/bmt: move segmentCount to tests * swarm/chunk: change chunk.DefaultSize to be untyped const * swarm/storage: add size validator * swarm/storage: add chunk size validation to localstore * swarm/storage: move validation from localstore to validator * swarm/storage: global chunk rules in MRU
This commit is contained in:
committed by
Balint Gabor
parent
8a040de60b
commit
97887d98da
@ -20,6 +20,8 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/chunk"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -61,7 +63,7 @@ func TestValidator(t *testing.T) {
|
||||
// add content address validator and check puts
|
||||
// bad should fail, good should pass
|
||||
store.Validators = append(store.Validators, NewContentAddressValidator(hashfunc))
|
||||
chunks = GenerateRandomChunks(DefaultChunkSize, 2)
|
||||
chunks = GenerateRandomChunks(chunk.DefaultSize, 2)
|
||||
goodChunk = chunks[0]
|
||||
badChunk = chunks[1]
|
||||
copy(badChunk.SData, goodChunk.SData)
|
||||
@ -79,7 +81,7 @@ func TestValidator(t *testing.T) {
|
||||
var negV boolTestValidator
|
||||
store.Validators = append(store.Validators, negV)
|
||||
|
||||
chunks = GenerateRandomChunks(DefaultChunkSize, 2)
|
||||
chunks = GenerateRandomChunks(chunk.DefaultSize, 2)
|
||||
goodChunk = chunks[0]
|
||||
badChunk = chunks[1]
|
||||
copy(badChunk.SData, goodChunk.SData)
|
||||
@ -97,7 +99,7 @@ func TestValidator(t *testing.T) {
|
||||
var posV boolTestValidator = true
|
||||
store.Validators = append(store.Validators, posV)
|
||||
|
||||
chunks = GenerateRandomChunks(DefaultChunkSize, 2)
|
||||
chunks = GenerateRandomChunks(chunk.DefaultSize, 2)
|
||||
goodChunk = chunks[0]
|
||||
badChunk = chunks[1]
|
||||
copy(badChunk.SData, goodChunk.SData)
|
||||
|
Reference in New Issue
Block a user