@@ -12,13 +12,14 @@ func TestAdd(t *testing.T) {
12
12
t .Parallel ()
13
13
14
14
var (
15
- shortString = "hello world"
16
- shortStringCidV0 = "Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD"
17
- shortStringCidV1 = "bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e"
18
- shortStringCidV1Sha512 = "bafkrgqbqt3gerhas23vuzrapkdeqf4vu2dwxp3srdj6hvg6nhsug2tgyn6mj3u23yx7utftq3i2ckw2fwdh5qmhid5qf3t35yvkc5e5ottlw6"
15
+ shortString = "hello world"
16
+ shortStringCidV0 = "Qmf412jQZiuVUtdgnB36FXFX7xg5V6KEbSJ4dpQuhkLyfD" // cidv0 - dag-pb - sha2-256
17
+ shortStringCidV1 = "bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e" // cidv1 - raw - sha2-256
18
+ shortStringCidV1NoRawLeaves = "bafybeihykld7uyxzogax6vgyvag42y7464eywpf55gxi5qpoisibh3c5wa" // cidv1 - dag-pb - sha2-256
19
+ shortStringCidV1Sha512 = "bafkrgqbqt3gerhas23vuzrapkdeqf4vu2dwxp3srdj6hvg6nhsug2tgyn6mj3u23yx7utftq3i2ckw2fwdh5qmhid5qf3t35yvkc5e5ottlw6"
19
20
)
20
21
21
- t .Run ("output cid version: default (CIDv0)" , func (t * testing.T ) {
22
+ t .Run ("produced cid version: implicit default (CIDv0)" , func (t * testing.T ) {
22
23
t .Parallel ()
23
24
node := harness .NewT (t ).NewNode ().Init ().StartDaemon ()
24
25
defer node .StopDaemon ()
@@ -27,7 +28,7 @@ func TestAdd(t *testing.T) {
27
28
require .Equal (t , shortStringCidV0 , cidStr )
28
29
})
29
30
30
- t .Run ("output cid version: follows configuration (CIDv0) " , func (t * testing.T ) {
31
+ t .Run ("produced cid version: follows user-set configuration Import.CidVersion=0 " , func (t * testing.T ) {
31
32
t .Parallel ()
32
33
node := harness .NewT (t ).NewNode ().Init ()
33
34
node .UpdateConfig (func (cfg * config.Config ) {
@@ -40,7 +41,7 @@ func TestAdd(t *testing.T) {
40
41
require .Equal (t , shortStringCidV0 , cidStr )
41
42
})
42
43
43
- t .Run ("output cid version : follows configuration (hash function) " , func (t * testing.T ) {
44
+ t .Run ("produced cid multihash : follows user-set configuration in Import.HashFunction " , func (t * testing.T ) {
44
45
t .Parallel ()
45
46
node := harness .NewT (t ).NewNode ().Init ()
46
47
node .UpdateConfig (func (cfg * config.Config ) {
@@ -53,7 +54,7 @@ func TestAdd(t *testing.T) {
53
54
require .Equal (t , shortStringCidV1Sha512 , cidStr )
54
55
})
55
56
56
- t .Run ("output cid version: follows configuration (CIDv1) " , func (t * testing.T ) {
57
+ t .Run ("produced cid version: follows user-set configuration Import.CidVersion=1 " , func (t * testing.T ) {
57
58
t .Parallel ()
58
59
node := harness .NewT (t ).NewNode ().Init ()
59
60
node .UpdateConfig (func (cfg * config.Config ) {
@@ -66,7 +67,7 @@ func TestAdd(t *testing.T) {
66
67
require .Equal (t , shortStringCidV1 , cidStr )
67
68
})
68
69
69
- t .Run ("output cid version: flag overrides configuration" , func (t * testing.T ) {
70
+ t .Run ("produced cid version: command flag overrides configuration in Import.CidVersion " , func (t * testing.T ) {
70
71
t .Parallel ()
71
72
node := harness .NewT (t ).NewNode ().Init ()
72
73
node .UpdateConfig (func (cfg * config.Config ) {
@@ -78,4 +79,20 @@ func TestAdd(t *testing.T) {
78
79
cidStr := node .IPFSAddStr (shortString , "--cid-version" , "0" )
79
80
require .Equal (t , shortStringCidV0 , cidStr )
80
81
})
82
+
83
+ t .Run ("produced unixfs raw leaves: follows user-set configuration Import.UnixFSRawLeaves" , func (t * testing.T ) {
84
+ t .Parallel ()
85
+ node := harness .NewT (t ).NewNode ().Init ()
86
+ node .UpdateConfig (func (cfg * config.Config ) {
87
+ // CIDv1 defaults to raw-leaves=true
88
+ cfg .Import .CidVersion = * config .NewOptionalInteger (1 )
89
+ // disable manually
90
+ cfg .Import .UnixFSRawLeaves = config .False
91
+ })
92
+ node .StartDaemon ()
93
+ defer node .StopDaemon ()
94
+
95
+ cidStr := node .IPFSAddStr (shortString )
96
+ require .Equal (t , shortStringCidV1NoRawLeaves , cidStr )
97
+ })
81
98
}
0 commit comments