Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

make the config API spec compliant #340

Closed
wants to merge 3 commits into from
Closed

make the config API spec compliant #340

wants to merge 3 commits into from

Conversation

daviddias
Copy link
Member

No description provided.

@dignifiedquire
Copy link
Member

missing promisify

@daviddias
Copy link
Member Author

promisify is there now :)

if (err) {
return callback(err)
}
const keys = key.split('.')
Copy link
Member

@dignifiedquire dignifiedquire Jul 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to replace this with https://lodash.com/docs#get available standalone: https://www.npmjs.com/package/lodash.get

@@ -26,7 +26,7 @@ describe('bitswap', () => {
beforeEach((done) => {
ipfs = new IPFS(require('../../utils/repo-path'))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently, this node never goes .goOnline

@daviddias
Copy link
Member Author

@dignifiedquire while revisiting this PR (applying the CR), I found something weird.

All tests pass with exception of the ones that spawn nodes for bitswap

  core
    --both
      bitswap
        connections
          fetches a remote block
Swarm listening on /ip4/127.0.0.1/tcp/9990/ws
Swarm listening on /ip4/127.0.0.1/tcp/9999
            1) 2 peers
Swarm listening on /ip4/127.0.0.1/tcp/9990/ws
Swarm listening on /ip4/127.0.0.1/tcp/9999
            2) 3 peers

I'm still debugging this, it fails on the node.id call, although all the other node.id pass.

But what is really weird is seeing that all the bitswap tests pass, even if the nodes don't get connected amongst themselves

@daviddias
Copy link
Member Author

> ipfs@0.14.3 test:node:core /Users/ground-control/code/js-ipfs
> TEST=core npm run test:node


> ipfs@0.14.3 test:node /Users/ground-control/code/js-ipfs
> gulp test:node

[15:54:23] Using gulpfile ~/code/js-ipfs/gulpfile.js
[15:54:23] Starting 'test:node'...
[15:54:23] Starting 'libnode:start'...
Starting at /tmp/ipfs-test-298170
Starting at /tmp/ipfs-test-860676
Starting at /tmp/ipfs-test-895221
Swarm listening on /ip4/127.0.0.1/tcp/20013/ws
Swarm listening on /ip4/127.0.0.1/tcp/10013
API is listening on: http://127.0.0.1:31013
Gateway (readonly) is listening on: http://127.0.0.1:32013
Swarm listening on /ip4/127.0.0.1/tcp/20007/ws
Swarm listening on /ip4/127.0.0.1/tcp/10007
API is listening on: http://127.0.0.1:31007
Gateway (readonly) is listening on: http://127.0.0.1:32007
Swarm listening on /ip4/127.0.0.1/tcp/20008/ws
Swarm listening on /ip4/127.0.0.1/tcp/10008
API is listening on: http://127.0.0.1:31008
Gateway (readonly) is listening on: http://127.0.0.1:32008
[15:54:28] Finished 'libnode:start' after 4.69 s
[15:54:28] Starting 'test:node:before'...
[15:54:28] Finished 'test:node:before' after 5.85 μs
[15:54:28] Starting 'mocha'...


  core
    --both
      bitswap
        connections
          fetches a remote block
Swarm listening on /ip4/127.0.0.1/tcp/9990/ws
Swarm listening on /ip4/127.0.0.1/tcp/9999
{ [Error: [object Object]] code: undefined }

            1) 2 peers
Swarm listening on /ip4/127.0.0.1/tcp/9990/ws
Swarm listening on /ip4/127.0.0.1/tcp/9999
{ [Error: [object Object]] code: undefined }

            2) 3 peers
          fetches a remote file
            - 2 peers
        commands
          wantlist

            ✓ throws if offline
Swarm listening on /ip4/127.0.0.1/tcp/9990/ws
Swarm listening on /ip4/127.0.0.1/tcp/9999

            ✓ returns an array of wanted blocks
            stat

              ✓ throws if offline
