@@ -30,22 +30,26 @@ public void largeFileTest() {
30
30
fileTest (largeFile );
31
31
}
32
32
33
+ @ org .junit .Test
34
+ public void hostFileTest () {
35
+ NamedStreamable hostFile = new NamedStreamable .FileWrapper (new File ("Makefile" ));
36
+ fileTest (hostFile );
37
+ }
38
+
33
39
public void fileTest (NamedStreamable file ) {
34
40
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 );
39
43
if (lsResult .size () != 1 )
40
44
throw new IllegalStateException ("Incorrect number of objects in ls!" );
41
- if (!lsResult .get (0 ).equals (merkleObject ))
45
+ if (!lsResult .get (0 ).equals (addResult ))
42
46
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 );
45
49
if (!Arrays .equals (catResult , file .getContents ()))
46
50
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 ))
49
53
throw new IllegalStateException ("Didn't remove file!" );
50
54
Object gc = ipfs .repo .gc ();
51
55
} catch (IOException e ) {
@@ -56,8 +60,8 @@ public void fileTest(NamedStreamable file) {
56
60
@ org .junit .Test
57
61
public void refsTest () {
58
62
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 ) {
61
65
Object refs = ipfs .refs (ref , false );
62
66
}
63
67
} catch (IOException e ) {
@@ -96,8 +100,8 @@ public void blockTest() {
96
100
public void fileTest () {
97
101
try {
98
102
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 ) {
101
105
Map ls = ipfs .file .ls (hash );
102
106
}
103
107
} catch (IOException e ) {
@@ -110,7 +114,7 @@ public void nameTest() {
110
114
try {
111
115
MerkleNode pointer = new MerkleNode ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
112
116
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" ) ));
114
118
} catch (IOException e ) {
115
119
throw new RuntimeException (e );
116
120
}
@@ -137,7 +141,7 @@ public void mountTest() {
137
141
@ org .junit .Test
138
142
public void dhtTest () {
139
143
try {
140
- MerkleNode pointer = new MerkleNode ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
144
+ Multihash pointer = Multihash . fromBase58 ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
141
145
Map get = ipfs .dht .get (pointer );
142
146
Map put = ipfs .dht .put ("somekey" , "somevalue" );
143
147
Map findprovs = ipfs .dht .findprovs (pointer );
@@ -160,7 +164,7 @@ public void statsTest() {
160
164
161
165
public void resolveTest () {
162
166
try {
163
- String hash = "QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy" ;
167
+ Multihash hash = Multihash . fromBase58 ( "QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy" ) ;
164
168
Map res = ipfs .resolve ("ipns" , hash , false );
165
169
} catch (IOException e ) {
166
170
throw new RuntimeException (e );
0 commit comments