{"action":"created","comment":{"url":"https://api.github.com/repos/ripple/ripple-lib/pulls/comments/46991732","id":46991732,"diff_hunk":"@@ -0,0 +1,143 @@\n+/* eslint-disable max-nested-callbacks */\n+'use strict';\n+const assert = require('assert-diff');\n+const _ = require('lodash');\n+const jayson = require('jayson');\n+\n+const createHTTPServer = require('../../src/index').createHTTPServer;\n+\n+const apiFixtures = require('../fixtures');\n+const apiRequests = apiFixtures.requests;\n+const apiResponses = apiFixtures.responses;\n+\n+const fixtures = require('./fixtures');\n+\n+const TIMEOUT = 20000;   // how long before each test case times out\n+\n+const apiOptions = {\n+  server: 'wss://s1.ripple.com'\n+};\n+\n+const httpPort = 3000;\n+\n+function createClient() {\n+  return jayson.client.http({port: httpPort, hostname: 'localhost'});\n+}\n+\n+const address = 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59';\n+\n+function makePositionalParams(params) {\n+  return params.map(value => value[_.keys(value)[0]]);\n+}\n+\n+function makeNamedParams(params) {\n+  return _.reduce(params, _.assign, {});\n+}\n+\n+function random() {\n+  return _.fill(Array(16), 0);\n+}\n+\n+describe('http server integration tests', function() {\n+  this.timeout(TIMEOUT);\n+\n+  let server = null;\n+  let client = null;\n+\n+  function createTestInternal(testName, methodName, testFunc, id, params) {\n+    it(testName, function() {\n+      return new Promise((resolve, reject) => {\n+        client.request(methodName, params, id, (err, result) => {\n+          if (err) {\n+            return reject(err);\n+          }\n+          testFunc(result);\n+          resolve();\n+        });\n+      });\n+    });\n+  }\n+\n+  function createTest(name, testFunc, id, params) {\n+    createTestInternal(name + ' - positional params', name,\n+      testFunc, id, makePositionalParams(params));\n+    createTestInternal(name + ' - named params', name,\n+      testFunc, id, makeNamedParams(params));\n+  }\n+\n+  beforeEach(function(done) {\n+    server = createHTTPServer(apiOptions, httpPort);\n+    server.start().then(() => {\n+      this.client = createClient();\n+      client = this.client;\n+      done();\n+    }).catch(done);\n+  });\n+\n+  afterEach(function(done) {\n+    server.stop().then(done, done);\n+  });\n+\n+\n+  createTest('getLedgerVersion', (result) => {\n+    assert(_.isNumber(result.result));\n+  }, '001', []);","path":"test/integration/http-integration-test.js","position":84,"original_position":84,"commit_id":"298b7dcb72c98ad0f36eded5478cba917724d04a","original_commit_id":"298b7dcb72c98ad0f36eded5478cba917724d04a","user":{"login":"clark800","id":1238722,"avatar_url":"https://avatars.githubusercontent.com/u/1238722?v=3","gravatar_id":"","url":"https://api.github.com/users/clark800","html_url":"https://github.com/clark800","followers_url":"https://api.github.com/users/clark800/followers","following_url":"https://api.github.com/users/clark800/following{/other_user}","gists_url":"https://api.github.com/users/clark800/gists{/gist_id}","starred_url":"https://api.github.com/users/clark800/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clark800/subscriptions","organizations_url":"https://api.github.com/users/clark800/orgs","repos_url":"https://api.github.com/users/clark800/repos","events_url":"https://api.github.com/users/clark800/events{/privacy}","received_events_url":"https://api.github.com/users/clark800/received_events","type":"User","site_admin":false},"body":"How about using a property on the test suite to store an incrementing counter for the request ID?","created_at":"2015-12-08T18:23:09Z","updated_at":"2015-12-08T18:23:09Z","html_url":"https://github.com/ripple/ripple-lib/pull/663#discussion_r46991732","pull_request_url":"https://api.github.com/repos/ripple/ripple-lib/pulls/663","_links":{"self":{"href":"https://api.github.com/repos/ripple/ripple-lib/pulls/comments/46991732"},"html":{"href":"https://github.com/ripple/ripple-lib/pull/663#discussion_r46991732"},"pull_request":{"href":"https://api.github.com/repos/ripple/ripple-lib/pulls/663"}}},"pull_request":{"url":"https://api.github.com/repos/ripple/ripple-lib/pulls/663","id":52615684,"html_url":"https://github.com/ripple/ripple-lib/pull/663","diff_url":"https://github.com/ripple/ripple-lib/pull/663.diff","patch_url":"https://github.com/ripple/ripple-lib/pull/663.patch","issue_url":"https://api.github.com/repos/ripple/ripple-lib/issues/663","number":663,"state":"open","locked":false,"title":"http server example","user":{"login":"darkdarkdragon","id":2035357,"avatar_url":"https://avatars.githubusercontent.com/u/2035357?v=3","gravatar_id":"","url":"https://api.github.com/users/darkdarkdragon","html_url":"https://github.com/darkdarkdragon","followers_url":"https://api.github.com/users/darkdarkdragon/followers","following_url":"https://api.github.com/users/darkdarkdragon/following{/other_user}","gists_url":"https://api.github.com/users/darkdarkdragon/gists{/gist_id}","starred_url":"https://api.github.com/users/darkdarkdragon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkdarkdragon/subscriptions","organizations_url":"https://api.github.com/users/darkdarkdragon/orgs","repos_url":"https://api.github.com/users/darkdarkdragon/repos","events_url":"https://api.github.com/users/darkdarkdragon/events{/privacy}","received_events_url":"https://api.github.com/users/darkdarkdragon/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-04T00:47:01Z","updated_at":"2015-12-08T18:23:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed3304d34a5bc53e9c0aa0b547b2f816f9deb94c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ripple/ripple-lib/pulls/663/commits","review_comments_url":"https://api.github.com/repos/ripple/ripple-lib/pulls/663/comments","review_comment_url":"https://api.github.com/repos/ripple/ripple-lib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ripple/ripple-lib/issues/663/comments","statuses_url":"https://api.github.com/repos/ripple/ripple-lib/statuses/298b7dcb72c98ad0f36eded5478cba917724d04a","head":{"label":"darkdarkdragon:develop-http-server","ref":"develop-http-server","sha":"298b7dcb72c98ad0f36eded5478cba917724d04a","user":{"login":"darkdarkdragon","id":2035357,"avatar_url":"https://avatars.githubusercontent.com/u/2035357?v=3","gravatar_id":"","url":"https://api.github.com/users/darkdarkdragon","html_url":"https://github.com/darkdarkdragon","followers_url":"https://api.github.com/users/darkdarkdragon/followers","following_url":"https://api.github.com/users/darkdarkdragon/following{/other_user}","gists_url":"https://api.github.com/users/darkdarkdragon/gists{/gist_id}","starred_url":"https://api.github.com/users/darkdarkdragon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkdarkdragon/subscriptions","organizations_url":"https://api.github.com/users/darkdarkdragon/orgs","repos_url":"https://api.github.com/users/darkdarkdragon/repos","events_url":"https://api.github.com/users/darkdarkdragon/events{/privacy}","received_events_url":"https://api.github.com/users/darkdarkdragon/received_events","type":"User","site_admin":false},"repo":{"id":29372989,"name":"ripple-lib","full_name":"darkdarkdragon/ripple-lib","owner":{"login":"darkdarkdragon","id":2035357,"avatar_url":"https://avatars.githubusercontent.com/u/2035357?v=3","gravatar_id":"","url":"https://api.github.com/users/darkdarkdragon","html_url":"https://github.com/darkdarkdragon","followers_url":"https://api.github.com/users/darkdarkdragon/followers","following_url":"https://api.github.com/users/darkdarkdragon/following{/other_user}","gists_url":"https://api.github.com/users/darkdarkdragon/gists{/gist_id}","starred_url":"https://api.github.com/users/darkdarkdragon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkdarkdragon/subscriptions","organizations_url":"https://api.github.com/users/darkdarkdragon/orgs","repos_url":"https://api.github.com/users/darkdarkdragon/repos","events_url":"https://api.github.com/users/darkdarkdragon/events{/privacy}","received_events_url":"https://api.github.com/users/darkdarkdragon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/darkdarkdragon/ripple-lib","description":"A JavaScript API for interacting with Ripple in Node.js and the browser","fork":true,"url":"https://api.github.com/repos/darkdarkdragon/ripple-lib","forks_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/forks","keys_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/teams","hooks_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/hooks","issue_events_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/issues/events{/number}","events_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/events","assignees_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/assignees{/user}","branches_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/branches{/branch}","tags_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/tags","blobs_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/git/refs{/sha}","trees_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/statuses/{sha}","languages_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/languages","stargazers_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/stargazers","contributors_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/contributors","subscribers_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/subscribers","subscription_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/subscription","commits_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/commits{/sha}","git_commits_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/git/commits{/sha}","comments_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/comments{/number}","issue_comment_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/issues/comments{/number}","contents_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/contents/{+path}","compare_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/merges","archive_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/downloads","issues_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/issues{/number}","pulls_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/pulls{/number}","milestones_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/milestones{/number}","notifications_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/labels{/name}","releases_url":"https://api.github.com/repos/darkdarkdragon/ripple-lib/releases{/id}","created_at":"2015-01-16T23:42:55Z","updated_at":"2015-04-23T21:59:17Z","pushed_at":"2015-12-08T05:08:51Z","git_url":"git://github.com/darkdarkdragon/ripple-lib.git","ssh_url":"git@github.com:darkdarkdragon/ripple-lib.git","clone_url":"https://github.com/darkdarkdragon/ripple-lib.git","svn_url":"https://github.com/darkdarkdragon/ripple-lib","homepage":"","size":12934,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ripple:develop","ref":"develop","sha":"20b647dfbf9d9235db6c2a85a825964c895ad9c0","user":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"repo":{"id":9681561,"name":"ripple-lib","full_name":"ripple/ripple-lib","owner":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ripple/ripple-lib","description":"A JavaScript API for interacting with Ripple in Node.js and the browser","fork":false,"url":"https://api.github.com/repos/ripple/ripple-lib","forks_url":"https://api.github.com/repos/ripple/ripple-lib/forks","keys_url":"https://api.github.com/repos/ripple/ripple-lib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ripple/ripple-lib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ripple/ripple-lib/teams","hooks_url":"https://api.github.com/repos/ripple/ripple-lib/hooks","issue_events_url":"https://api.github.com/repos/ripple/ripple-lib/issues/events{/number}","events_url":"https://api.github.com/repos/ripple/ripple-lib/events","assignees_url":"https://api.github.com/repos/ripple/ripple-lib/assignees{/user}","branches_url":"https://api.github.com/repos/ripple/ripple-lib/branches{/branch}","tags_url":"https://api.github.com/repos/ripple/ripple-lib/tags","blobs_url":"https://api.github.com/repos/ripple/ripple-lib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ripple/ripple-lib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ripple/ripple-lib/git/refs{/sha}","trees_url":"https://api.github.com/repos/ripple/ripple-lib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ripple/ripple-lib/statuses/{sha}","languages_url":"https://api.github.com/repos/ripple/ripple-lib/languages","stargazers_url":"https://api.github.com/repos/ripple/ripple-lib/stargazers","contributors_url":"https://api.github.com/repos/ripple/ripple-lib/contributors","subscribers_url":"https://api.github.com/repos/ripple/ripple-lib/subscribers","subscription_url":"https://api.github.com/repos/ripple/ripple-lib/subscription","commits_url":"https://api.github.com/repos/ripple/ripple-lib/commits{/sha}","git_commits_url":"https://api.github.com/repos/ripple/ripple-lib/git/commits{/sha}","comments_url":"https://api.github.com/repos/ripple/ripple-lib/comments{/number}","issue_comment_url":"https://api.github.com/repos/ripple/ripple-lib/issues/comments{/number}","contents_url":"https://api.github.com/repos/ripple/ripple-lib/contents/{+path}","compare_url":"https://api.github.com/repos/ripple/ripple-lib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ripple/ripple-lib/merges","archive_url":"https://api.github.com/repos/ripple/ripple-lib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ripple/ripple-lib/downloads","issues_url":"https://api.github.com/repos/ripple/ripple-lib/issues{/number}","pulls_url":"https://api.github.com/repos/ripple/ripple-lib/pulls{/number}","milestones_url":"https://api.github.com/repos/ripple/ripple-lib/milestones{/number}","notifications_url":"https://api.github.com/repos/ripple/ripple-lib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ripple/ripple-lib/labels{/name}","releases_url":"https://api.github.com/repos/ripple/ripple-lib/releases{/id}","created_at":"2013-04-25T21:17:19Z","updated_at":"2015-12-06T11:43:51Z","pushed_at":"2015-12-08T05:08:52Z","git_url":"git://github.com/ripple/ripple-lib.git","ssh_url":"git@github.com:ripple/ripple-lib.git","clone_url":"https://github.com/ripple/ripple-lib.git","svn_url":"https://github.com/ripple/ripple-lib","homepage":"","size":13565,"stargazers_count":429,"watchers_count":429,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":162,"mirror_url":null,"open_issues_count":1,"forks":162,"open_issues":1,"watchers":429,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ripple/ripple-lib/pulls/663"},"html":{"href":"https://github.com/ripple/ripple-lib/pull/663"},"issue":{"href":"https://api.github.com/repos/ripple/ripple-lib/issues/663"},"comments":{"href":"https://api.github.com/repos/ripple/ripple-lib/issues/663/comments"},"review_comments":{"href":"https://api.github.com/repos/ripple/ripple-lib/pulls/663/comments"},"review_comment":{"href":"https://api.github.com/repos/ripple/ripple-lib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ripple/ripple-lib/pulls/663/commits"},"statuses":{"href":"https://api.github.com/repos/ripple/ripple-lib/statuses/298b7dcb72c98ad0f36eded5478cba917724d04a"}}}}