Swarm listening on /ip4/127.0.0.1/tcp/9990/ws
Swarm listening on /ip4/127.0.0.1/tcp/9999

              ✓ returns the stats
            unwant

              ✓ throws if offline
      block

        ✓ get

        ✓ put

        ✓ rm

        ✓ stat
      bootstrap

        ✓ get bootstrap list

        ✓ add a peer to the bootstrap list

        ✓ remove a peer from the bootstrap list
      .config
        callback API
          .get

            ✓ retrieve the whole config

            ✓ retrieve a value through a key

            ✓ retrieve a value through a nested key

            ✓ fail on non valid key

            ✓ fail on non existent key
          .set

            ✓ set a new key

            ✓ set an already existing key

            ✓ set a JSON object

            ✓ fail on non valid key

            ✓ fail on non valid value
          .replace
            - replace the whole config
            - replace to empty config
        promise API
          .get

            ✓ retrieve the whole config
          .set

            ✓ set a new key
      .files
        callback API
          .add

            ✓ stream (208ms)

            ✓ buffer as tuple (206ms)

            ✓ buffer (201ms)

            ✓ BIG buffer (419ms)

            ✓ add a nested dir as array (208ms)
            .createAddStream

              ✓ stream of valid files and dirs (313ms)
          .cat

            ✓ with a base58 string encoded multihash

            ✓ with a multihash

            ✓ streams a large file (296ms)
        promise API
          .add

            ✓ buffer (203ms)
          .cat

            ✓ with a base58 multihash encoded string

            ✓ errors on invalid key

            ✓ with a multihash
        .get

          ✓ with a base58 encoded multihash

          ✓ with a multihash

          ✓ large file (285ms)

          ✓ directory
          promise

            ✓ with a base58 encoded string

            ✓ errors on invalid key
      id

        ✓ get id
      init

        ✓ basic (1673ms)

        ✓ set # of bits in key
      .object
        callback API
          .new

            ✓ no layout
          .put

            ✓ of object

            ✓ of json encoded buffer

            ✓ of protobuf encoded buffer

            ✓ of buffer treated as Data field

            ✓ of DAGNode

            ✓ fails if String is passed

            ✓ DAGNode with some DAGLinks
          .get

            ✓ with multihash

            ✓ with multihash (+ links)

            ✓ with multihash base58 encoded

            ✓ with multihash base58 encoded toString
          .data

            ✓ with multihash

            ✓ with multihash base58 encoded

            ✓ with multihash base58 encoded toString
          .links

            ✓ object.links with multihash

            ✓ with multihash (+ links)

            ✓ with multihash base58 encoded

            ✓ with multihash base58 encoded toString
          .stat

            ✓ with multihash

            ✓ with multihash (+ Links)

            ✓ with multihash base58 encoded

            ✓ with multihash base58 encoded toString
          .patch

            ✓ .addLink

            ✓ .rmLink

            ✓ .appendData

            ✓ .setData
        promise API

          ✓ object.new

          ✓ object.put

          ✓ object.get

          ✓ object.data

          ✓ object.stat

          ✓ object.links
          object.patch

            ✓ .addLink

            ✓ .rmLink

            ✓ .appendData

            ✓ .setData
      version

        ✓ get version
    --node only
      init (Node.js specific)

        ✓ init docs are written (1220ms)

        ✓ empty repo
      swarm

        ✓ create 2 temporary nodes (4470ms)

        ✓ get each peer addr
Swarm listening on /ip4/127.0.0.1/tcp/20002/ws
Swarm listening on /ip4/127.0.0.1/tcp/10002
Swarm listening on /ip4/127.0.0.1/tcp/20003/ws
Swarm listening on /ip4/127.0.0.1/tcp/10003

        ✓ start 2 nodes

        ✓ libp2p.swarm.connect nodeA to nodeB (523ms)

        ✓ libp2p.swarm.peers on nodeA and nodeB match each other

        ✓ libp2p.swarm.localAddrs

        ✓ libp2p.swarm.disconnect nodeB from nodeA (507ms)

        ✓ stop (2006ms)


  94 passing (16s)
  3 pending
  2 failing

  1) core --both bitswap connections fetches a remote block 2 peers:
     Uncaught AssertionError: expected [Error: [object Object]] to not exist
      at test/core/both/test-bitswap.js:54:27
      at node_modules/ipfs-api/src/api/id.js:12:9
      at node_modules/ipfs-api/src/request-api.js:46:9
      at finish (node_modules/ipfs-api/node_modules/wreck/lib/index.js:360:16)
      at wrapped (node_modules/hoek/lib/index.js:871:20)
      at onReaderFinish (node_modules/ipfs-api/node_modules/wreck/lib/index.js:406:16)
      at finishMaybe (_stream_writable.js:468:14)
      at endWritable (_stream_writable.js:478:3)
      at Writable.end (_stream_writable.js:443:5)
      at IncomingMessage.onend (_stream_readable.js:490:10)
      at endReadableNT (_stream_readable.js:905:12)

  2) core --both bitswap connections fetches a remote block 3 peers:
     Uncaught AssertionError: expected [Error: [object Object]] to not exist
      at test/core/both/test-bitswap.js:54:27
      at node_modules/ipfs-api/src/api/id.js:12:9
      at node_modules/ipfs-api/src/request-api.js:46:9
      at finish (node_modules/ipfs-api/node_modules/wreck/lib/index.js:360:16)
      at wrapped (node_modules/hoek/lib/index.js:871:20)
      at onReaderFinish (node_modules/ipfs-api/node_modules/wreck/lib/index.js:406:16)
      at finishMaybe (_stream_writable.js:468:14)
      at afterWrite (_stream_writable.js:347:3)



[15:54:45] 'mocha' errored after 17 s
[15:54:45] Error in plugin 'gulp-spawn-mocha'
Message:
    Mocha exited with code 2

@@ -50,6 +50,7 @@
"interface-ipfs-core": "^0.6.0",
"left-pad": "^1.1.1",
"lodash": "^4.14.1",
"mocha": "^2.5.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty for catching that :)

@daviddias
Copy link
Member Author

…API (.replace) and make necessary changes to make it all work again
@daviddias
Copy link
Member Author

daviddias commented Aug 20, 2016

Figured out how to go around it, pushed the code in this branch to #420

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants