@@ -15,6 +15,7 @@ import (
15
15
dagpb "github.com/ipld/go-codec-dagpb"
16
16
"github.com/ipld/go-ipld-prime"
17
17
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
18
+ "github.com/multiformats/go-multihash"
18
19
"github.com/stretchr/testify/require"
19
20
)
20
21
@@ -67,6 +68,40 @@ func TestBuildUnixFSFileWrappedInDirectory_Reference(t *testing.T) {
67
68
}
68
69
}
69
70
71
+ // Cross-impl reference test: directory of files with single character
72
+ // names, starting from ' ' and ending with '~', but excluding the special
73
+ // characters '/' and '.'. Each file should contain a single byte with the
74
+ // same value as the character in its name. Files are added to a sharded
75
+ // directory with a fanout of 16, using CIDv1 throughout, and should result
76
+ // in the root CID of:
77
+ //
78
+ // bafybeihnipspiyy3dctpcx7lv655qpiuy52d7b2fzs52dtrjqwmvbiux44
79
+ func TestBuildUnixFSDirectoryShardAltFanout_Reference (t * testing.T ) {
80
+ ls := cidlink .DefaultLinkSystem ()
81
+ storage := cidlink.Memory {}
82
+ ls .StorageReadOpener = storage .OpenRead
83
+ ls .StorageWriteOpener = storage .OpenWrite
84
+ entries := make ([]dagpb.PBLink , 0 )
85
+ for ch := ' ' ; ch <= '~' ; ch ++ {
86
+ if ch == '/' || ch == '.' {
87
+ continue
88
+ }
89
+ s := string (ch )
90
+ r := bytes .NewBuffer ([]byte (s ))
91
+ e , err := mkEntry (r , s , & ls )
92
+ require .NoError (t , err )
93
+ entries = append (entries , e )
94
+ }
95
+ lnk , sz , err := BuildUnixFSShardedDirectory (16 , multihash .MURMUR3X64_64 , entries , & ls )
96
+ require .NoError (t , err )
97
+ var totStored int
98
+ for _ , blk := range storage .Bag {
99
+ totStored += len (blk )
100
+ }
101
+ require .Equal (t , totStored , int (sz ))
102
+ require .Equal (t , "bafybeihnipspiyy3dctpcx7lv655qpiuy52d7b2fzs52dtrjqwmvbiux44" , lnk .String ())
103
+ }
104
+
70
105
func TestBuildUnixFSDirectory (t * testing.T ) {
71
106
ls := cidlink .DefaultLinkSystem ()
72
107
storage := cidlink.Memory {}
0 commit comments