@@ -232,6 +232,37 @@ public void pinUpdate() {
232232 }
233233 }
234234
235+ @ org .junit .Test
236+ public void rawLeafNodePinUpdate () {
237+ try {
238+ MerkleNode child1 = ipfs .block .put ("some data" .getBytes (), Optional .of ("raw" ));
239+ Multihash hashChild1 = child1 .hash ;
240+ System .out .println ("child1: " + hashChild1 );
241+
242+ CborObject .CborMerkleLink root1 = new CborObject .CborMerkleLink (hashChild1 );
243+ MerkleNode root1Res = ipfs .block .put (Collections .singletonList (root1 .toByteArray ()), Optional .of ("cbor" )).get (0 );
244+ System .out .println ("root1: " + root1Res .hash );
245+ ipfs .pin .add (root1Res .hash );
246+
247+ CborObject .CborList root2 = new CborObject .CborList (Arrays .asList (new CborObject .CborMerkleLink (hashChild1 ), new CborObject .CborLong (42 )));
248+ MerkleNode root2Res = ipfs .block .put (Collections .singletonList (root2 .toByteArray ()), Optional .of ("cbor" )).get (0 );
249+ List <MultiAddress > update = ipfs .pin .update (root1Res .hash , root2Res .hash , true );
250+
251+ Map <Multihash , Object > ls = ipfs .pin .ls (IPFS .PinType .all );
252+ boolean childPresent = ls .containsKey (hashChild1 );
253+ if (!childPresent )
254+ throw new IllegalStateException ("Child not present!" );
255+
256+ ipfs .repo .gc ();
257+ Map <Multihash , Object > ls2 = ipfs .pin .ls (IPFS .PinType .all );
258+ boolean childPresentAfterGC = ls2 .containsKey (hashChild1 );
259+ if (!childPresentAfterGC )
260+ throw new IllegalStateException ("Child not present!" );
261+ } catch (IOException e ) {
262+ throw new RuntimeException (e );
263+ }
264+ }
265+
235266 @ org .junit .Test
236267 public void indirectPinTest () {
237268 try {
0 commit comments