@@ -108,6 +108,33 @@ func TestAdd(t *testing.T) {
108108 require .Equal (t , shortStringCidV1NoRawLeaves , cidStr )
109109 })
110110
111+ t .Run ("produced unixfs max file links: command flag --max-file-links overrides configuration in Import.UnixFSFileMaxLinks" , func (t * testing.T ) {
112+ t .Parallel ()
113+
114+ //
115+ // UnixFSChunker=size-262144 (256KiB)
116+ // Import.UnixFSFileMaxLinks=174
117+ node := harness .NewT (t ).NewNode ().Init ("--profile=legacy-cid-v0" ) // legacy-cid-v0 for determinism across all params
118+ node .UpdateConfig (func (cfg * config.Config ) {
119+ cfg .Import .UnixFSChunker = * config .NewOptionalString ("size-262144" ) // 256 KiB chunks
120+ cfg .Import .UnixFSFileMaxLinks = * config .NewOptionalInteger (174 ) // max 174 per level
121+ })
122+ node .StartDaemon ()
123+ defer node .StopDaemon ()
124+
125+ // Add 174MiB file:
126+ // 1024 * 256KiB should fit in single layer
127+ seed := shortString
128+ cidStr := node .IPFSAddDeterministic ("262144KiB" , seed , "--max-file-links" , "1024" )
129+ root , err := node .InspectPBNode (cidStr )
130+ assert .NoError (t , err )
131+
132+ // Expect 1024 links due to cli parameter raising link limit from 174 to 1024
133+ require .Equal (t , 1024 , len (root .Links ))
134+ // expect same CID every time
135+ require .Equal (t , "QmbBftNHWmjSWKLC49dMVrfnY8pjrJYntiAXirFJ7oJrNk" , cidStr )
136+ })
137+
111138 t .Run ("ipfs init --profile=legacy-cid-v0 sets config that produces legacy CIDv0" , func (t * testing.T ) {
112139 t .Parallel ()
113140 node := harness .NewT (t ).NewNode ().Init ("--profile=legacy-cid-v0" )
0 commit comments