@@ -201,6 +201,37 @@ public void pinTest() {
201
201
}
202
202
}
203
203
204
+ @ org .junit .Test
205
+ public void pinUpdate () {
206
+ try {
207
+ MerkleNode child1 = ipfs .add (new NamedStreamable .ByteArrayWrapper ("some data" .getBytes ()));
208
+ Multihash hashChild1 = child1 .hash ;
209
+ System .out .println ("child1: " + hashChild1 );
210
+
211
+ CborObject .CborMerkleLink root1 = new CborObject .CborMerkleLink (hashChild1 );
212
+ MerkleNode root1Res = ipfs .block .put (Collections .singletonList (root1 .toByteArray ()), Optional .of ("cbor" )).get (0 );
213
+ System .out .println ("root1: " + root1Res .hash );
214
+ ipfs .pin .add (root1Res .hash );
215
+
216
+ CborObject .CborList root2 = new CborObject .CborList (Arrays .asList (new CborObject .CborMerkleLink (hashChild1 ), new CborObject .CborLong (42 )));
217
+ MerkleNode root2Res = ipfs .block .put (Collections .singletonList (root2 .toByteArray ()), Optional .of ("cbor" )).get (0 );
218
+ ipfs .pin .update (root1Res .hash , root2Res .hash , true );
219
+
220
+ Map <Multihash , Object > ls = ipfs .pin .ls (IPFS .PinType .all );
221
+ boolean childPresent = ls .containsKey (hashChild1 );
222
+ if (!childPresent )
223
+ throw new IllegalStateException ("Child not present!" );
224
+
225
+ ipfs .repo .gc ();
226
+ Map <Multihash , Object > ls2 = ipfs .pin .ls (IPFS .PinType .all );
227
+ boolean childPresentAfterGC = ls2 .containsKey (hashChild1 );
228
+ if (!childPresentAfterGC )
229
+ throw new IllegalStateException ("Child not present!" );
230
+ } catch (IOException e ) {
231
+ throw new RuntimeException (e );
232
+ }
233
+ }
234
+
204
235
@ org .junit .Test
205
236
public void indirectPinTest () {
206
237
try {
0 commit comments