From 462c8026befd1bf576facb97887d2f030aeb59fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 16 Oct 2018 16:37:15 +0200 Subject: [PATCH] namesys: allow non /ipfs paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- namesys/base.go | 2 +- test/sharness/t0100-name.sh | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/namesys/base.go b/namesys/base.go index 1906bdf5d..a523a10bf 100644 --- a/namesys/base.go +++ b/namesys/base.go @@ -63,7 +63,7 @@ func resolveAsync(ctx context.Context, r resolver, name string, options opts.Res return } log.Debugf("resolved %s to %s", name, res.value.String()) - if strings.HasPrefix(res.value.String(), "/ipfs/") { + if !strings.HasPrefix(res.value.String(), ipnsPrefix) { outCh <- Result{Path: res.value} break } diff --git a/test/sharness/t0100-name.sh b/test/sharness/t0100-name.sh index 019a5f947..7a23fd196 100755 --- a/test/sharness/t0100-name.sh +++ b/test/sharness/t0100-name.sh @@ -114,6 +114,27 @@ test_expect_success "publish an explicit node ID as key name looks good" ' test_cmp expected_node_id_publish actual_node_id_publish ' +# test IPNS + IPLD +test_expect_success "'ipfs dag put' succeeds" ' + HELLO_HASH="$(echo "\"hello world\"" | ipfs dag put)" && + OBJECT_HASH="$(echo "{\"thing\": {\"/\": \"${HELLO_HASH}\" }}" | ipfs dag put)" +' +test_expect_success "'ipfs name publish --allow-offline /ipld/...' succeeds" ' + PEERID=`ipfs id --format=""` && + test_check_peerid "${PEERID}" && + ipfs name publish --allow-offline "/ipld/$OBJECT_HASH/thing" >publish_out +' +test_expect_success "publish a path looks good" ' + echo "Published to ${PEERID}: /ipld/$OBJECT_HASH/thing" >expected3 && + test_cmp expected3 publish_out +' +test_expect_success "'ipfs name resolve' succeeds" ' + ipfs name resolve "$PEERID" >output +' +test_expect_success "resolve output looks good" ' + printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && + test_cmp expected4 output +' # test publishing nothing