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
d1e0c720
Unverified
Commit
d1e0c720
authored
Apr 27, 2020
by
lash
Committed by
GitHub
Apr 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct validator hash, bump bmt dep version (#123)
parent
9371a9bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
5 deletions
+8
-5
go.mod
go.mod
+1
-1
go.sum
go.sum
+3
-0
validator.go
pkg/validator/validator.go
+1
-1
validator_test.go
pkg/validator/validator_test.go
+3
-3
No files found.
go.mod
View file @
d1e0c720
...
@@ -6,7 +6,7 @@ require (
...
@@ -6,7 +6,7 @@ require (
github.com/btcsuite/btcd v0.20.1-beta
github.com/btcsuite/btcd v0.20.1-beta
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/coreos/go-semver v0.3.0
github.com/coreos/go-semver v0.3.0
github.com/ethersphere/bmt v0.1.
0
github.com/ethersphere/bmt v0.1.
1
github.com/gogo/protobuf v1.3.1
github.com/gogo/protobuf v1.3.1
github.com/gorilla/handlers v1.4.2
github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.3
github.com/gorilla/mux v1.7.3
...
...
go.sum
View file @
d1e0c720
...
@@ -70,6 +70,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
...
@@ -70,6 +70,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethersphere/bmt v0.1.0 h1:27wVVSodxfADhN64KXhV/P8Gd6RlEC2miNujJY+huNY=
github.com/ethersphere/bmt v0.1.0 h1:27wVVSodxfADhN64KXhV/P8Gd6RlEC2miNujJY+huNY=
github.com/ethersphere/bmt v0.1.0/go.mod h1:S+nhucAQ/MYvaOBzRhIkXrWogaLH8IRSb9a7D7JW85k=
github.com/ethersphere/bmt v0.1.0/go.mod h1:S+nhucAQ/MYvaOBzRhIkXrWogaLH8IRSb9a7D7JW85k=
github.com/ethersphere/bmt v0.1.1 h1:vwHSJwnDyzJ0fqP3YQBDk+/vqdAfulfRGJesQ5kL2ps=
github.com/ethersphere/bmt v0.1.1/go.mod h1:fqRBDmYwn3lX2MH4lkImXQgFWeNP8ikLkS/hgi/HRws=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
...
@@ -503,6 +505,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
...
@@ -503,6 +505,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
gitlab.com/nolash/go-mockbytes v0.0.6 h1:Fha6AnxnjXXKw/Ukacnbla8uY3jp/n1RsPHpzfmHn0U=
gitlab.com/nolash/go-mockbytes v0.0.6 h1:Fha6AnxnjXXKw/Ukacnbla8uY3jp/n1RsPHpzfmHn0U=
gitlab.com/nolash/go-mockbytes v0.0.6/go.mod h1:KKOpNTT39j2Eo+P6uUTOncntfeKY6AFh/2CxuD5MpgE=
gitlab.com/nolash/go-mockbytes v0.0.6/go.mod h1:KKOpNTT39j2Eo+P6uUTOncntfeKY6AFh/2CxuD5MpgE=
gitlab.com/nolash/go-mockbytes v0.0.7/go.mod h1:KKOpNTT39j2Eo+P6uUTOncntfeKY6AFh/2CxuD5MpgE=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA=
...
...
pkg/validator/validator.go
View file @
d1e0c720
...
@@ -31,7 +31,7 @@ type ContentAddressValidator struct {
...
@@ -31,7 +31,7 @@ type ContentAddressValidator struct {
// New constructs a new ContentAddressValidator
// New constructs a new ContentAddressValidator
func
NewContentAddressValidator
()
swarm
.
ChunkValidator
{
func
NewContentAddressValidator
()
swarm
.
ChunkValidator
{
p
:=
bmtlegacy
.
NewTreePool
(
hashFunc
,
swarm
.
SectionSize
,
bmtlegacy
.
PoolSize
)
p
:=
bmtlegacy
.
NewTreePool
(
hashFunc
,
swarm
.
Branches
,
bmtlegacy
.
PoolSize
)
return
&
ContentAddressValidator
{
return
&
ContentAddressValidator
{
hasher
:
bmtlegacy
.
New
(
p
),
hasher
:
bmtlegacy
.
New
(
p
),
...
...
pkg/validator/validator_test.go
View file @
d1e0c720
...
@@ -19,7 +19,7 @@ func TestContentAddressValidator(t *testing.T) {
...
@@ -19,7 +19,7 @@ func TestContentAddressValidator(t *testing.T) {
validator
:=
validator
.
NewContentAddressValidator
()
validator
:=
validator
.
NewContentAddressValidator
()
// generate address from pre-generated hex of 'foo' from legacy bmt
// generate address from pre-generated hex of 'foo' from legacy bmt
bmtHashOfFoo
:=
"
b9d678ef39fa973b430795a1f04e0f2541b47c996fd300552a1e8bfb5824325f
"
bmtHashOfFoo
:=
"
2387e8e7d8a48c2a9339c97c1dc3461a9a7aa07e994c5cb8b38fd7c1b3e6ea48
"
address
:=
swarm
.
MustParseHexAddress
(
bmtHashOfFoo
)
address
:=
swarm
.
MustParseHexAddress
(
bmtHashOfFoo
)
// set up a chunk object with correct expected length prefix
// set up a chunk object with correct expected length prefix
...
@@ -31,12 +31,12 @@ func TestContentAddressValidator(t *testing.T) {
...
@@ -31,12 +31,12 @@ func TestContentAddressValidator(t *testing.T) {
copy
(
fooBytes
[
8
:
],
[]
byte
(
foo
))
copy
(
fooBytes
[
8
:
],
[]
byte
(
foo
))
ch
:=
swarm
.
NewChunk
(
address
,
fooBytes
)
ch
:=
swarm
.
NewChunk
(
address
,
fooBytes
)
if
!
validator
.
Validate
(
ch
)
{
if
!
validator
.
Validate
(
ch
)
{
t
.
Fatalf
(
"data '%s' should have validated to hash '%
x
'"
,
ch
.
Data
(),
ch
.
Address
())
t
.
Fatalf
(
"data '%s' should have validated to hash '%
s
'"
,
ch
.
Data
(),
ch
.
Address
())
}
}
// now test with incorrect data
// now test with incorrect data
ch
=
swarm
.
NewChunk
(
address
,
fooBytes
[
:
len
(
fooBytes
)
-
1
])
ch
=
swarm
.
NewChunk
(
address
,
fooBytes
[
:
len
(
fooBytes
)
-
1
])
if
validator
.
Validate
(
ch
)
{
if
validator
.
Validate
(
ch
)
{
t
.
Fatalf
(
"data '%s' should not have validated to hash '%
x
'"
,
ch
.
Data
(),
ch
.
Address
())
t
.
Fatalf
(
"data '%s' should not have validated to hash '%
s
'"
,
ch
.
Data
(),
ch
.
Address
())
}
}
}
}
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