From 11ed2d17098a83aec199f195bc921f0219241829 Mon Sep 17 00:00:00 2001 From: cbermudez97 Date: Fri, 29 Mar 2019 16:00:03 -0400 Subject: [PATCH] [skyapi] refs #12 - Add test for the node skycoin api --- dev/tester/index.js | 23 +++++++++++---- dev/tester/package-lock.json | 56 +++++++----------------------------- dev/tester/package.json | 3 +- 3 files changed, 30 insertions(+), 52 deletions(-) diff --git a/dev/tester/index.js b/dev/tester/index.js index 9c275ee..64a9e36 100644 --- a/dev/tester/index.js +++ b/dev/tester/index.js @@ -1,21 +1,32 @@ "use strict"; // Set BASEPATH -const localBasePath = 'http://127.0.0.1:6420'; const developBasePath = 'https://staging.node.skycoin.net'; const prodBasePath = 'https://node.skycoin.net'; // AXIOS const testAxios = function (basePath) { - const skyapi_axios = require("libsky-axios"); //Load the Axios API client - let api_axios_config = new skyapi_axios.Configuration(); //Create a default configuration class + const skyapi_axios = require("libsky-axios"); // Load the Axios API client + let api_axios_config = new skyapi_axios.Configuration(); // Create a default configuration class let api_axios = new skyapi_axios.DefaultApi(api_axios_config, basePath); // Create the API instance - // Make a petition to version of skycoin node + // Make a petition of the version to the skycoin node api_axios.version().then(result => { - console.log(`Response from skyapi_axios\n${basePath}: ${JSON.stringify(result.data)}`); //Print the response data field + console.log(`Response from skycoin node in ${basePath} using axios client: ${JSON.stringify(result.data)}`); //Print the response data field + }); +}; + +// NODE +const testNode = function (basePath) { + const skyapi_node = require("libsky-node"); // Load the Node API client + let api_node = new skyapi_node.DefaultApi(basePath); // Create the API instance + // Make a petition of the version to the skycoin node + api_node.version().then(result => { + console.log(`Response from skycoin node in ${basePath} using node client: ${JSON.stringify(result.body)}`); //Print the response body field }); }; -// testAxios(localBasePath); testAxios(developBasePath); testAxios(prodBasePath); + +testNode(developBasePath); +testNode(prodBasePath); diff --git a/dev/tester/package-lock.json b/dev/tester/package-lock.json index ad409ee..6d0a80a 100644 --- a/dev/tester/package-lock.json +++ b/dev/tester/package-lock.json @@ -9,51 +9,17 @@ "dev": true, "requires": { "axios": "^0.18.0" - }, - "dependencies": { - "@types/node": { - "version": "8.10.45", - "bundled": true - }, - "axios": { - "version": "0.18.0", - "bundled": true, - "dev": true, - "requires": { - "follow-redirects": "^1.3.0", - "is-buffer": "^1.1.5" - } - }, - "debug": { - "version": "3.2.6", - "bundled": true, - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "follow-redirects": { - "version": "1.7.0", - "bundled": true, - "dev": true, - "requires": { - "debug": "^3.2.6" - } - }, - "is-buffer": { - "version": "1.1.6", - "bundled": true, - "dev": true - }, - "ms": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "typescript": { - "version": "2.9.2", - "bundled": true - } + } + }, + "libsky-node": { + "version": "file:../lib/skyapi/typescript-node", + "dev": true, + "requires": { + "@types/bluebird": "*", + "@types/request": "*", + "bluebird": "^3.5.0", + "request": "^2.81.0", + "rewire": "^3.0.2" } } } diff --git a/dev/tester/package.json b/dev/tester/package.json index b8061b1..bf8b333 100644 --- a/dev/tester/package.json +++ b/dev/tester/package.json @@ -9,6 +9,7 @@ }, "dependencies": {}, "devDependencies": { - "libsky-axios": "file:../lib/skyapi/typescript-axios" + "libsky-axios": "file:../lib/skyapi/typescript-axios", + "libsky-node": "file:../lib/skyapi/typescript-node" } }