Skip to content

Commit 6c43f7d

Browse files
committed
fix dag json test
1 parent 67f00b9 commit 6c43f7d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/io/ipfs/api/NamedStreamable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class FileWrapper implements NamedStreamable {
2929
private final File source;
3030

3131
public FileWrapper(File source) {
32+
if (! source.exists())
33+
throw new IllegalStateException("File does not exist: " + source);
3234
this.source = source;
3335
}
3436

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ public class APITest {
2222

2323
@Test
2424
public void dag() throws IOException {
25-
byte[] object = "{\"data\":1234}".getBytes();
25+
String original = "{\"data\":1234}";
26+
byte[] object = original.getBytes();
2627
MerkleNode put = ipfs.dag.put("json", object);
2728

28-
Cid expected = Cid.decode("zdpuB2CbdLrUK5AgZusm4hraisDDDC135ugdmZWvMHhhsSYTb");
29+
Cid expected = Cid.decode("zdpuAs3whHmb9T1NkHSLGF45ykcKrEBxSLiEx6YpLzmKbQLEB");
2930

3031
Multihash result = put.hash;
3132
Assert.assertTrue("Correct cid returned", result.equals(expected));
3233

3334
byte[] get = ipfs.dag.get(expected);
34-
Assert.assertTrue("Raw data equal", Arrays.equals(object, get));
35+
Assert.assertTrue("Raw data equal", original.equals(new String(get).trim()));
3536
}
3637

3738
@Test

0 commit comments

Comments
 (0)