Test for alternative hash function in Dag Modifier.
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Aug 8, 2017 at 18:20 UTC
77e9b8ddf9e7e6e945305b8456f934885d22e836
2 files changed
+9
unixfs/mod/dagmodifier_test.go
+1
@@ -77,6 +77,7 @@ func runAllSubtests(t *testing.T, tfunc func(*testing.T, testu.NodeOpts)) {
77
t.Run("opts=ProtoBufLeaves", func(t *testing.T) { tfunc(t, testu.UseProtoBufLeaves) })
78
t.Run("opts=RawLeaves", func(t *testing.T) { tfunc(t, testu.UseRawLeaves) })
79
t.Run("opts=CidV1", func(t *testing.T) { tfunc(t, testu.UseCidV1) })
80
+ t.Run("opts=Blake2b256", func(t *testing.T) { tfunc(t, testu.UseBlake2b256) })
81
}
82
83
func TestDagModifierBasic(t *testing.T) {
unixfs/test/utils.go
+8
@@ -18,6 +18,7 @@ import (
18
cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid"
19
node "gx/ipfs/QmPN7cwmpcc4DWXb4KTB9dNAJgjuPY69h3npsMfhRrQL9c/go-ipld-format"
20
u "gx/ipfs/QmSU6eubNdhXjFBJBSksTp8kv8YRub8mGAPv8tVJHmL2EU/go-ipfs-util"
21
+ mh "gx/ipfs/QmU9a9NV9RdPNwZQDYd5uKsm6N6LJLSvLbywDDYFbaaC6P/go-multihash"
22
)
23
24
func SizeSplitterGen(size int64) chunk.SplitterGen {
@@ -41,6 +42,13 @@ type NodeOpts struct {
42
var UseProtoBufLeaves = NodeOpts{Prefix: mdag.V0CidPrefix()}
43
var UseRawLeaves = NodeOpts{Prefix: mdag.V0CidPrefix(), ForceRawLeaves: true, RawLeavesUsed: true}
44
var UseCidV1 = NodeOpts{Prefix: mdag.V1CidPrefix(), RawLeavesUsed: true}
45
+var UseBlake2b256 NodeOpts
46
+
47
+func init() {
48
+ UseBlake2b256 = UseCidV1
49
+ UseBlake2b256.Prefix.MhType = mh.Names["blake2b-256"]
50
+ UseBlake2b256.Prefix.MhLength = -1
51
+}
52
53
func GetNode(t testing.TB, dserv mdag.DAGService, data []byte, opts NodeOpts) node.Node {
54
in := bytes.NewReader(data)