From 086ea338276ed10be837af05ed786a1f8292f29b Mon Sep 17 00:00:00 2001 From: Petar Maymounkov Date: Wed, 29 Jul 2020 12:25:00 -0700 Subject: [PATCH 1/3] update libp2p deps --- go.mod | 7 +++---- go.sum | 27 ++++++++++----------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index fa9dc16a0dd..b014d84ebc5 100644 --- a/go.mod +++ b/go.mod @@ -60,10 +60,10 @@ require ( github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c github.com/jbenet/go-temp-err-catcher v0.1.0 github.com/jbenet/goprocess v0.1.4 - github.com/libp2p/go-libp2p v0.9.6 + github.com/libp2p/go-libp2p v0.10.0 github.com/libp2p/go-libp2p-circuit v0.2.3 github.com/libp2p/go-libp2p-connmgr v0.2.4 - github.com/libp2p/go-libp2p-core v0.5.7 + github.com/libp2p/go-libp2p-core v0.6.0 github.com/libp2p/go-libp2p-discovery v0.4.0 github.com/libp2p/go-libp2p-http v0.1.5 github.com/libp2p/go-libp2p-kad-dht v0.8.2 @@ -78,7 +78,7 @@ require ( github.com/libp2p/go-libp2p-record v0.1.3 github.com/libp2p/go-libp2p-routing-helpers v0.2.3 github.com/libp2p/go-libp2p-secio v0.2.2 - github.com/libp2p/go-libp2p-swarm v0.2.6 + github.com/libp2p/go-libp2p-swarm v0.2.8 github.com/libp2p/go-libp2p-testing v0.1.1 github.com/libp2p/go-libp2p-tls v0.1.3 github.com/libp2p/go-libp2p-yamux v0.2.8 @@ -90,7 +90,6 @@ require ( github.com/miekg/dns v1.1.29 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/mr-tron/base58 v1.1.3 - github.com/multiformats/go-base36 v0.1.0 github.com/multiformats/go-multiaddr v0.2.2 github.com/multiformats/go-multiaddr-dns v0.2.0 github.com/multiformats/go-multiaddr-net v0.1.5 diff --git a/go.sum b/go.sum index 6662a335dbc..09d54f5744c 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,6 @@ github.com/Stebalien/go-bitfield v0.0.0-20180330043415-076a62f9ce6e/go.mod h1:3o github.com/Stebalien/go-bitfield v0.0.1 h1:X3kbSSPUaJK60wV2hjOPZwmpljr6VGCqdq4cBLhbQBo= github.com/Stebalien/go-bitfield v0.0.1/go.mod h1:GNjFpasyUVkHMsfEOk8EFLJ9syQ6SI+XWrX9Wf2XH0s= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75 h1:3ILjVyslFbc4jl1w5TWuvvslFD/nDfR2H8tVaMVLrEY= -github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -344,10 +342,6 @@ github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7Na github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8= github.com/ipfs/go-ipfs-cmds v0.2.9 h1:zQTENe9UJrtCb2bOtRoDGjtuo3rQjmuPdPnVlqoBV/M= github.com/ipfs/go-ipfs-cmds v0.2.9/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk= -github.com/ipfs/go-ipfs-config v0.8.0 h1:4Tc7DC3dz4e7VadOjxXxFQGTQ1g7EYZClJ/ih8qOrxE= -github.com/ipfs/go-ipfs-config v0.8.0/go.mod h1:GQUxqb0NfkZmEU92PxqqqLVVFTLpoGGUlBaTyDaAqrE= -github.com/ipfs/go-ipfs-config v0.8.1-0.20200714165010-0b2590596cd4 h1:gD1K9GUACg3QRyjJD5rxTW/dUEYJt2/a98nnCoISSOk= -github.com/ipfs/go-ipfs-config v0.8.1-0.20200714165010-0b2590596cd4/go.mod h1:GQUxqb0NfkZmEU92PxqqqLVVFTLpoGGUlBaTyDaAqrE= github.com/ipfs/go-ipfs-config v0.9.0 h1:qTXJ9CyOyQv1LFJUMysxz8fi6RxxnP9QqcmiobuANvw= github.com/ipfs/go-ipfs-config v0.9.0/go.mod h1:GQUxqb0NfkZmEU92PxqqqLVVFTLpoGGUlBaTyDaAqrE= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= @@ -558,8 +552,8 @@ github.com/libp2p/go-libp2p v0.8.2 h1:gVuk8nZGjnRagJ/mLpBCSJw7bW1yWJrq3EwOk/AC6F github.com/libp2p/go-libp2p v0.8.2/go.mod h1:NQDA/F/qArMHGe0J7sDScaKjW8Jh4y/ozQqBbYJ+BnA= github.com/libp2p/go-libp2p v0.8.3 h1:IFWeNzxkBaNO1N8stN9ayFGdC6RmVuSsKd5bou7qpK0= github.com/libp2p/go-libp2p v0.8.3/go.mod h1:EsH1A+8yoWK+L4iKcbPYu6MPluZ+CHWI9El8cTaefiM= -github.com/libp2p/go-libp2p v0.9.6 h1:sDiuVhuLpWQOjSFmxOJEXVM9RHKIUTKgi8ArSS9nBtE= -github.com/libp2p/go-libp2p v0.9.6/go.mod h1:EA24aHpFs3BscMWvO286AiaKs3a7efQdLo+tbZ2tUSk= +github.com/libp2p/go-libp2p v0.10.0 h1:7ooOvK1wi8eLpyTppy8TeH43UHy5uI75GAHGJxenUi0= +github.com/libp2p/go-libp2p v0.10.0/go.mod h1:yBJNpb+mGJdgrwbKAKrhPU0u3ogyNFTfjJ6bdM+Q/G8= github.com/libp2p/go-libp2p-autonat v0.0.2/go.mod h1:fs71q5Xk+pdnKU014o2iq1RhMs9/PMaG5zXRFNnIIT4= github.com/libp2p/go-libp2p-autonat v0.0.6/go.mod h1:uZneLdOkZHro35xIhpbtTzLlgYturpu4J5+0cZK3MqE= github.com/libp2p/go-libp2p-autonat v0.1.0 h1:aCWAu43Ri4nU0ZPO7NyLzUvvfqd0nE3dX0R/ZGYVgOU= @@ -627,6 +621,8 @@ github.com/libp2p/go-libp2p-core v0.5.6 h1:IxFH4PmtLlLdPf4fF/i129SnK/C+/v8WEX644 github.com/libp2p/go-libp2p-core v0.5.6/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo= github.com/libp2p/go-libp2p-core v0.5.7 h1:QK3xRwFxqd0Xd9bSZL+8yZ8ncZZbl6Zngd/+Y+A6sgQ= github.com/libp2p/go-libp2p-core v0.5.7/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo= +github.com/libp2p/go-libp2p-core v0.6.0 h1:u03qofNYTBN+yVg08PuAKylZogVf0xcTEeM8skGf+ak= +github.com/libp2p/go-libp2p-core v0.6.0/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo= github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= github.com/libp2p/go-libp2p-crypto v0.0.2/go.mod h1:eETI5OUfBnvARGOHrJz2eWNyTUxEGZnBxMcbUjfIj4I= github.com/libp2p/go-libp2p-crypto v0.1.0 h1:k9MFy+o2zGDNGsaoZl0MA3iZ75qXxr9OOoAZF+sD5OQ= @@ -715,7 +711,7 @@ github.com/libp2p/go-libp2p-pubsub v0.3.1 h1:7Hyv2d8BK/x1HGRJTZ8X++VQEP+WqDTSwpU github.com/libp2p/go-libp2p-pubsub v0.3.1/go.mod h1:TxPOBuo1FPdsTjFnv+FGZbNbWYsp74Culx+4ViQpato= github.com/libp2p/go-libp2p-pubsub-router v0.3.0 h1:ghpHApTMXN+aZ+InYvpJa/ckBW4orypzNI0aWQDth3s= github.com/libp2p/go-libp2p-pubsub-router v0.3.0/go.mod h1:6kZb1gGV1yGzXTfyNsi4p+hyt1JnA1OMGHeExTOJR3A= -github.com/libp2p/go-libp2p-quic-transport v0.3.7/go.mod h1:Kr4aDtnfHHNeENn5J+sZIVc+t8HpQn9W6BOxhVGHbgI= +github.com/libp2p/go-libp2p-quic-transport v0.5.0/go.mod h1:IEcuC5MLxvZ5KuHKjRu+dr3LjCT1Be3rcD/4d8JrX8M= github.com/libp2p/go-libp2p-quic-transport v0.7.1 h1:X6Ond9GANspXpgwJlSR9yxcMMD6SLBnGKRtwjBG5awc= github.com/libp2p/go-libp2p-quic-transport v0.7.1/go.mod h1:TD31to4E5exogR/GWHClXCfkktigjAl5rXSt7HoxNvY= github.com/libp2p/go-libp2p-record v0.0.1/go.mod h1:grzqg263Rug/sRex85QrDOLntdFAymLDLm7lxMgU79Q= @@ -747,8 +743,9 @@ github.com/libp2p/go-libp2p-swarm v0.2.3 h1:uVkCb8Blfg7HQ/f30TyHn1g/uCwXsAET7pU0 github.com/libp2p/go-libp2p-swarm v0.2.3/go.mod h1:P2VO/EpxRyDxtChXz/VPVXyTnszHvokHKRhfkEgFKNM= github.com/libp2p/go-libp2p-swarm v0.2.4 h1:94XL76/tFeTdJNcIGugi+1uZo5O/a7y4i21PirwbgZI= github.com/libp2p/go-libp2p-swarm v0.2.4/go.mod h1:/xIpHFPPh3wmSthtxdGbkHZ0OET1h/GGZes8Wku/M5Y= -github.com/libp2p/go-libp2p-swarm v0.2.6 h1:UhMXIa+yCOALQyceENEIStMlbTCzOM6aWo6vw8QW17Q= -github.com/libp2p/go-libp2p-swarm v0.2.6/go.mod h1:F9hrkZjO7dDbcEiYii/fAB1QdpLuU6h1pa4P5VNsEgc= +github.com/libp2p/go-libp2p-swarm v0.2.7/go.mod h1:ZSJ0Q+oq/B1JgfPHJAT2HTall+xYRNYp1xs4S2FBWKA= +github.com/libp2p/go-libp2p-swarm v0.2.8 h1:cIUUvytBzNQmGSjnXFlI6UpoBGsaud82mJPIJVfkDlg= +github.com/libp2p/go-libp2p-swarm v0.2.8/go.mod h1:JQKMGSth4SMqonruY0a8yjlPVIkb0mdNSwckW7OYziM= github.com/libp2p/go-libp2p-testing v0.0.1/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= @@ -867,8 +864,7 @@ github.com/libp2p/go-yamux v1.3.5 h1:ibuz4naPAully0pN6J/kmUARiqLpnDQIzI/8GCOrljg github.com/libp2p/go-yamux v1.3.5/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= github.com/libp2p/go-yamux v1.3.7 h1:v40A1eSPJDIZwz2AvrV3cxpTZEGDP11QJbukmEhYyQI= github.com/libp2p/go-yamux v1.3.7/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= -github.com/lucas-clemente/quic-go v0.15.7 h1:Pu7To5/G9JoP1mwlrcIvfV8ByPBlCzif3MCl8+1W83I= -github.com/lucas-clemente/quic-go v0.15.7/go.mod h1:Myi1OyS0FOjL3not4BxT7KN29bRkcMUV5JVVFLKtDp8= +github.com/lucas-clemente/quic-go v0.16.0/go.mod h1:I0+fcNTdb9eS1ZcjQZbDVPGchJ86chcIxPALn9lEJqE= github.com/lucas-clemente/quic-go v0.17.3 h1:jMX/MmDNCljfisgMmPGUcBJ+zUh9w3d3ia4YJjYS3TM= github.com/lucas-clemente/quic-go v0.17.3/go.mod h1:I0+fcNTdb9eS1ZcjQZbDVPGchJ86chcIxPALn9lEJqE= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= @@ -1114,6 +1110,7 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= @@ -1295,8 +1292,6 @@ golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200519113804-d87ec0cfa476 h1:E7ct1C6/33eOdrGZKMoyntcEvs2dwZnDe30crG5vpYU= -golang.org/x/net v0.0.0-20200519113804-d87ec0cfa476/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1360,8 +1355,6 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From e384b5964a5415a57b2a9e014feb26e8edb4e346 Mon Sep 17 00:00:00 2001 From: Petar Maymounkov Date: Wed, 29 Jul 2020 12:26:14 -0700 Subject: [PATCH 2/3] IPNS format keys in b36cid --- .circleci/config.yml | 2 +- core/commands/keystore.go | 54 +- core/coreapi/key.go | 2 +- core/coreapi/name.go | 2 +- go.mod | 2 +- go.sum | 2 + test/sharness/lib/test-lib.sh | 6 +- test/sharness/t0100-name.sh | 480 ++++++++++-------- .../t0600-issues-and-regressions-online.sh | 2 +- 9 files changed, 315 insertions(+), 237 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 62374e6ee90..db96658cf9f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -175,7 +175,7 @@ jobs: command: | npm init -y npm install ipfs@^0.48.1 - npm install ipfs-interop@^2.0.0 + npm install ipfs-interop@^2.0.1 npm install mocha-circleci-reporter@0.0.3 working_directory: ~/ipfs/go-ipfs/interop - run: diff --git a/core/commands/keystore.go b/core/commands/keystore.go index 9089caf6053..a50ee0b4f3c 100644 --- a/core/commands/keystore.go +++ b/core/commands/keystore.go @@ -104,7 +104,7 @@ var keyGenCmd = &cmds.Command{ if sizefound { opts = append(opts, options.Key.Size(size)) } - if err = verifyFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil { + if err = verifyIDFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil { return err } @@ -128,31 +128,6 @@ var keyGenCmd = &cmds.Command{ Type: KeyOutput{}, } -func verifyFormatLabel(formatLabel string) error { - switch formatLabel { - case "b58mh": - return nil - case "b36cid": - return nil - } - return fmt.Errorf("invalid output format option") -} - -func formatID(id peer.ID, formatLabel string) string { - switch formatLabel { - case "b58mh": - return id.Pretty() - case "b36cid": - if s, err := peer.ToCid(id).StringOfBase(mbase.Base36); err != nil { - panic(err) - } else { - return s - } - default: - panic("unreachable") - } -} - var keyExportCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Export a keypair", @@ -320,7 +295,7 @@ var keyListCmd = &cmds.Command{ cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - if err := verifyFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil { + if err := verifyIDFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil { return err } @@ -437,6 +412,31 @@ var keyRmCmd = &cmds.Command{ Type: KeyOutputList{}, } +func verifyIDFormatLabel(formatLabel string) error { + switch formatLabel { + case "b58mh": + return nil + case "b36cid": + return nil + } + return fmt.Errorf("invalid output format option") +} + +func formatID(id peer.ID, formatLabel string) string { + switch formatLabel { + case "b58mh": + return id.Pretty() + case "b36cid": + if s, err := peer.ToCid(id).StringOfBase(mbase.Base36); err != nil { + panic(err) + } else { + return s + } + default: + panic("unreachable") + } +} + func keyOutputListEncoders() cmds.EncoderFunc { return cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, list *KeyOutputList) error { withID, _ := req.Options["l"].(bool) diff --git a/core/coreapi/key.go b/core/coreapi/key.go index e6fe7b124d1..9b4045ed04a 100644 --- a/core/coreapi/key.go +++ b/core/coreapi/key.go @@ -29,7 +29,7 @@ func (k *key) Name() string { // Path returns the path of the key. func (k *key) Path() path.Path { - return path.New(ipfspath.Join([]string{"/ipns", k.peerID.Pretty()})) + return path.New(ipfspath.Join([]string{"/ipns", coreiface.FormatKeyID(k.peerID)})) } // ID returns key PeerID diff --git a/core/coreapi/name.go b/core/coreapi/name.go index ec653a39434..c9c3dedf36e 100644 --- a/core/coreapi/name.go +++ b/core/coreapi/name.go @@ -76,7 +76,7 @@ func (api *NameAPI) Publish(ctx context.Context, p path.Path, opts ...caopts.Nam } return &ipnsEntry{ - name: pid.Pretty(), + name: coreiface.FormatKeyID(pid), value: p, }, nil } diff --git a/go.mod b/go.mod index b014d84ebc5..c048b909785 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/ipfs/go-path v0.0.7 github.com/ipfs/go-unixfs v0.2.4 github.com/ipfs/go-verifcid v0.0.1 - github.com/ipfs/interface-go-ipfs-core v0.3.0 + github.com/ipfs/interface-go-ipfs-core v0.4.0 github.com/ipld/go-car v0.1.0 github.com/jbenet/go-is-domain v1.0.5 github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c diff --git a/go.sum b/go.sum index 09d54f5744c..e235f313e61 100644 --- a/go.sum +++ b/go.sum @@ -447,6 +447,8 @@ github.com/ipfs/go-verifcid v0.0.1 h1:m2HI7zIuR5TFyQ1b79Da5N9dnnCP1vcu2QqawmWlK2 github.com/ipfs/go-verifcid v0.0.1/go.mod h1:5Hrva5KBeIog4A+UpqlaIU+DEstipcJYQQZc0g37pY0= github.com/ipfs/interface-go-ipfs-core v0.3.0 h1:oZdLLfh256gPGcYPURjivj/lv296GIcr8mUqZUnXOEI= github.com/ipfs/interface-go-ipfs-core v0.3.0/go.mod h1:Tihp8zxGpUeE3Tokr94L6zWZZdkRQvG5TL6i9MuNE+s= +github.com/ipfs/interface-go-ipfs-core v0.4.0 h1:+mUiamyHIwedqP8ZgbCIwpy40oX7QcXUbo4CZOeJVJg= +github.com/ipfs/interface-go-ipfs-core v0.4.0/go.mod h1:UJBcU6iNennuI05amq3FQ7g0JHUkibHFAfhfUIy927o= github.com/ipld/go-car v0.1.0 h1:AaIEA5ITRnFA68uMyuIPYGM2XXllxsu8sNjFJP797us= github.com/ipld/go-car v0.1.0/go.mod h1:RCWzaUh2i4mOEkB3W45Vc+9jnS/M6Qay5ooytiBHl3g= github.com/ipld/go-ipld-prime v0.0.2-0.20191108012745-28a82f04c785 h1:fASnkvtR+SmB2y453RxmDD3Uvd4LonVUgFGk9JoDaZs= diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index c7169717519..f0b7b7cfe29 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -443,9 +443,13 @@ file_size() { $_STAT "$1" } +# len 46: 2048-bit RSA keys, b58mh-encoded +# len 52: ED25519 keys, b58mh-encoded +# len 56: 2048-bit RSA keys, b36cid-encoded +# len 62: ED25519 keys, b36cid-encoded test_check_peerid() { peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") && - test "$peeridlen" = "46" -o "$peeridlen" = "52" -o "$peeridlen" = "62" || { + test "$peeridlen" = "46" -o "$peeridlen" = "52" -o "$peeridlen" = "56" -o "$peeridlen" = "62" || { echo "Bad peerid '$1' with len '$peeridlen'" return 1 } diff --git a/test/sharness/t0100-name.sh b/test/sharness/t0100-name.sh index 10ee52f64ae..f2088ee8220 100755 --- a/test/sharness/t0100-name.sh +++ b/test/sharness/t0100-name.sh @@ -8,209 +8,281 @@ test_description="Test ipfs repo operations" . lib/test-lib.sh -test_init_ipfs - -# test publishing a hash - - -test_expect_success "'ipfs name publish --allow-offline' succeeds" ' - PEERID=`ipfs id --format=""` && - test_check_peerid "${PEERID}" && - ipfs name publish --allow-offline "/ipfs/$HASH_WELCOME_DOCS" >publish_out -' - -test_expect_success "publish output looks good" ' - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected1 && - test_cmp expected1 publish_out -' - -test_expect_success "'ipfs name resolve' succeeds" ' - ipfs name resolve "$PEERID" >output -' - -test_expect_success "resolve output looks good" ' - printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 && - test_cmp expected2 output -' - -# test publishing with -Q option - - -test_expect_success "'ipfs name publish --quieter' succeeds" ' - PEERID=`ipfs id --format=""` && - test_check_peerid "${PEERID}" && - ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out -' - -test_expect_success "pubrmlish --quieter output looks good" ' - echo "${PEERID}" >expected1 && - test_cmp expected1 publish_out -' - -test_expect_success "'ipfs name resolve' succeeds" ' - ipfs name resolve "$PEERID" >output -' - -test_expect_success "resolve output looks good" ' - printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 && - test_cmp expected2 output -' - -# now test with a path - -test_expect_success "'ipfs name publish --allow-offline' succeeds" ' - PEERID=`ipfs id --format=""` && - test_check_peerid "${PEERID}" && - ipfs name publish --allow-offline "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out -' - -test_expect_success "publish a path looks good" ' - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS/help" >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 "/ipfs/%s/help\n" "$HASH_WELCOME_DOCS" >expected4 && - test_cmp expected4 output -' - -test_expect_success "ipfs cat on published content succeeds" ' - ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected && - ipfs cat "/ipns/$PEERID" >actual && - test_cmp expected actual -' - -# publish with an explicit node ID - -test_expect_failure "'ipfs name publish --allow-offline ' succeeds" ' - PEERID=`ipfs id --format=""` && - test_check_peerid "${PEERID}" && - echo ipfs name publish --allow-offline "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" && - ipfs name publish --allow-offline "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish -' - -test_expect_failure "publish with our explicit node ID looks good" ' - echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && - test_cmp expected_node_id_publish actual_node_id_publish -' - -# publish with an explicit node ID as key name - -test_expect_success "generate and verify a new key" ' - NEWID=`ipfs key gen -f=b58mh --type=rsa --size=2048 keyname` && - test_check_peerid "${NEWID}" -' - -test_expect_success "'ipfs name publis --allow-offline --key= ' succeeds" ' - ipfs name publish --allow-offline --key=${NEWID} "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish -' - -test_expect_success "publish an explicit node ID as key name looks good" ' - echo "Published to ${NEWID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && - 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 - -test_expect_success "'ipfs name publish' fails" ' - printf '' | test_expect_code 1 ipfs name publish --allow-offline >publish_out 2>&1 -' - -test_expect_success "publish output has the correct error" ' - grep "argument \"ipfs-path\" is required" publish_out -' - -test_expect_success "'ipfs name publish' fails" ' - printf '' | test_expect_code 1 ipfs name publish -Q --allow-offline >publish_out 2>&1 -' - -test_expect_success "publish output has the correct error" ' - grep "argument \"ipfs-path\" is required" publish_out -' - -test_expect_success "'ipfs name publish --help' succeeds" ' - ipfs name publish --help -' - -# test offline resolve - -test_expect_success "'ipfs name resolve --offline' succeeds" ' - ipfs name resolve --offline "$PEERID" >output -' -test_expect_success "resolve output looks good" ' - printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && - test_cmp expected4 output -' - -test_expect_success "'ipfs name resolve --offline -n' succeeds" ' - ipfs name resolve --offline -n "$PEERID" >output -' -test_expect_success "resolve output looks good" ' - printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && - test_cmp expected4 output -' - -test_launch_ipfs_daemon - -test_expect_success "'ipfs name resolve --offline' succeeds" ' - ipfs name resolve --offline "$PEERID" >output -' -test_expect_success "resolve output looks good" ' - printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && - test_cmp expected4 output -' - -test_expect_success "'ipfs name resolve --offline -n' succeeds" ' - ipfs name resolve --offline -n "$PEERID" >output -' -test_expect_success "resolve output looks good" ' - printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && - test_cmp expected4 output -' - -test_expect_success "empty request to name publish doesn't panic and returns error" ' - curl -X POST "http://$API_ADDR/api/v0/name/publish" > curl_out || true && - grep "argument \"ipfs-path\" is required" curl_out -' - -test_kill_ipfs_daemon - - -# Test daemon in offline mode -test_launch_ipfs_daemon --offline - -test_expect_success "'ipfs name publish' fails offline mode" ' - PEERID=`ipfs id --format=""` && - test_check_peerid "${PEERID}" && - test_expect_code 1 ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" -' - -test_kill_ipfs_daemon +test_name_with_self() { + SELF_ALG=$1 + + test_expect_success "ipfs init (variant self $SELF_ALG)" ' + export IPFS_PATH="$(pwd)/.ipfs" && + case $SELF_ALG in + default) + ipfs init --profile=test > /dev/null + ;; + rsa) + ipfs init --profile=test -a=rsa > /dev/null + ;; + ed25519) + ipfs init --profile=test -a=ed25519 > /dev/null + ;; + esac && + export PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` && + test_check_peerid "${PEERID}" + ' + + # test publishing a hash + + test_expect_success "'ipfs name publish --allow-offline' succeeds" ' + ipfs name publish --allow-offline "/ipfs/$HASH_WELCOME_DOCS" >publish_out + ' + + test_expect_success "publish output looks good" ' + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected1 && + test_cmp expected1 publish_out + ' + + test_expect_success "'ipfs name resolve' succeeds" ' + ipfs name resolve "$PEERID" >output + ' + + test_expect_success "resolve output looks good" ' + printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 && + test_cmp expected2 output + ' + + # test publishing with -Q option + + test_expect_success "'ipfs name publish --quieter' succeeds" ' + ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out + ' + + test_expect_success "publish --quieter output looks good" ' + echo "${PEERID}" >expected1 && + test_cmp expected1 publish_out + ' + + test_expect_success "'ipfs name resolve' succeeds" ' + ipfs name resolve "$PEERID" >output + ' + + test_expect_success "resolve output looks good" ' + printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 && + test_cmp expected2 output + ' + + # now test with a path + + test_expect_success "'ipfs name publish --allow-offline' succeeds" ' + ipfs name publish --allow-offline "/ipfs/$HASH_WELCOME_DOCS/help" >publish_out + ' + + test_expect_success "publish a path looks good" ' + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS/help" >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 "/ipfs/%s/help\n" "$HASH_WELCOME_DOCS" >expected4 && + test_cmp expected4 output + ' + + test_expect_success "ipfs cat on published content succeeds" ' + ipfs cat "/ipfs/$HASH_WELCOME_DOCS/help" >expected && + ipfs cat "/ipns/$PEERID" >actual && + test_cmp expected actual + ' + + # publish with an explicit node ID + + test_expect_failure "'ipfs name publish --allow-offline ' succeeds" ' + echo ipfs name publish --allow-offline "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" && + ipfs name publish --allow-offline "${PEERID}" "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish + ' + + test_expect_failure "publish with our explicit node ID looks good" ' + echo "Published to ${PEERID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && + test_cmp expected_node_id_publish actual_node_id_publish + ' + + # test publishing with B36CID and B58MH resolve to the same B36CID + + test_expect_success "verify self key output" ' + B58MH_ID=`ipfs key list -f=b58mh -l | grep self | cut -d " " -f1` && + B36CID_ID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` && + test_check_peerid "${B58MH_ID}" && + test_check_peerid "${B36CID_ID}" + ' + + test_expect_success "'ipfs name publish --allow-offline --key= ' succeeds" ' + ipfs name publish --allow-offline --key=${B58MH_ID} "/ipfs/$HASH_WELCOME_DOCS" >b58mh_published_id && + ipfs name publish --allow-offline --key=${B36CID_ID} "/ipfs/$HASH_WELCOME_DOCS" >b36cid_published_id + ' + + test_expect_success "publish an explicit node ID as two key in B58MH and B36CID, name looks good" ' + echo "Published to ${B36CID_ID}: /ipfs/$HASH_WELCOME_DOCS" >expected_published_id && + test_cmp expected_published_id b58mh_published_id && + test_cmp expected_published_id b36cid_published_id + ' + + test_expect_success "'ipfs name resolve' succeeds" ' + ipfs name resolve "$B36CID_ID" >output + ' + + test_expect_success "resolve output looks good" ' + printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 && + test_cmp expected2 output + ' + + # 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" ' + 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 (IPNS + IPLD)" ' + printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && + test_cmp expected4 output + ' + + # test publishing nothing + + test_expect_success "'ipfs name publish' fails" ' + printf '' | test_expect_code 1 ipfs name publish --allow-offline >publish_out 2>&1 + ' + + test_expect_success "publish output has the correct error" ' + grep "argument \"ipfs-path\" is required" publish_out + ' + + test_expect_success "'ipfs name publish' fails" ' + printf '' | test_expect_code 1 ipfs name publish -Q --allow-offline >publish_out 2>&1 + ' + + test_expect_success "publish output has the correct error" ' + grep "argument \"ipfs-path\" is required" publish_out + ' + + test_expect_success "'ipfs name publish --help' succeeds" ' + ipfs name publish --help + ' + + # test offline resolve + + test_expect_success "'ipfs name resolve --offline' succeeds" ' + ipfs name resolve --offline "$PEERID" >output + ' + test_expect_success "resolve output looks good (offline resolve)" ' + printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && + test_cmp expected4 output + ' + + test_expect_success "'ipfs name resolve --offline -n' succeeds" ' + ipfs name resolve --offline -n "$PEERID" >output + ' + test_expect_success "resolve output looks good (offline resolve, -n)" ' + printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && + test_cmp expected4 output + ' + + test_launch_ipfs_daemon + + test_expect_success "'ipfs name resolve --offline' succeeds" ' + ipfs name resolve --offline "$PEERID" >output + ' + test_expect_success "resolve output looks good (with daemon)" ' + printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && + test_cmp expected4 output + ' + + test_expect_success "'ipfs name resolve --offline -n' succeeds" ' + ipfs name resolve --offline -n "$PEERID" >output + ' + test_expect_success "resolve output looks good (with daemon, -n)" ' + printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 && + test_cmp expected4 output + ' + + test_expect_success "empty request to name publish doesn't panic and returns error" ' + curl -X POST "http://$API_ADDR/api/v0/name/publish" > curl_out || true && + grep "argument \"ipfs-path\" is required" curl_out + ' + + test_kill_ipfs_daemon + + # Test daemon in offline mode + test_launch_ipfs_daemon --offline + + test_expect_success "'ipfs name publish' fails offline mode" ' + test_expect_code 1 ipfs name publish "/ipfs/$HASH_WELCOME_DOCS" + ' + + test_kill_ipfs_daemon + + test_expect_success "clean up ipfs dir" ' + rm -rf "$IPFS_PATH" + ' +} +test_name_with_self 'default' +test_name_with_self 'rsa' +test_name_with_self 'ed25519' + +test_name_with_key() { + GEN_ALG=$1 + + test_expect_success "ipfs init (key variant $GEN_ALG)" ' + export IPFS_PATH="$(pwd)/.ipfs" && + ipfs init --profile=test > /dev/null + ' + + test_expect_success "'prepare keys" ' + case $GEN_ALG in + rsa) + export KEY=`ipfs key gen -f=b58mh --type=rsa --size=2048 key` && + export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1` + ;; + ed25519_b58) + export KEY=`ipfs key gen -f=b58mh --type=ed25519 key` + export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1` + ;; + ed25519_b36) + export KEY=`ipfs key gen -f=b36cid --type=ed25519 key` + export KEY_B36CID=$KEY + ;; + esac && + test_check_peerid "${KEY}" + ' + + # publish with an explicit node ID as key name + + test_expect_success "'ipfs name publish --allow-offline --key= ' succeeds" ' + ipfs name publish --allow-offline --key=${KEY} "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish + ' + + test_expect_success "publish an explicit node ID as key name looks good" ' + echo "Published to ${KEY_B36CID}: /ipfs/$HASH_WELCOME_DOCS" >expected_node_id_publish && + test_cmp expected_node_id_publish actual_node_id_publish + ' + + # cleanup + test_expect_success "clean up ipfs dir" ' + rm -rf "$IPFS_PATH" + ' +} +test_name_with_key 'rsa' +test_name_with_key 'ed25519_b58' +test_name_with_key 'ed25519_b36' test_done diff --git a/test/sharness/t0600-issues-and-regressions-online.sh b/test/sharness/t0600-issues-and-regressions-online.sh index 947b5610ab0..3343df1208c 100755 --- a/test/sharness/t0600-issues-and-regressions-online.sh +++ b/test/sharness/t0600-issues-and-regressions-online.sh @@ -62,7 +62,7 @@ test_expect_success "ipfs daemon --offline --mount fails - #2995" ' test_launch_ipfs_daemon --offline test_expect_success "'ipfs name resolve' succeeds after ipfs id when daemon offline" ' - PEERID=`ipfs id --format=""` && + PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` && test_check_peerid "${PEERID}" && ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out ' From dff0c47050cb0404d0fefb7def9f8b7799e9ac2e Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 4 Aug 2020 11:28:40 -0400 Subject: [PATCH 3/3] improve keystore sharness tests --- test/sharness/lib/test-lib.sh | 2 +- test/sharness/t0165-keystore.sh | 38 +++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index f0b7b7cfe29..6eac7a2e189 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -465,7 +465,7 @@ test_check_rsa2048_b58mh_peerid() { test_check_ed25519_b58mh_peerid() { peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") && - test "$peeridlen" = "46" || { + test "$peeridlen" = "52" || { echo "Bad ED25519 B58MH peerid '$1' with len '$peeridlen'" return 1 } diff --git a/test/sharness/t0165-keystore.sh b/test/sharness/t0165-keystore.sh index f75c0d5d30f..5f346a3d2b8 100755 --- a/test/sharness/t0165-keystore.sh +++ b/test/sharness/t0165-keystore.sh @@ -12,9 +12,12 @@ test_init_ipfs test_key_cmd() { # test key output format -test_expect_success "create an RSA key and test B58MH multihash output" ' +test_expect_success "create an RSA key and test B58MH/B36CID output formats" ' PEERID=$(ipfs key gen -f=b58mh --type=rsa --size=2048 key_rsa) && -test_check_rsa2048_b58mh_peerid $PEERID +test_check_rsa2048_b58mh_peerid $PEERID && +ipfs key rm key_rsa && +PEERID=$(ipfs key gen -f=b36cid --type=rsa --size=2048 key_rsa) && +test_check_rsa2048_b36cid_peerid $PEERID ' test_expect_success "test RSA key sk export format" ' @@ -23,13 +26,18 @@ test_check_rsa2048_sk key_rsa.key && rm key_rsa.key ' -test_expect_success "test RSA key B36CID multihash format" ' +test_expect_success "test RSA key B58MH/B36CID multihash format" ' +PEERID=$(ipfs key list -f=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) && +test_check_rsa2048_b58mh_peerid $PEERID && PEERID=$(ipfs key list -f=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) && test_check_rsa2048_b36cid_peerid $PEERID && ipfs key rm key_rsa ' -test_expect_success "create an ED25519 key and test multihash output" ' +test_expect_success "create an ED25519 key and test B58MH/B36CID output formats" ' +PEERID=$(ipfs key gen -f=b58mh --type=ed25519 key_ed25519) && +test_check_ed25519_b58mh_peerid $PEERID && +ipfs key rm key_ed25519 && PEERID=$(ipfs key gen -f=b36cid --type=ed25519 key_ed25519) && test_check_ed25519_b36cid_peerid $PEERID ' @@ -40,7 +48,9 @@ test_check_ed25519_sk key_ed25519.key && rm key_ed25519.key ' -test_expect_success "test ED25519 key B36CID multihash format" ' +test_expect_success "test ED25519 key B58MH/B36CID multihash format" ' +PEERID=$(ipfs key list -f=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) && +test_check_ed25519_b58mh_peerid $PEERID && PEERID=$(ipfs key list -f=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) && test_check_ed25519_b36cid_peerid $PEERID && ipfs key rm key_ed25519 @@ -49,12 +59,12 @@ ipfs key rm key_ed25519 test_expect_success "create a new rsa key" ' - rsahash=$(ipfs key gen -f=b58mh generated_rsa_key --type=rsa --size=2048) + rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048) echo $rsahash > rsa_key_id ' test_expect_success "create a new ed25519 key" ' - edhash=$(ipfs key gen -f=b58mh generated_ed25519_key --type=ed25519) + edhash=$(ipfs key gen generated_ed25519_key --type=ed25519) echo $edhash > ed25519_key_id ' @@ -104,18 +114,18 @@ ipfs key rm key_ed25519 echo generated_rsa_key >> list_exp && echo quxel >> list_exp && echo self >> list_exp - ipfs key list -f=b58mh > list_out && + ipfs key list > list_out && test_sort_cmp list_exp list_out ' test_expect_success "key hashes show up in long list output" ' - ipfs key list -f=b58mh -l | grep $edhash > /dev/null && - ipfs key list -f=b58mh -l | grep $rsahash > /dev/null + ipfs key list -l | grep $edhash > /dev/null && + ipfs key list -l | grep $rsahash > /dev/null ' test_expect_success "key list -l contains self key with peerID" ' PeerID="$(ipfs config Identity.PeerID)" - ipfs key list -f=b58mh -l | grep "$PeerID\s\+self" + ipfs key list -l | grep "$PeerID\s\+self" ' test_expect_success "key rm remove a key" ' @@ -123,7 +133,7 @@ ipfs key rm key_ed25519 echo generated_ed25519_key > list_exp && echo quxel >> list_exp && echo self >> list_exp - ipfs key list -f=b58mh > list_out && + ipfs key list > list_out && test_sort_cmp list_exp list_out ' @@ -137,12 +147,12 @@ ipfs key rm key_ed25519 echo fooed > list_exp && echo quxel >> list_exp && echo self >> list_exp - ipfs key list -f=b58mh > list_out && + ipfs key list > list_out && test_sort_cmp list_exp list_out ' test_expect_success "key rename rename key output succeeds" ' - key_content=$(ipfs key gen -f=b58mh key1 --type=rsa --size=2048) && + key_content=$(ipfs key gen key1 --type=rsa --size=2048) && ipfs key rename key1 key2 >rs && echo "Key $key_content renamed to key2" >expect && test_cmp rs expect