77import org .junit .*;
88
99import java .io .*;
10+ import java .nio .charset .StandardCharsets ;
1011import java .nio .file .*;
1112import java .util .*;
1213import java .util .function .*;
@@ -396,31 +397,40 @@ public void rawLeafNodePinUpdate() throws IOException {
396397
397398 @ Test
398399 public void indirectPinTest () throws IOException {
399- Multihash EMPTY = ipfs . object . _new ( Optional . empty ()). hash ;
400- io . ipfs .api . MerkleNode data = ipfs . object . patch ( EMPTY , "set-data " , Optional . of ( "childdata " .getBytes ()), Optional . empty (), Optional . empty () );
401- Multihash child = data . hash ;
400+ String path = "/test/indirectPinTest-" + UUID . randomUUID () ;
401+ ipfs .files . write ( path + "/content " , new NamedStreamable . ByteArrayWrapper ( "something " .getBytes (StandardCharsets . UTF_8 )), true , true );
402+ Multihash content = Multihash . decode (( String ) ipfs . files . stat ( path + "/content" ). get ( "Hash" )) ;
402403
403- io .ipfs .api .MerkleNode tmp1 = ipfs .object .patch (EMPTY , "set-data" , Optional .of ("parent1_data" .getBytes ()), Optional .empty (), Optional .empty ());
404- Multihash parent1 = ipfs .object .patch (tmp1 .hash , "add-link" , Optional .empty (), Optional .of (child .toString ()), Optional .of (child )).hash ;
405- ipfs .pin .add (parent1 );
404+ // adding one more extra entry to parent1 to keep its hash different from parent2
405+ ipfs .files .mkdir (path + "/parent1" , true );
406+ ipfs .files .write (path + "/parent1/content1" , new NamedStreamable .ByteArrayWrapper ("somethingelse" .getBytes (StandardCharsets .UTF_8 )), true , true );
407+ ipfs .files .cp ("/ipfs/" + content , path + "/parent1/content2" , true );
408+
409+ ipfs .files .mkdir (path + "/parent2" , true );
410+ ipfs .files .cp ("/ipfs/" + content , path + "/parent2/content" , true );
406411
407- io .ipfs .api .MerkleNode tmp2 = ipfs .object .patch (EMPTY , "set-data" , Optional .of ("parent2_data" .getBytes ()), Optional .empty (), Optional .empty ());
408- Multihash parent2 = ipfs .object .patch (tmp2 .hash , "add-link" , Optional .empty (), Optional .of (child .toString ()), Optional .of (child )).hash ;
412+ Multihash parent1 = Multihash .decode ((String ) ipfs .files .stat (path + "/parent1" ).get ("Hash" ));
413+ Multihash parent2 = Multihash .decode ((String ) ipfs .files .stat (path + "/parent2" ).get ("Hash" ));
414+
415+ ipfs .pin .add (parent1 );
409416 ipfs .pin .add (parent2 );
410417 ipfs .pin .rm (parent1 , true );
411418
412419 Map <Multihash , Object > ls = ipfs .pin .ls (IPFS .PinType .all );
413- boolean childPresent = ls .containsKey (child );
420+ boolean childPresent = ls .containsKey (content );
414421 if (!childPresent )
415- throw new IllegalStateException ("Child not present!" );
422+ throw new IllegalStateException ("Child not present: " + ls );
416423
417424 ipfs .repo .gc ();
418425 Map <Multihash , Object > ls2 = ipfs .pin .ls (IPFS .PinType .all );
419- boolean childPresentAfterGC = ls2 .containsKey (child );
426+ boolean childPresentAfterGC = ls2 .containsKey (content );
420427 if (!childPresentAfterGC )
421- throw new IllegalStateException ("Child not present!" );
422- }
428+ throw new IllegalStateException ("Child not present:" + ls );
423429
430+ ipfs .files .rm (path , true , true );
431+ }
432+
433+ @ Ignore ("RPC API removed" )
424434 @ Test
425435 public void objectPatch () throws IOException {
426436 MerkleNode obj = ipfs .object ._new (Optional .empty ());
@@ -462,6 +472,7 @@ public void refsTest() throws IOException {
462472 }
463473 }
464474
475+ @ Ignore ("RPC API removed" )
465476 @ Test
466477 public void objectTest () throws IOException {
467478 MerkleNode _new = ipfs .object ._new (Optional .empty ());
@@ -489,10 +500,8 @@ public void bulkBlockTest() throws IOException {
489500 List <MerkleNode > bulkPut = ipfs .block .put (Arrays .asList (raw , raw , raw , raw , raw ), Optional .of ("cbor" ));
490501 List <Multihash > hashes = bulkPut .stream ().map (m -> m .hash ).collect (Collectors .toList ());
491502 byte [] result = ipfs .block .get (hashes .get (0 ));
492- System .out .println ();
493503 }
494504
495- // @Ignore // Ignored because ipfs frequently times out internally in the publish call
496505 @ Test
497506 public void publish () throws Exception {
498507 // JSON document
@@ -514,6 +523,15 @@ public void publish() throws Exception {
514523 assertEquals ("Should be equals" , resolved , "/ipfs/" + merkleNode .hash );
515524 }
516525
526+ @ Test
527+ public void resolveName () throws Exception {
528+ // Resolve from DNSLinked domain
529+ String resolved = ipfs .name .resolve ("docs.ipfs.tech" );
530+ assertNotNull (resolved );
531+ assertTrue (resolved .startsWith ("/ipfs/" ));
532+ assertTrue (resolved .length () > 20 ); // this may change (content and encoding as well)
533+ }
534+
517535 @ Test
518536 public void pubsubSynchronous () {
519537 String topic = "topic" + System .nanoTime ();
@@ -587,7 +605,6 @@ public void merkleLinkInMap() throws IOException {
587605 // These commands can be used to reproduce this on the command line
588606 String reproCommand1 = "printf \" " + toEscapedHex (rawTarget ) + "\" | ipfs block put --format=cbor" ;
589607 String reproCommand2 = "printf \" " + toEscapedHex (rawSource ) + "\" | ipfs block put --format=cbor" ;
590- System .out .println ();
591608 }
592609
593610 @ Test
@@ -652,7 +669,6 @@ public void rootMerkleLink() throws IOException {
652669 // These commands can be used to reproduce this on the command line
653670 String reproCommand1 = "printf \" " + toEscapedHex (rawTarget ) + "\" | ipfs block put --format=cbor" ;
654671 String reproCommand2 = "printf \" " + toEscapedHex (obj2 ) + "\" | ipfs block put --format=cbor" ;
655- System .out .println ();
656672 }
657673
658674 /**
@@ -672,7 +688,6 @@ public void rootNull() throws IOException {
672688
673689 // These commands can be used to reproduce this on the command line
674690 String reproCommand1 = "printf \" " + toEscapedHex (obj ) + "\" | ipfs block put --format=cbor" ;
675- System .out .println ();
676691 }
677692
678693 /**
@@ -754,7 +769,6 @@ public void dhtTest() throws IOException {
754769 @ Test
755770 public void localId () throws Exception {
756771 Map id = ipfs .id ();
757- System .out .println ();
758772 }
759773
760774 @ Test
@@ -815,13 +829,15 @@ public void versionTest() throws IOException {
815829
816830 @ Test
817831 public void swarmTestFilters () throws IOException {
832+ // on GH CI we run this in "server" profile that packs a TON of filters
833+ // See https://github.com/ipfs/kubo/blob/c1fd4d70f58e682bfe73fa4b50d17581c823c671/config/profile.go#L27
818834 Map listenAddrs = ipfs .swarm .listenAddrs ();
819835 Map localAddrs = ipfs .swarm .localAddrs (true );
820836 String multiAddrFilter = "/ip4/192.168.0.0/ipcidr/16" ;
821837 Map rm = ipfs .swarm .rmFilter (multiAddrFilter );
822838 Map filters = ipfs .swarm .filters ();
823839 List <String > filtersList = (List <String >)filters .get ("Strings" );
824- Assert .assertNull ("Filters empty" , filtersList );
840+ Assert .assertTrue ("Filters empty" , filtersList == null || ! filtersList . contains ( multiAddrFilter ) );
825841
826842 Map added = ipfs .swarm .addFilter (multiAddrFilter );
827843 filters = ipfs .swarm .filters ();
@@ -856,6 +872,8 @@ public void bitswapTest() throws IOException {
856872 Map stat = ipfs .bitswap .stat ();
857873 Map stat2 = ipfs .bitswap .stat (true );
858874 }
875+
876+ @ Ignore ("AutoConf.Enabled=true is default; prevents bootstrap removal" )
859877 @ Test
860878 public void bootstrapTest () throws IOException {
861879 List <MultiAddress > bootstrap = ipfs .bootstrap .list ();
0 commit comments