Commit 78483a44 authored by lash's avatar lash Committed by GitHub

Add omitted test for mock validator

parent 7e40e573
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package validator
import (
......
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package validator_test
import (
"testing"
"github.com/ethersphere/bee/pkg/storage/mock/validator"
"github.com/ethersphere/bee/pkg/swarm"
)
func TestMockValidator(t *testing.T) {
validAddr := swarm.NewAddress([]byte("foo"))
invalidAddr := swarm.NewAddress([]byte("bar"))
validContent := []byte("xyzzy")
invalidContent := []byte("yzzyx")
validator := validator.NewMockValidator(validAddr, validContent)
ch := swarm.NewChunk(validAddr, validContent)
if !validator.Validate(ch) {
t.Fatalf("chunk '%v' should be valid", ch)
}
ch = swarm.NewChunk(invalidAddr, validContent)
if validator.Validate(ch) {
t.Fatalf("chunk '%v' should be invalid", ch)
}
ch = swarm.NewChunk(validAddr, invalidContent)
if validator.Validate(ch) {
t.Fatalf("chunk '%v' should be invalid", ch)
}
ch = swarm.NewChunk(invalidAddr, invalidContent)
if validator.Validate(ch) {
t.Fatalf("chunk '%v' should be invalid", ch)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment