Skip to content

Commit 78c3b3f

Browse files
committed
add test for larger binary data in a subdir in recursive add
1 parent 0a6b711 commit 78c3b3f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/io/ipfs/api/RecursiveAddTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,27 @@ public void largeBinaryRecursiveAdd() throws Exception {
6868
MerkleNode node = add.get(add.size() - 1);
6969
Assert.assertEquals(EXPECTED, node.hash.toBase58());
7070
}
71+
72+
@Test
73+
public void largeBinaryInSubdirRecursiveAdd() throws Exception {
74+
String EXPECTED = "QmUYuMwCpgaxJhNxRA5Pmje8EfpEgU3eQSB9t3VngbxYJk";
75+
76+
Path base = Paths.get("tmplargebininsubdirdata");
77+
base.toFile().mkdirs();
78+
Path bindir = base.resolve("moredata");
79+
bindir.toFile().mkdirs();
80+
byte[] bindata = new byte[100 * 1024*1024];
81+
new Random(28).nextBytes(bindata);
82+
Files.write(bindir.resolve("data.bin"), bindata);
83+
new Random(496).nextBytes(bindata);
84+
Files.write(bindir.resolve("data2.bin"), bindata);
85+
86+
Path js = base.resolve("js");
87+
js.toFile().mkdirs();
88+
Files.write(js.resolve("func.js"), "function() {console.log('Hey');}".getBytes());
89+
90+
List<MerkleNode> add = ipfs.add(new NamedStreamable.FileWrapper(base.toFile()));
91+
MerkleNode node = add.get(add.size() - 1);
92+
Assert.assertEquals(EXPECTED, node.hash.toBase58());
93+
}
7194
}

0 commit comments

Comments
 (0)