Skip to content

Commit

Permalink
[skyapi] refs fibercrypto#12 - Add test for the node skycoin api
Browse files Browse the repository at this point in the history
  • Loading branch information
cbermudez97 committed Mar 29, 2019
1 parent 04764c4 commit 11ed2d1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 52 deletions.
23 changes: 17 additions & 6 deletions dev/tester/index.js
Original file line number Diff line number Diff line change
@@ -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);
56 changes: 11 additions & 45 deletions dev/tester/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dev/tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 11ed2d1

Please sign in to comment.