From 7ee2ec4843b4cbe466fecd9eb28dc320966abc7b Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 5 Oct 2017 16:54:07 +0300 Subject: [PATCH] namesys/pubsub: pubsub sharness test test/sharness: test for ipns pubsub namesys/pubsub: return boolean indicator on Cancel package.json: remove duplicate entry for go-testutil update gx deps, testutil to 1.1.12 fix jenkins failure: use tabs in t0183-namesys-pubsub t0183: use 4 spaces for tabification License: MIT Signed-off-by: vyzo --- core/bootstrap_test.go | 2 +- core/commands/dht_test.go | 2 +- core/commands/ipnsps.go | 25 +++++- core/mock/mock.go | 2 +- exchange/bitswap/bitswap_test.go | 4 +- exchange/bitswap/decision/bench_test.go | 2 +- exchange/bitswap/decision/engine_test.go | 2 +- .../decision/peer_request_queue_test.go | 2 +- exchange/bitswap/testnet/interface.go | 2 +- exchange/bitswap/testnet/network_test.go | 2 +- exchange/bitswap/testnet/peernet.go | 2 +- exchange/bitswap/testnet/virtual.go | 2 +- exchange/bitswap/testutils.go | 2 +- exchange/reprovide/reprovide_test.go | 2 +- fuse/ipns/ipns_test.go | 2 +- fuse/node/mount_test.go | 2 +- fuse/readonly/ipfs_test.go | 2 +- mfs/repub_test.go | 2 +- namesys/namesys.go | 4 +- namesys/publisher_test.go | 2 +- namesys/pubsub.go | 11 ++- namesys/pubsub_test.go | 8 +- namesys/resolve_test.go | 2 +- package.json | 14 +--- routing/mock/centralized_client.go | 2 +- routing/mock/centralized_server.go | 2 +- routing/mock/centralized_test.go | 2 +- routing/mock/interface.go | 2 +- routing/offline/offline_test.go | 2 +- test/integration/addcat_test.go | 2 +- test/integration/bench_cat_test.go | 2 +- test/integration/bench_test.go | 2 +- test/integration/three_legged_cat_test.go | 2 +- test/sharness/t0183-namesys-pubsub.sh | 80 +++++++++++++++++++ 34 files changed, 150 insertions(+), 50 deletions(-) create mode 100755 test/sharness/t0183-namesys-pubsub.sh diff --git a/core/bootstrap_test.go b/core/bootstrap_test.go index ccbda320c281..920022e73c44 100644 --- a/core/bootstrap_test.go +++ b/core/bootstrap_test.go @@ -6,7 +6,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ) func TestSubsetWhenMaxIsGreaterThanLengthOfSlice(t *testing.T) { diff --git a/core/commands/dht_test.go b/core/commands/dht_test.go index 8cc8a035ca05..ebe309703690 100644 --- a/core/commands/dht_test.go +++ b/core/commands/dht_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/ipfs/go-ipfs/namesys" - tu "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + tu "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ) func TestKeyTranslation(t *testing.T) { diff --git a/core/commands/ipnsps.go b/core/commands/ipnsps.go index 57cdac0ffe8e..f1c087df9aca 100644 --- a/core/commands/ipnsps.go +++ b/core/commands/ipnsps.go @@ -16,6 +16,10 @@ type ipnsPubsubState struct { Enabled bool } +type ipnsPubsubCancel struct { + Canceled bool +} + // IpnsPubsubCmd is the subcommand that allows us to manage the IPNS pubsub system var IpnsPubsubCmd = &cmds.Command{ Helptext: cmds.HelpText{ @@ -121,9 +125,28 @@ var ipnspsCancelCmd = &cmds.Command{ return } - psr.Cancel(req.Arguments()[0]) + ok = psr.Cancel(req.Arguments()[0]) + res.SetOutput(&ipnsPubsubCancel{ok}) }, Arguments: []cmds.Argument{ cmds.StringArg("name", true, false, "Name to cancel the subscription for."), }, + Type: ipnsPubsubCancel{}, + Marshalers: cmds.MarshalerMap{ + cmds.Text: func(res cmds.Response) (io.Reader, error) { + output, ok := res.Output().(*ipnsPubsubCancel) + if !ok { + return nil, u.ErrCast() + } + + var state string + if output.Canceled { + state = "canceled" + } else { + state = "no subscription" + } + + return strings.NewReader(state + "\n"), nil + }, + }, } diff --git a/core/mock/mock.go b/core/mock/mock.go index adba01ba8bf3..b50fef490f1c 100644 --- a/core/mock/mock.go +++ b/core/mock/mock.go @@ -9,7 +9,7 @@ import ( "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" metrics "gx/ipfs/QmQbh3Rb7KM37As3vkHYnEFnzkVXNCP8EYGtHz6g2fXk14/go-libp2p-metrics" diff --git a/exchange/bitswap/bitswap_test.go b/exchange/bitswap/bitswap_test.go index d68858eefb66..8cf0317cd282 100644 --- a/exchange/bitswap/bitswap_test.go +++ b/exchange/bitswap/bitswap_test.go @@ -14,14 +14,14 @@ import ( tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet" mockrouting "github.com/ipfs/go-ipfs/routing/mock" delay "github.com/ipfs/go-ipfs/thirdparty/delay" + travis "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil/ci/travis" blocks "gx/ipfs/QmSn9Td7xgxm9EV7iEjTckpUWmWApggzPxu7eFGWkkpwin/go-block-format" - travis "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil/ci/travis" detectrace "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-detect-race" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" p2ptestutil "gx/ipfs/QmQGX417WoxKxDJeHqouMEmmH4G1RCENNSzkZYHrXy3Xb3/go-libp2p-netutil" - tu "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + tu "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ) // FIXME the tests are really sensitive to the network delay. fix them to work diff --git a/exchange/bitswap/decision/bench_test.go b/exchange/bitswap/decision/bench_test.go index cb005e6ef9ae..5ffb2aa3cf94 100644 --- a/exchange/bitswap/decision/bench_test.go +++ b/exchange/bitswap/decision/bench_test.go @@ -7,8 +7,8 @@ import ( "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" u "gx/ipfs/QmSU6eubNdhXjFBJBSksTp8kv8YRub8mGAPv8tVJHmL2EU/go-ipfs-util" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ) diff --git a/exchange/bitswap/decision/engine_test.go b/exchange/bitswap/decision/engine_test.go index 512548cf5511..ac35c7122c57 100644 --- a/exchange/bitswap/decision/engine_test.go +++ b/exchange/bitswap/decision/engine_test.go @@ -11,10 +11,10 @@ import ( context "context" blockstore "github.com/ipfs/go-ipfs/blocks/blockstore" message "github.com/ipfs/go-ipfs/exchange/bitswap/message" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" blocks "gx/ipfs/QmSn9Td7xgxm9EV7iEjTckpUWmWApggzPxu7eFGWkkpwin/go-block-format" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" dssync "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore/sync" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ) diff --git a/exchange/bitswap/decision/peer_request_queue_test.go b/exchange/bitswap/decision/peer_request_queue_test.go index 718da14e49ae..32efd763bd0b 100644 --- a/exchange/bitswap/decision/peer_request_queue_test.go +++ b/exchange/bitswap/decision/peer_request_queue_test.go @@ -10,8 +10,8 @@ import ( "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" u "gx/ipfs/QmSU6eubNdhXjFBJBSksTp8kv8YRub8mGAPv8tVJHmL2EU/go-ipfs-util" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" ) func TestPushPop(t *testing.T) { diff --git a/exchange/bitswap/testnet/interface.go b/exchange/bitswap/testnet/interface.go index c83b2e78edda..69cdbf0cc97d 100644 --- a/exchange/bitswap/testnet/interface.go +++ b/exchange/bitswap/testnet/interface.go @@ -2,7 +2,7 @@ package bitswap import ( bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ) diff --git a/exchange/bitswap/testnet/network_test.go b/exchange/bitswap/testnet/network_test.go index 8032485526cc..7fcecc909491 100644 --- a/exchange/bitswap/testnet/network_test.go +++ b/exchange/bitswap/testnet/network_test.go @@ -9,8 +9,8 @@ import ( bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network" mockrouting "github.com/ipfs/go-ipfs/routing/mock" delay "github.com/ipfs/go-ipfs/thirdparty/delay" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" blocks "gx/ipfs/QmSn9Td7xgxm9EV7iEjTckpUWmWApggzPxu7eFGWkkpwin/go-block-format" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ) diff --git a/exchange/bitswap/testnet/peernet.go b/exchange/bitswap/testnet/peernet.go index 32438508a131..861491a0dc95 100644 --- a/exchange/bitswap/testnet/peernet.go +++ b/exchange/bitswap/testnet/peernet.go @@ -4,8 +4,8 @@ import ( "context" bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network" mockrouting "github.com/ipfs/go-ipfs/routing/mock" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" mockpeernet "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/net/mock" ) diff --git a/exchange/bitswap/testnet/virtual.go b/exchange/bitswap/testnet/virtual.go index 217d43552850..939a22b7be5e 100644 --- a/exchange/bitswap/testnet/virtual.go +++ b/exchange/bitswap/testnet/virtual.go @@ -11,8 +11,8 @@ import ( cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" routing "gx/ipfs/QmPR2JzfKd9poHx9XBhzoFeBBC31ZM3W5iUPKJZWyaoZZm/go-libp2p-routing" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ifconnmgr "gx/ipfs/QmYkCrTwivapqdB3JbwvwvxymseahVkcm46ThRMAA24zCr/go-libp2p-interface-connmgr" ) diff --git a/exchange/bitswap/testutils.go b/exchange/bitswap/testutils.go index ca7b9a60b568..cc35e70ee2c3 100644 --- a/exchange/bitswap/testutils.go +++ b/exchange/bitswap/testutils.go @@ -8,7 +8,7 @@ import ( tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet" datastore2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" delay "github.com/ipfs/go-ipfs/thirdparty/delay" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" p2ptestutil "gx/ipfs/QmQGX417WoxKxDJeHqouMEmmH4G1RCENNSzkZYHrXy3Xb3/go-libp2p-netutil" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" diff --git a/exchange/reprovide/reprovide_test.go b/exchange/reprovide/reprovide_test.go index ab4ed4afe6a3..c55756161611 100644 --- a/exchange/reprovide/reprovide_test.go +++ b/exchange/reprovide/reprovide_test.go @@ -7,10 +7,10 @@ import ( blockstore "github.com/ipfs/go-ipfs/blocks/blockstore" mock "github.com/ipfs/go-ipfs/routing/mock" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" blocks "gx/ipfs/QmSn9Td7xgxm9EV7iEjTckpUWmWApggzPxu7eFGWkkpwin/go-block-format" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" dssync "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore/sync" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" . "github.com/ipfs/go-ipfs/exchange/reprovide" ) diff --git a/fuse/ipns/ipns_test.go b/fuse/ipns/ipns_test.go index e86317136747..66f227fa5f7b 100644 --- a/fuse/ipns/ipns_test.go +++ b/fuse/ipns/ipns_test.go @@ -15,7 +15,7 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" offroute "github.com/ipfs/go-ipfs/routing/offline" - ci "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil/ci" + ci "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil/ci" racedet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-detect-race" diff --git a/fuse/node/mount_test.go b/fuse/node/mount_test.go index 3e7583612f18..ee0f88472644 100644 --- a/fuse/node/mount_test.go +++ b/fuse/node/mount_test.go @@ -15,7 +15,7 @@ import ( mount "github.com/ipfs/go-ipfs/fuse/mount" namesys "github.com/ipfs/go-ipfs/namesys" offroute "github.com/ipfs/go-ipfs/routing/offline" - ci "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil/ci" + ci "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil/ci" ) func maybeSkipFuseTests(t *testing.T) { diff --git a/fuse/readonly/ipfs_test.go b/fuse/readonly/ipfs_test.go index 160ad3259bc4..490893c4ff91 100644 --- a/fuse/readonly/ipfs_test.go +++ b/fuse/readonly/ipfs_test.go @@ -20,7 +20,7 @@ import ( chunk "github.com/ipfs/go-ipfs/importer/chunk" dag "github.com/ipfs/go-ipfs/merkledag" uio "github.com/ipfs/go-ipfs/unixfs/io" - ci "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil/ci" + ci "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil/ci" node "gx/ipfs/QmPN7cwmpcc4DWXb4KTB9dNAJgjuPY69h3npsMfhRrQL9c/go-ipld-format" u "gx/ipfs/QmSU6eubNdhXjFBJBSksTp8kv8YRub8mGAPv8tVJHmL2EU/go-ipfs-util" diff --git a/mfs/repub_test.go b/mfs/repub_test.go index 1c21bd793f86..2dd199e8f90c 100644 --- a/mfs/repub_test.go +++ b/mfs/repub_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - ci "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil/ci" + ci "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil/ci" "context" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" diff --git a/namesys/namesys.go b/namesys/namesys.go index 0c82d055b29c..644c9f55dc57 100644 --- a/namesys/namesys.go +++ b/namesys/namesys.go @@ -11,12 +11,12 @@ import ( routing "gx/ipfs/QmPR2JzfKd9poHx9XBhzoFeBBC31ZM3W5iUPKJZWyaoZZm/go-libp2p-routing" mh "gx/ipfs/QmU9a9NV9RdPNwZQDYd5uKsm6N6LJLSvLbywDDYFbaaC6P/go-multihash" + floodsub "gx/ipfs/QmUUSLfvihARhCxxgnjW4hmycJpPvzNu12Aaz6JWVdfnLg/go-libp2p-floodsub" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" - p2phost "gx/ipfs/QmaSxYRuMq4pkpBBG2CYaRrPx2z7NmMVEs34b9g61biQA6/go-libp2p-host" - floodsub "gx/ipfs/Qmdnza7rLi7CMNNwNhNkcs9piX5sf6rxE8FrCsPzYtUEUi/floodsub" + p2phost "gx/ipfs/Qmc1XhrFEiSeBNn3mpfg6gEuYCt5im2gYmNVmncsvmpeAk/go-libp2p-host" ) // mpns (a multi-protocol NameSystem) implements generic IPFS naming. diff --git a/namesys/publisher_test.go b/namesys/publisher_test.go index 3149b3e48578..28635f3bfc9b 100644 --- a/namesys/publisher_test.go +++ b/namesys/publisher_test.go @@ -10,9 +10,9 @@ import ( mockrouting "github.com/ipfs/go-ipfs/routing/mock" dshelp "github.com/ipfs/go-ipfs/thirdparty/ds-help" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" dssync "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore/sync" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" ma "gx/ipfs/QmXY77cVe7rVRQXZZQRioukUM7aRW3BTcAgJe12MCtb3Ji/go-multiaddr" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" diff --git a/namesys/pubsub.go b/namesys/pubsub.go index 26744d1ff79b..c3e9f8fa9ebb 100644 --- a/namesys/pubsub.go +++ b/namesys/pubsub.go @@ -17,15 +17,15 @@ import ( pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" u "gx/ipfs/QmSU6eubNdhXjFBJBSksTp8kv8YRub8mGAPv8tVJHmL2EU/go-ipfs-util" mh "gx/ipfs/QmU9a9NV9RdPNwZQDYd5uKsm6N6LJLSvLbywDDYFbaaC6P/go-multihash" + floodsub "gx/ipfs/QmUUSLfvihARhCxxgnjW4hmycJpPvzNu12Aaz6JWVdfnLg/go-libp2p-floodsub" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" dssync "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore/sync" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" - p2phost "gx/ipfs/QmaSxYRuMq4pkpBBG2CYaRrPx2z7NmMVEs34b9g61biQA6/go-libp2p-host" record "gx/ipfs/QmbxkgUceEcuSZ4ZdBA3x74VUDSSYjHYmmeEqkjxbtZ6Jg/go-libp2p-record" dhtpb "gx/ipfs/QmbxkgUceEcuSZ4ZdBA3x74VUDSSYjHYmmeEqkjxbtZ6Jg/go-libp2p-record/pb" - floodsub "gx/ipfs/Qmdnza7rLi7CMNNwNhNkcs9piX5sf6rxE8FrCsPzYtUEUi/floodsub" + p2phost "gx/ipfs/Qmc1XhrFEiSeBNn3mpfg6gEuYCt5im2gYmNVmncsvmpeAk/go-libp2p-host" ) // PubsubPublisher is a publisher that distributes IPNS records through pubsub @@ -289,8 +289,9 @@ func (r *PubsubResolver) GetSubscriptions() []string { return res } -// Cancel cancels a topic subscription -func (r *PubsubResolver) Cancel(name string) { +// Cancel cancels a topic subscription; returns true if an active +// subscription was canceled +func (r *PubsubResolver) Cancel(name string) bool { r.mx.Lock() defer r.mx.Unlock() @@ -299,6 +300,8 @@ func (r *PubsubResolver) Cancel(name string) { sub.Cancel() delete(r.subs, name) } + + return ok } func (r *PubsubResolver) handleSubscription(sub *floodsub.Subscription, name string, pubk ci.PubKey, cancel func()) { diff --git a/namesys/pubsub_test.go b/namesys/pubsub_test.go index 5784c0a37423..82e074763fd1 100644 --- a/namesys/pubsub_test.go +++ b/namesys/pubsub_test.go @@ -10,15 +10,15 @@ import ( mockrouting "github.com/ipfs/go-ipfs/routing/mock" routing "gx/ipfs/QmPR2JzfKd9poHx9XBhzoFeBBC31ZM3W5iUPKJZWyaoZZm/go-libp2p-routing" - bhost "gx/ipfs/QmPZRCaYeNLMo5GfcRS2rv9ZxVuXXt6MFg9dWLmgsdXKCw/go-libp2p-blankhost" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" + netutil "gx/ipfs/QmQGX417WoxKxDJeHqouMEmmH4G1RCENNSzkZYHrXy3Xb3/go-libp2p-netutil" testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" + bhost "gx/ipfs/QmQkeGXc9ZuQ5upVFpd2EjKvgw9aVh1BbtAgvNGVcebmmX/go-libp2p-blankhost" + floodsub "gx/ipfs/QmUUSLfvihARhCxxgnjW4hmycJpPvzNu12Aaz6JWVdfnLg/go-libp2p-floodsub" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" - p2phost "gx/ipfs/QmaSxYRuMq4pkpBBG2CYaRrPx2z7NmMVEs34b9g61biQA6/go-libp2p-host" - floodsub "gx/ipfs/Qmdnza7rLi7CMNNwNhNkcs9piX5sf6rxE8FrCsPzYtUEUi/floodsub" - netutil "gx/ipfs/QmdzuGp4a9pahgXuBeReHdYGUzdVX3FUCwfmWVo5mQfkTi/go-libp2p-netutil" + p2phost "gx/ipfs/Qmc1XhrFEiSeBNn3mpfg6gEuYCt5im2gYmNVmncsvmpeAk/go-libp2p-host" ) func newNetHost(ctx context.Context, t *testing.T) p2phost.Host { diff --git a/namesys/resolve_test.go b/namesys/resolve_test.go index bb30a243a4fc..7503ad3d7e90 100644 --- a/namesys/resolve_test.go +++ b/namesys/resolve_test.go @@ -8,7 +8,7 @@ import ( path "github.com/ipfs/go-ipfs/path" mockrouting "github.com/ipfs/go-ipfs/routing/mock" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" dssync "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore/sync" diff --git a/package.json b/package.json index 8efdaafff3ef..a3fb08055077 100644 --- a/package.json +++ b/package.json @@ -466,9 +466,9 @@ }, { "author": "whyrusleeping", - "hash": "QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx", + "hash": "QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK", "name": "go-testutil", - "version": "1.1.11" + "version": "1.1.12" }, { "author": "whyrusleeping", @@ -490,15 +490,9 @@ }, { "author": "whyrusleeping", - "hash": "QmPZRCaYeNLMo5GfcRS2rv9ZxVuXXt6MFg9dWLmgsdXKCw", + "hash": "QmQkeGXc9ZuQ5upVFpd2EjKvgw9aVh1BbtAgvNGVcebmmX", "name": "go-libp2p-blankhost", - "version": "0.2.0" - }, - { - "author": "whyrusleeping", - "hash": "QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK", - "name": "go-testutil", - "version": "1.1.12" + "version": "0.2.1" } ], "gxVersion": "0.10.0", diff --git a/routing/mock/centralized_client.go b/routing/mock/centralized_client.go index 0614d2d77ce6..407629299fde 100644 --- a/routing/mock/centralized_client.go +++ b/routing/mock/centralized_client.go @@ -6,7 +6,7 @@ import ( "time" dshelp "github.com/ipfs/go-ipfs/thirdparty/ds-help" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" routing "gx/ipfs/QmPR2JzfKd9poHx9XBhzoFeBBC31ZM3W5iUPKJZWyaoZZm/go-libp2p-routing" diff --git a/routing/mock/centralized_server.go b/routing/mock/centralized_server.go index c5f90d1d88a7..02929a4cf6dd 100644 --- a/routing/mock/centralized_server.go +++ b/routing/mock/centralized_server.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" diff --git a/routing/mock/centralized_test.go b/routing/mock/centralized_test.go index 84f9fcbcffc5..9ecba1181d6e 100644 --- a/routing/mock/centralized_test.go +++ b/routing/mock/centralized_test.go @@ -6,7 +6,7 @@ import ( "time" delay "github.com/ipfs/go-ipfs/thirdparty/delay" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" diff --git a/routing/mock/interface.go b/routing/mock/interface.go index 3522c6f38f76..5dcbbd21db31 100644 --- a/routing/mock/interface.go +++ b/routing/mock/interface.go @@ -8,7 +8,7 @@ import ( "context" delay "github.com/ipfs/go-ipfs/thirdparty/delay" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" routing "gx/ipfs/QmPR2JzfKd9poHx9XBhzoFeBBC31ZM3W5iUPKJZWyaoZZm/go-libp2p-routing" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" diff --git a/routing/offline/offline_test.go b/routing/offline/offline_test.go index 9f5b3f0b238c..f922f399c6eb 100644 --- a/routing/offline/offline_test.go +++ b/routing/offline/offline_test.go @@ -3,8 +3,8 @@ package offline import ( "bytes" "context" + "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ds "gx/ipfs/QmVSase1JP7cq9QkPT46oNwdp9pT6kBkG3oqS14y3QcZjG/go-datastore" - "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" "testing" ) diff --git a/test/integration/addcat_test.go b/test/integration/addcat_test.go index 90fb177c65ac..760fdbfa5fea 100644 --- a/test/integration/addcat_test.go +++ b/test/integration/addcat_test.go @@ -18,8 +18,8 @@ import ( mock "github.com/ipfs/go-ipfs/core/mock" "github.com/ipfs/go-ipfs/thirdparty/unit" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" mocknet "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/net/mock" ) diff --git a/test/integration/bench_cat_test.go b/test/integration/bench_cat_test.go index 796194cead6e..a516fd93b01f 100644 --- a/test/integration/bench_cat_test.go +++ b/test/integration/bench_cat_test.go @@ -13,7 +13,7 @@ import ( mock "github.com/ipfs/go-ipfs/core/mock" "github.com/ipfs/go-ipfs/thirdparty/unit" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" mocknet "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/net/mock" ) diff --git a/test/integration/bench_test.go b/test/integration/bench_test.go index 92dcbd72e2ff..ce63ee01f286 100644 --- a/test/integration/bench_test.go +++ b/test/integration/bench_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/ipfs/go-ipfs/thirdparty/unit" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" ) func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B) { diff --git a/test/integration/three_legged_cat_test.go b/test/integration/three_legged_cat_test.go index 4fcf770e200f..62b01b3c7820 100644 --- a/test/integration/three_legged_cat_test.go +++ b/test/integration/three_legged_cat_test.go @@ -15,7 +15,7 @@ import ( mock "github.com/ipfs/go-ipfs/core/mock" "github.com/ipfs/go-ipfs/thirdparty/unit" pstore "gx/ipfs/QmPgDWmTmuzvP7QE5zwo1TmjbJme9pmZHNujB2453jkCTr/go-libp2p-peerstore" - testutil "gx/ipfs/QmWRCn8vruNAzHx8i6SAXinuheRitKEGu8c7m26stKvsYx/go-testutil" + testutil "gx/ipfs/QmQgLZP9haZheimMHqqAjJh2LhRmNfEoZDfbtkpeMhi9xK/go-testutil" mocknet "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/net/mock" ) diff --git a/test/sharness/t0183-namesys-pubsub.sh b/test/sharness/t0183-namesys-pubsub.sh new file mode 100755 index 000000000000..130e4c500b23 --- /dev/null +++ b/test/sharness/t0183-namesys-pubsub.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +test_description="Test IPNS pubsub" + +. lib/test-lib.sh + +# start iptb + wait for peering +NUM_NODES=5 +test_expect_success 'init iptb' ' + iptb init -n $NUM_NODES --bootstrap=none --port=0 +' + +startup_cluster $NUM_NODES --enable-namesys-pubsub + +test_expect_success 'peer ids' ' + PEERID_0=$(iptb get id 0) +' + +test_expect_success 'check namesys pubsub state' ' + echo enabled > expected && + ipfsi 0 name pubsub state > state0 && + ipfsi 1 name pubsub state > state1 && + ipfsi 2 name pubsub state > state2 && + test_cmp expected state0 && + test_cmp expected state1 && + test_cmp expected state2 +' + +test_expect_success 'subscribe nodes to the publisher topic' ' + ipfsi 1 name resolve /ipns/$PEERID_0 && + ipfsi 2 name resolve /ipns/$PEERID_0 +' + +test_expect_success 'check subscriptions' ' + echo /ipns/$PEERID_0 > expected && + ipfsi 1 name pubsub subs > subs1 && + ipfsi 2 name pubsub subs > subs2 && + test_cmp expected subs1 && + test_cmp expected subs2 +' + +test_expect_success 'add an obect on publisher node' ' + echo "ipns is super fun" > file && + HASH_FILE=$(ipfsi 0 add -q file) +' + +test_expect_success 'publish that object as an ipns entry' ' + ipfsi 0 name publish $HASH_FILE +' + +test_expect_success 'wait for the flood' ' + sleep 1 +' + +test_expect_success 'resolve name in subscriber nodes' ' + echo "/ipfs/$HASH_FILE" > expected && + ipfsi 1 name resolve /ipns/$PEERID_0 > name1 && + ipfsi 2 name resolve /ipns/$PEERID_0 > name2 && + test_cmp expected name1 && + test_cmp expected name2 +' + +test_expect_success 'cancel subscriptions to the publisher topic' ' + ipfsi 1 name pubsub cancel /ipns/$PEERID_0 && + ipfsi 2 name pubsub cancel /ipns/$PEERID_0 +' + +test_expect_success 'check subscriptions' ' + echo -n "" > expected && + ipfsi 1 name pubsub subs > subs1 && + ipfsi 2 name pubsub subs > subs2 && + test_cmp expected subs1 && + test_cmp expected subs2 +' + +test_expect_success "shut down iptb" ' + iptb stop +' + +test_done