Skip to content

Commit 6731aa9

Browse files
authored
Merge pull request #253 from ipfs-shipyard/fix/update-kubo
Update Kubo version tested against
2 parents 79d7990 + 1af4382 commit 6731aa9

6 files changed

Lines changed: 62 additions & 33 deletions

File tree

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
version: '2'
22
services:
33
ipfs-daemon:
4-
image: 'ipfs/kubo:v0.18.1'
4+
image: 'ipfs/kubo:v0.39.0'
55
ports:
66
- "4001:4001"
77
- "5001:5001"
88
user: "ipfs"
9-
command: [ "daemon", "--enable-pubsub-experiment" ]
9+
command: [ "daemon", "--enable-pubsub-experiment", "--enable-namesys-pubsub", "--routing=dhtclient" ]

install-run-ipfs.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
2-
wget https://dist.ipfs.io/kubo/v0.18.1/kubo_v0.18.1_linux-amd64.tar.gz -O /tmp/kubo_linux-amd64.tar.gz
2+
wget https://dist.ipfs.io/kubo/v0.39.0/kubo_v0.39.0_linux-amd64.tar.gz -O /tmp/kubo_linux-amd64.tar.gz
33
tar -xvf /tmp/kubo_linux-amd64.tar.gz
44
export PATH=$PATH:$PWD/kubo/
5-
ipfs init
6-
ipfs daemon --enable-pubsub-experiment --routing=dhtclient &
5+
ipfs init --profile server
6+
ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --routing=dhtclient &

mac-install-run-ipfs.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
2-
wget https://dist.ipfs.io/kubo/v0.18.1/kubo_v0.18.1_darwin-arm64.tar.gz -O /tmp/kubo_darwin-arm64.tar.gz
2+
wget https://dist.ipfs.io/kubo/v0.39.0/kubo_v0.39.0_darwin-arm64.tar.gz -O /tmp/kubo_darwin-arm64.tar.gz
33
tar -xvf /tmp/kubo_darwin-arm64.tar.gz
44
export PATH=$PATH:$PWD/kubo/
5-
ipfs init
6-
ipfs daemon --enable-pubsub-experiment --routing=dhtclient &
5+
ipfs init --profile server
6+
ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --routing=dhtclient &

src/main/java/io/ipfs/api/IPFS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ public List<MultiAddress> add() throws IOException {
832832
}
833833

834834
public List<MultiAddress> list() throws IOException {
835-
return ((List<String>)retrieveMap("bootstrap/list").get("Peers"))
835+
return ((List<String>)retrieveMap("bootstrap/list?expand-auto=true").get("Peers"))
836836
.stream().map(x -> new MultiAddress(x)).collect(Collectors.toList());
837837
}
838838

src/main/java/io/ipfs/api/Peer.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
import io.ipfs.cid.*;
44
import io.ipfs.multiaddr.*;
5+
import io.ipfs.multibase.Base58;
56
import io.ipfs.multihash.*;
67

78
import java.util.*;
89
import java.util.function.*;
910

1011
public class Peer {
1112
public final MultiAddress address;
12-
public final Multihash id;
13+
public final Cid id;
1314
public final long latency;
1415
public final String muxer;
1516
public final Object streams;
1617

17-
public Peer(MultiAddress address, Multihash id, long latency, String muxer, Object streams) {
18+
public Peer(MultiAddress address, Cid id, long latency, String muxer, Object streams) {
1819
this.address = address;
1920
this.id = id;
2021
this.latency = latency;
@@ -27,10 +28,20 @@ public static Peer fromJSON(Object json) {
2728
throw new IllegalStateException("Incorrect json for Peer: " + JSONParser.toString(json));
2829
Map m = (Map) json;
2930
Function<String, String> val = key -> (String) m.get(key);
30-
long latency = val.apply("Latency").length() > 0 ? Long.parseLong(val.apply("Latency")) : -1;
31-
return new Peer(new MultiAddress(val.apply("Addr")), Cid.decode(val.apply("Peer")), latency, val.apply("Muxer"), val.apply("Streams"));
31+
Cid peer = decodePeerId(val.apply("Peer"));
32+
long latency = m.containsKey("Latency") ? Long.parseLong(val.apply("Latency")) : -1;
33+
return new Peer(new MultiAddress(val.apply("Addr")), peer, latency, val.apply("Muxer"), val.apply("Streams"));
3234
}
3335

36+
// See https://github.com/Peergos/Peergos/blob/81064fdb2cdf6b6fe126cf6a20d4d40ecd148938/src/peergos/shared/io/ipfs/Cid.java#L148
37+
public static Cid decodePeerId(String peerId) {
38+
if (peerId.startsWith("1")) {
39+
// convert base58 encoded identity multihash to cidV1
40+
Multihash hash = Multihash.deserialize(Base58.decode(peerId));
41+
return new Cid(1, Cid.Codec.Libp2pKey, hash.getType(), hash.getHash());
42+
}
43+
return Cid.decode(peerId);
44+
}
3445
@Override
3546
public String toString() {
3647
return id + "@" + address;

src/test/java/io/ipfs/api/APITest.java

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.*;
88

99
import java.io.*;
10+
import java.nio.charset.StandardCharsets;
1011
import java.nio.file.*;
1112
import java.util.*;
1213
import 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

Comments
 (0)