@@ -30,22 +30,26 @@ public void largeFileTest() {
3030 fileTest (largeFile );
3131 }
3232
33+ @ org .junit .Test
34+ public void hostFileTest () {
35+ NamedStreamable hostFile = new NamedStreamable .FileWrapper (new File ("Makefile" ));
36+ fileTest (hostFile );
37+ }
38+
3339 public void fileTest (NamedStreamable file ) {
3440 try {
35- List <NamedStreamable > inputFiles = Arrays .asList (file );
36- List <MerkleNode > addResult = ipfs .add (inputFiles );
37- MerkleNode merkleObject = addResult .get (0 );
38- List <MerkleNode > lsResult = ipfs .ls (merkleObject );
41+ MerkleNode addResult = ipfs .add (file );
42+ List <MerkleNode > lsResult = ipfs .ls (addResult .hash );
3943 if (lsResult .size () != 1 )
4044 throw new IllegalStateException ("Incorrect number of objects in ls!" );
41- if (!lsResult .get (0 ).equals (merkleObject ))
45+ if (!lsResult .get (0 ).equals (addResult ))
4246 throw new IllegalStateException ("Object not returned in ls!" );
43- byte [] catResult = ipfs .cat (merkleObject );
44- byte [] getResult = ipfs .get (merkleObject );
47+ byte [] catResult = ipfs .cat (addResult . hash );
48+ byte [] getResult = ipfs .get (addResult . hash );
4549 if (!Arrays .equals (catResult , file .getContents ()))
4650 throw new IllegalStateException ("Different contents!" );
47- List <MerkleNode > pinRm = ipfs .pin .rm (merkleObject , true );
48- if (!pinRm .get (0 ).equals (merkleObject ))
51+ List <MerkleNode > pinRm = ipfs .pin .rm (addResult , true );
52+ if (!pinRm .get (0 ).equals (addResult ))
4953 throw new IllegalStateException ("Didn't remove file!" );
5054 Object gc = ipfs .repo .gc ();
5155 } catch (IOException e ) {
@@ -56,8 +60,8 @@ public void fileTest(NamedStreamable file) {
5660 @ org .junit .Test
5761 public void refsTest () {
5862 try {
59- List <String > local = ipfs .refs .local ();
60- for (String ref : local ) {
63+ List <Multihash > local = ipfs .refs .local ();
64+ for (Multihash ref : local ) {
6165 Object refs = ipfs .refs (ref , false );
6266 }
6367 } catch (IOException e ) {
@@ -96,8 +100,8 @@ public void blockTest() {
96100 public void fileTest () {
97101 try {
98102 ipfs .repo .gc ();
99- List <String > local = ipfs .refs .local ();
100- for (String hash : local ) {
103+ List <Multihash > local = ipfs .refs .local ();
104+ for (Multihash hash : local ) {
101105 Map ls = ipfs .file .ls (hash );
102106 }
103107 } catch (IOException e ) {
@@ -110,7 +114,7 @@ public void nameTest() {
110114 try {
111115 MerkleNode pointer = new MerkleNode ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
112116 Map pub = ipfs .name .publish (pointer );
113- String resolved = ipfs .name .resolve (( String ) pub .get ("Name" ));
117+ String resolved = ipfs .name .resolve (Multihash . fromBase58 (( String ) pub .get ("Name" ) ));
114118 } catch (IOException e ) {
115119 throw new RuntimeException (e );
116120 }
@@ -137,7 +141,7 @@ public void mountTest() {
137141 @ org .junit .Test
138142 public void dhtTest () {
139143 try {
140- MerkleNode pointer = new MerkleNode ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
144+ Multihash pointer = Multihash . fromBase58 ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
141145 Map get = ipfs .dht .get (pointer );
142146 Map put = ipfs .dht .put ("somekey" , "somevalue" );
143147 Map findprovs = ipfs .dht .findprovs (pointer );
@@ -160,7 +164,7 @@ public void statsTest() {
160164
161165 public void resolveTest () {
162166 try {
163- String hash = "QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy" ;
167+ Multihash hash = Multihash . fromBase58 ( "QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy" ) ;
164168 Map res = ipfs .resolve ("ipns" , hash , false );
165169 } catch (IOException e ) {
166170 throw new RuntimeException (e );
0 commit comments