Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
a56cbf98
Commit
a56cbf98
authored
Feb 18, 2019
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gx publish 1.1.31
parent
1cc06b0c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1073 additions
and
752 deletions
+1073
-752
.gx/lastpubver
.gx/lastpubver
+1
-1
package.json
package.json
+7
-7
pb/merkledag.pb.go
pb/merkledag.pb.go
+830
-568
pb/merkledag.proto
pb/merkledag.proto
+1
-1
pb/merkledagpb_test.go
pb/merkledagpb_test.go
+210
-175
pb/stability_test.go
pb/stability_test.go
+24
-0
No files found.
.gx/lastpubver
View file @
a56cbf98
1.1.3
0
: Qm
QvMsV5aPyd7eMd3U1hvAUhZEupG3rXbVZn7ppU5RE6bt
1.1.3
1
: Qm
aaGCdoNe5juy9QxdZ2grartLXkXH7jS6zaU27AmxsJeT
package.json
View file @
a56cbf98
...
...
@@ -39,21 +39,21 @@
},
{
"author"
:
"hsanjuan"
,
"hash"
:
"Qm
YZwey1thDTynSrvd6qQkX24UpTka6TFhQ2v569UpoqxD
"
,
"hash"
:
"Qm
Sz8kAe2JCKp2dWSG8gHSWnwSmne8YfRXTeK5HBmc9L7t
"
,
"name"
:
"go-ipfs-exchange-offline"
,
"version"
:
"0.1.
5
"
"version"
:
"0.1.
6
"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qmd
xUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8
"
,
"hash"
:
"Qmd
djPSGZb3ieihSseFeCfVRpZzcqczPNsD2DvarSwnjJB
"
,
"name"
:
"gogo-protobuf"
,
"version"
:
"
0.0.0
"
"version"
:
"
1.2.1
"
},
{
"author"
:
"why"
,
"hash"
:
"Qm
ZuPasxd7fSgtzRzCL7Z8J8QwDJML2fgBUExRbQCqb4BT
"
,
"hash"
:
"Qm
UnzGFx7TSofhfrtyaJKzhP6sx5j5QfF76BFCVQa65mJr
"
,
"name"
:
"go-blockservice"
,
"version"
:
"1.1.2
3
"
"version"
:
"1.1.2
4
"
}
],
"gxVersion"
:
"0.12.1"
,
...
...
@@ -61,6 +61,6 @@
"license"
:
""
,
"name"
:
"go-merkledag"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"version"
:
"1.1.3
0
"
"version"
:
"1.1.3
1
"
}
pb/merkledag.pb.go
View file @
a56cbf98
This diff is collapsed.
Click to expand it.
pb/merkledag.proto
View file @
a56cbf98
package
merkledag
.
pb
;
import
"
code.google
.com/
p/
gogoprotobuf/gogoproto/gogo.proto"
;
import
"
github
.com/gogo
/
protobuf/gogoproto/gogo.proto"
;
option
(
gogoproto.gostring_all
)
=
true
;
option
(
gogoproto.equal_all
)
=
true
;
...
...
pb/merkledagpb_test.go
View file @
a56cbf98
// Code generated by protoc-gen-gogo.
// Code generated by protoc-gen-gogo.
DO NOT EDIT.
// source: merkledag.proto
// DO NOT EDIT!
/*
Package merkledag_pb is a generated protocol buffer package.
It is generated from these files:
merkledag.proto
It has these top-level messages:
PBLink
PBNode
*/
package
merkledag_pb
import
testing
"testing"
import
math_rand
"math/rand"
import
time
"time"
import
github_com_gogo_protobuf_proto
"github.com/gogo/protobuf/proto"
import
encoding_json
"encoding/json"
import
fmt
"fmt"
import
go_parser
"go/parser"
import
(
fmt
"fmt"
_
"github.com/gogo/protobuf/gogoproto"
github_com_gogo_protobuf_jsonpb
"github.com/gogo/protobuf/jsonpb"
github_com_gogo_protobuf_proto
"github.com/gogo/protobuf/proto"
proto
"github.com/gogo/protobuf/proto"
go_parser
"go/parser"
math
"math"
math_rand
"math/rand"
testing
"testing"
time
"time"
)
// Reference imports to suppress errors if they are not otherwise used.
var
_
=
proto
.
Marshal
var
_
=
fmt
.
Errorf
var
_
=
math
.
Inf
func
TestPBLinkProto
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBLink
(
popr
,
false
)
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
msg
:=
&
PBLink
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
for
i
:=
range
data
{
data
[
i
]
=
byte
(
popr
.
Intn
(
256
))
littlefuzz
:=
make
([]
byte
,
len
(
dAtA
))
copy
(
littlefuzz
,
dAtA
)
for
i
:=
range
dAtA
{
dAtA
[
i
]
=
byte
(
popr
.
Intn
(
256
))
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"seed = %d, %#v !Proto %#v"
,
seed
,
msg
,
p
)
}
if
len
(
littlefuzz
)
>
0
{
fuzzamount
:=
100
for
i
:=
0
;
i
<
fuzzamount
;
i
++
{
littlefuzz
[
popr
.
Intn
(
len
(
littlefuzz
))]
=
byte
(
popr
.
Intn
(
256
))
littlefuzz
=
append
(
littlefuzz
,
byte
(
popr
.
Intn
(
256
)))
}
// shouldn't panic
_
=
github_com_gogo_protobuf_proto
.
Unmarshal
(
littlefuzz
,
msg
)
}
}
func
TestPBLinkMarshalTo
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBLink
(
popr
,
false
)
size
:=
p
.
Size
()
d
ata
:=
make
([]
byte
,
size
)
for
i
:=
range
d
ata
{
d
ata
[
i
]
=
byte
(
popr
.
Intn
(
256
))
d
AtA
:=
make
([]
byte
,
size
)
for
i
:=
range
d
AtA
{
d
AtA
[
i
]
=
byte
(
popr
.
Intn
(
256
))
}
_
,
err
:=
p
.
MarshalTo
(
d
ata
)
_
,
err
:=
p
.
MarshalTo
(
d
AtA
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
msg
:=
&
PBLink
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
for
i
:=
range
d
ata
{
d
ata
[
i
]
=
byte
(
popr
.
Intn
(
256
))
for
i
:=
range
d
AtA
{
d
AtA
[
i
]
=
byte
(
popr
.
Intn
(
256
))
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Proto %#v"
,
seed
,
msg
,
p
)
}
}
...
...
@@ -80,11 +92,11 @@ func BenchmarkPBLinkProtoMarshal(b *testing.B) {
}
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
pops
[
i
%
10000
])
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
pops
[
i
%
10000
])
if
err
!=
nil
{
panic
(
err
)
}
total
+=
len
(
d
ata
)
total
+=
len
(
d
AtA
)
}
b
.
SetBytes
(
int64
(
total
/
b
.
N
))
}
...
...
@@ -94,11 +106,11 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) {
total
:=
0
datas
:=
make
([][]
byte
,
10000
)
for
i
:=
0
;
i
<
10000
;
i
++
{
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
NewPopulatedPBLink
(
popr
,
false
))
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
NewPopulatedPBLink
(
popr
,
false
))
if
err
!=
nil
{
panic
(
err
)
}
datas
[
i
]
=
d
ata
datas
[
i
]
=
d
AtA
}
msg
:=
&
PBLink
{}
b
.
ResetTimer
()
...
...
@@ -112,51 +124,64 @@ func BenchmarkPBLinkProtoUnmarshal(b *testing.B) {
}
func
TestPBNodeProto
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBNode
(
popr
,
false
)
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
msg
:=
&
PBNode
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
for
i
:=
range
data
{
data
[
i
]
=
byte
(
popr
.
Intn
(
256
))
littlefuzz
:=
make
([]
byte
,
len
(
dAtA
))
copy
(
littlefuzz
,
dAtA
)
for
i
:=
range
dAtA
{
dAtA
[
i
]
=
byte
(
popr
.
Intn
(
256
))
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"seed = %d, %#v !Proto %#v"
,
seed
,
msg
,
p
)
}
if
len
(
littlefuzz
)
>
0
{
fuzzamount
:=
100
for
i
:=
0
;
i
<
fuzzamount
;
i
++
{
littlefuzz
[
popr
.
Intn
(
len
(
littlefuzz
))]
=
byte
(
popr
.
Intn
(
256
))
littlefuzz
=
append
(
littlefuzz
,
byte
(
popr
.
Intn
(
256
)))
}
// shouldn't panic
_
=
github_com_gogo_protobuf_proto
.
Unmarshal
(
littlefuzz
,
msg
)
}
}
func
TestPBNodeMarshalTo
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBNode
(
popr
,
false
)
size
:=
p
.
Size
()
d
ata
:=
make
([]
byte
,
size
)
for
i
:=
range
d
ata
{
d
ata
[
i
]
=
byte
(
popr
.
Intn
(
256
))
d
AtA
:=
make
([]
byte
,
size
)
for
i
:=
range
d
AtA
{
d
AtA
[
i
]
=
byte
(
popr
.
Intn
(
256
))
}
_
,
err
:=
p
.
MarshalTo
(
d
ata
)
_
,
err
:=
p
.
MarshalTo
(
d
AtA
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
msg
:=
&
PBNode
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
for
i
:=
range
d
ata
{
d
ata
[
i
]
=
byte
(
popr
.
Intn
(
256
))
for
i
:=
range
d
AtA
{
d
AtA
[
i
]
=
byte
(
popr
.
Intn
(
256
))
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Proto %#v"
,
seed
,
msg
,
p
)
}
}
...
...
@@ -169,11 +194,11 @@ func BenchmarkPBNodeProtoMarshal(b *testing.B) {
}
b
.
ResetTimer
()
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
pops
[
i
%
10000
])
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
pops
[
i
%
10000
])
if
err
!=
nil
{
panic
(
err
)
}
total
+=
len
(
d
ata
)
total
+=
len
(
d
AtA
)
}
b
.
SetBytes
(
int64
(
total
/
b
.
N
))
}
...
...
@@ -183,11 +208,11 @@ func BenchmarkPBNodeProtoUnmarshal(b *testing.B) {
total
:=
0
datas
:=
make
([][]
byte
,
10000
)
for
i
:=
0
;
i
<
10000
;
i
++
{
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
NewPopulatedPBNode
(
popr
,
false
))
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
NewPopulatedPBNode
(
popr
,
false
))
if
err
!=
nil
{
panic
(
err
)
}
datas
[
i
]
=
d
ata
datas
[
i
]
=
d
AtA
}
msg
:=
&
PBNode
{}
b
.
ResetTimer
()
...
...
@@ -201,143 +226,190 @@ func BenchmarkPBNodeProtoUnmarshal(b *testing.B) {
}
func
TestPBLinkJSON
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBLink
(
popr
,
true
)
jsondata
,
err
:=
encoding_json
.
Marshal
(
p
)
marshaler
:=
github_com_gogo_protobuf_jsonpb
.
Marshaler
{}
jsondata
,
err
:=
marshaler
.
MarshalToString
(
p
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
msg
:=
&
PBLink
{}
err
=
encoding
_json
.
Unmarshal
(
jsondata
,
msg
)
err
=
github_com_gogo_protobuf
_json
pb
.
Unmarshal
String
(
jsondata
,
msg
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Json Equal %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Json Equal %#v"
,
seed
,
msg
,
p
)
}
}
func
TestPBNodeJSON
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBNode
(
popr
,
true
)
jsondata
,
err
:=
encoding_json
.
Marshal
(
p
)
marshaler
:=
github_com_gogo_protobuf_jsonpb
.
Marshaler
{}
jsondata
,
err
:=
marshaler
.
MarshalToString
(
p
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
msg
:=
&
PBNode
{}
err
=
encoding
_json
.
Unmarshal
(
jsondata
,
msg
)
err
=
github_com_gogo_protobuf
_json
pb
.
Unmarshal
String
(
jsondata
,
msg
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Json Equal %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Json Equal %#v"
,
seed
,
msg
,
p
)
}
}
func
TestPBLinkProtoText
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBLink
(
popr
,
true
)
d
ata
:=
github_com_gogo_protobuf_proto
.
MarshalTextString
(
p
)
d
AtA
:=
github_com_gogo_protobuf_proto
.
MarshalTextString
(
p
)
msg
:=
&
PBLink
{}
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Proto %#v"
,
seed
,
msg
,
p
)
}
}
func
TestPBLinkProtoCompactText
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBLink
(
popr
,
true
)
d
ata
:=
github_com_gogo_protobuf_proto
.
CompactTextString
(
p
)
d
AtA
:=
github_com_gogo_protobuf_proto
.
CompactTextString
(
p
)
msg
:=
&
PBLink
{}
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Proto %#v"
,
seed
,
msg
,
p
)
}
}
func
TestPBNodeProtoText
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBNode
(
popr
,
true
)
d
ata
:=
github_com_gogo_protobuf_proto
.
MarshalTextString
(
p
)
d
AtA
:=
github_com_gogo_protobuf_proto
.
MarshalTextString
(
p
)
msg
:=
&
PBNode
{}
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Proto %#v"
,
seed
,
msg
,
p
)
}
}
func
TestPBNodeProtoCompactText
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBNode
(
popr
,
true
)
d
ata
:=
github_com_gogo_protobuf_proto
.
CompactTextString
(
p
)
d
AtA
:=
github_com_gogo_protobuf_proto
.
CompactTextString
(
p
)
msg
:=
&
PBNode
{}
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
ata
,
msg
);
err
!=
nil
{
panic
(
err
)
if
err
:=
github_com_gogo_protobuf_proto
.
UnmarshalText
(
d
AtA
,
msg
);
err
!=
nil
{
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseProto %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"
seed = %d,
%#v !VerboseProto %#v, since %v"
,
seed
,
msg
,
p
,
err
)
}
if
!
p
.
Equal
(
msg
)
{
t
.
Fatalf
(
"%#v !Proto %#v"
,
msg
,
p
)
t
.
Fatalf
(
"
seed = %d,
%#v !Proto %#v"
,
seed
,
msg
,
p
)
}
}
func
TestPBLink
Stringer
(
t
*
testing
.
T
)
{
func
TestPBLink
VerboseEqual
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBLink
(
popr
,
false
)
s1
:=
p
.
String
()
s2
:=
fmt
.
Sprintf
(
"%v"
,
p
)
dAtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
}
msg
:=
&
PBLink
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
dAtA
,
msg
);
err
!=
nil
{
panic
(
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseEqual %#v, since %v"
,
msg
,
p
,
err
)
}
}
func
TestPBNodeVerboseEqual
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBNode
(
popr
,
false
)
dAtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
}
msg
:=
&
PBNode
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
dAtA
,
msg
);
err
!=
nil
{
panic
(
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseEqual %#v, since %v"
,
msg
,
p
,
err
)
}
}
func
TestPBLinkGoString
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBLink
(
popr
,
false
)
s1
:=
p
.
GoString
()
s2
:=
fmt
.
Sprintf
(
"%#v"
,
p
)
if
s1
!=
s2
{
t
.
Fatalf
(
"String want %v got %v"
,
s1
,
s2
)
t
.
Fatalf
(
"GoString want %v got %v"
,
s1
,
s2
)
}
_
,
err
:=
go_parser
.
ParseExpr
(
s1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestPBNodeString
er
(
t
*
testing
.
T
)
{
func
TestPBNode
Go
String
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBNode
(
popr
,
false
)
s1
:=
p
.
String
()
s2
:=
fmt
.
Sprintf
(
"%v"
,
p
)
s1
:=
p
.
Go
String
()
s2
:=
fmt
.
Sprintf
(
"%
#
v"
,
p
)
if
s1
!=
s2
{
t
.
Fatalf
(
"String want %v got %v"
,
s1
,
s2
)
t
.
Fatalf
(
"GoString want %v got %v"
,
s1
,
s2
)
}
_
,
err
:=
go_parser
.
ParseExpr
(
s1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestPBLinkSize
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBLink
(
popr
,
true
)
size2
:=
github_com_gogo_protobuf_proto
.
Size
(
p
)
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
size
:=
p
.
Size
()
if
len
(
d
ata
)
!=
size
{
t
.
Fatalf
(
"
size %v != marshalled size %v"
,
size
,
len
(
d
ata
))
if
len
(
d
AtA
)
!=
size
{
t
.
Errorf
(
"seed = %d,
size %v != marshalled size %v"
,
seed
,
size
,
len
(
d
AtA
))
}
if
size2
!=
size
{
t
.
Fatalf
(
"
size %v != before marshal proto.Size %v"
,
size
,
size2
)
t
.
Errorf
(
"seed = %d,
size %v != before marshal proto.Size %v"
,
seed
,
size
,
size2
)
}
size3
:=
github_com_gogo_protobuf_proto
.
Size
(
p
)
if
size3
!=
size
{
t
.
Fatalf
(
"
size %v != after marshal proto.Size %v"
,
size
,
size3
)
t
.
Errorf
(
"seed = %d,
size %v != after marshal proto.Size %v"
,
seed
,
size
,
size3
)
}
}
...
...
@@ -356,23 +428,24 @@ func BenchmarkPBLinkSize(b *testing.B) {
}
func
TestPBNodeSize
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
seed
:=
time
.
Now
()
.
UnixNano
()
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
seed
))
p
:=
NewPopulatedPBNode
(
popr
,
true
)
size2
:=
github_com_gogo_protobuf_proto
.
Size
(
p
)
d
ata
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
d
AtA
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"seed = %d, err = %v"
,
seed
,
err
)
}
size
:=
p
.
Size
()
if
len
(
d
ata
)
!=
size
{
t
.
Fatalf
(
"
size %v != marshalled size %v"
,
size
,
len
(
d
ata
))
if
len
(
d
AtA
)
!=
size
{
t
.
Errorf
(
"seed = %d,
size %v != marshalled size %v"
,
seed
,
size
,
len
(
d
AtA
))
}
if
size2
!=
size
{
t
.
Fatalf
(
"
size %v != before marshal proto.Size %v"
,
size
,
size2
)
t
.
Errorf
(
"seed = %d,
size %v != before marshal proto.Size %v"
,
seed
,
size
,
size2
)
}
size3
:=
github_com_gogo_protobuf_proto
.
Size
(
p
)
if
size3
!=
size
{
t
.
Fatalf
(
"
size %v != after marshal proto.Size %v"
,
size
,
size3
)
t
.
Errorf
(
"seed = %d,
size %v != after marshal proto.Size %v"
,
seed
,
size
,
size3
)
}
}
...
...
@@ -390,60 +463,22 @@ func BenchmarkPBNodeSize(b *testing.B) {
b
.
SetBytes
(
int64
(
total
/
b
.
N
))
}
func
TestPBLink
Go
String
(
t
*
testing
.
T
)
{
func
TestPBLinkString
er
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBLink
(
popr
,
false
)
s1
:=
p
.
Go
String
()
s2
:=
fmt
.
Sprintf
(
"%
#
v"
,
p
)
s1
:=
p
.
String
()
s2
:=
fmt
.
Sprintf
(
"%v"
,
p
)
if
s1
!=
s2
{
t
.
Fatalf
(
"GoString want %v got %v"
,
s1
,
s2
)
}
_
,
err
:=
go_parser
.
ParseExpr
(
s1
)
if
err
!=
nil
{
panic
(
err
)
t
.
Fatalf
(
"String want %v got %v"
,
s1
,
s2
)
}
}
func
TestPBNode
Go
String
(
t
*
testing
.
T
)
{
func
TestPBNodeString
er
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBNode
(
popr
,
false
)
s1
:=
p
.
Go
String
()
s2
:=
fmt
.
Sprintf
(
"%
#
v"
,
p
)
s1
:=
p
.
String
()
s2
:=
fmt
.
Sprintf
(
"%v"
,
p
)
if
s1
!=
s2
{
t
.
Fatalf
(
"GoString want %v got %v"
,
s1
,
s2
)
}
_
,
err
:=
go_parser
.
ParseExpr
(
s1
)
if
err
!=
nil
{
panic
(
err
)
}
}
func
TestPBLinkVerboseEqual
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBLink
(
popr
,
false
)
data
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
}
msg
:=
&
PBLink
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
data
,
msg
);
err
!=
nil
{
panic
(
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseEqual %#v, since %v"
,
msg
,
p
,
err
)
}
}
func
TestPBNodeVerboseEqual
(
t
*
testing
.
T
)
{
popr
:=
math_rand
.
New
(
math_rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
p
:=
NewPopulatedPBNode
(
popr
,
false
)
data
,
err
:=
github_com_gogo_protobuf_proto
.
Marshal
(
p
)
if
err
!=
nil
{
panic
(
err
)
}
msg
:=
&
PBNode
{}
if
err
:=
github_com_gogo_protobuf_proto
.
Unmarshal
(
data
,
msg
);
err
!=
nil
{
panic
(
err
)
}
if
err
:=
p
.
VerboseEqual
(
msg
);
err
!=
nil
{
t
.
Fatalf
(
"%#v !VerboseEqual %#v, since %v"
,
msg
,
p
,
err
)
t
.
Fatalf
(
"String want %v got %v"
,
s1
,
s2
)
}
}
...
...
pb/stability_test.go
0 → 100644
View file @
a56cbf98
package
merkledag_pb
import
(
bytes
"bytes"
"testing"
)
func
TestStability
(
t
*
testing
.
T
)
{
correct
:=
[]
byte
(
"
\x12\x87\x01\n
;
\x81\x86
9
\xac
H
\xa4
Ư
\xa2\xf1
X
\x1a\x8b\x95
%
\xe2\x0f\xda
h
\x92\u007f
+/
\xf8
6
\xf7
5x
\xdb\x0f\xa5
L)
\xf7\xfd\x92\x8d\x92\xca
C
\xf1\x93\xde\xe4\u007f
Y
\x15
I
\xf5\x97\xa8\x11\xc8\xfa
g
\xab\x03\x1e\xbd\x12
B|CMw`mHq{>?|vd{0F7>8<B;SUcg1E|NU:>m[C`HSg3UcXmGs-qp-z6{Kc.tGX->H07
\x18\xea
ئ
\xd0\b\x12
9
\x12
1LZ3,V9jnmk^veYEV71EMLt9;6]}b<OBKeL+0ceE8.SenYYxr,
\x18
쎔
\xc1\x05\x12
7
\n
/Z
\xb5
R
\x9d
p@t
\xaf
J
\xc8\xc0\xf5\xa4
o
\t
n
\xe8
GzwT0
\x03\x8f\xc0\x0e\xac\x03\xaf
M
\xdc\xd3
%
\xbd
+11
\x06
4
\x8a\b\xb8
d
\"\xf5
ݬ
\x18\xf5\x8d\xd7\xc7\r\x12
b
\n
<
\xaf\xbd
m
\xdc\b\x0f\x1d\xfd\xc9
ĭ%oGV F
\xfc
@T
\xf5\x9b
[
\xe5
F^u
\xe6\xe0\xaa
`
\xc8\xeb
.
\xe5\xd4\xcd
&P
\xa8\x1c\xce\xe3
U
\a\xa1\x1a
7
\x90
q
\xc7
Q
\xf7\x1f\xdf\r\xfe\xb3\xfb\xc8\x12\x1c
Be<DTg1rDhlUHMppHvO8n
\\
C.Go^T
\x18\x82\x8b\xd1\xce\x0f\x12
f
\n
Y
\n\x87\x16\xa9
(
\xe7
ͺ
\xea
ɿ%
\x00\x98
IE
\xcc\xe5\xda
Lo
\xb4\x82\x9d\xbb
f
\x9f
aD@
\xf7\x19
.
\x14\xea
_
\xba
I,
\x95
V
\xd7
@
\x88\xa9\x13
.J
\\\x13\xcc\x15\x9a\xa6\xeb
J
\x0e\x9b\x96
<
\xad\xd1
n
\x9c
-
\xba\xfd\xce
&
\xc7\x18\xbc\xdc\x0f\xa7
ԭ
\x15
^
\xeb
̹Fq
\xe3\xdd\xfb
K
\x99\x12\x03
Xyv
\x18\xb3
Ր
\xb3\r\x12
}
\n
I
\x89\xdf\xff\x84\r\xae
ʨ
\x9b\x8e\xf2
1
\xf6\xf2
~
\x13\xda\xeb\xe2\xed\xcd\xed\x9f
8ƞ
\u007f
z
\xa1\x83
N
\xda\x01\xe3
5A
\x10\xa6\x11
|u
\\
*{N
\x18
)
\xae\xc7\xc5\x06\xc1
d
\a\xcc\x17\xb0\x8f\xd5\xd2\xe3
Pj
\x9a
H
\x04\xa3\xba
{
\"\xd1\x15\x12
*Y6m[-JhYc}LWlNU533k`>nkU2e7GXmqisoCPV0C+ni
\x18
Ա
\xfe\x8b\f\x12
u
\n
'
\xf2
#
\xc1\xc0
nQ
\xf9\xb5\x19\x80\xcd\xf8\x06
k1
\xf6
#
\x84\x1c\xb6\xbf\xea
Y
\x9b\xd8
O
\x84\x04\xdb
Kq
\xe4\xae\xf2\xd6\xe9
*
\x16
B
\x12
D[gVeg4=t}EGSu82+dmgvQ+Tr>_sLUJ|iZ[P2y2T67ilvEikK}
\\
iru?IF?mVS[Mv9KG8+
\x18\x92\xa0\xf9\xa1\n\n\x11
?̎
\v\x06
ѣ
\x80
nH
\x12\x00\xa7\xd2
w͝"
)
n
:=
new
(
PBNode
)
err
:=
n
.
Unmarshal
(
correct
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
d
,
err
:=
n
.
Marshal
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
bytes
.
Equal
(
d
,
correct
)
{
t
.
Logf
(
"%q"
,
d
)
t
.
Fatal
(
"protobuf not stable"
)
}
}
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