Skip to content

Commit

Permalink
added setapiurl
Browse files Browse the repository at this point in the history
  • Loading branch information
SloRunner committed Sep 17, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent a982d33 commit a50044f
Showing 2 changed files with 27 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -50,15 +50,6 @@ module.exports = class Ethermine {
}
})
}
getServersHistory(callback){
browser(this.apiurl + '/servers/history', { json: true }, function(error, res, body) {
if (!error && res.statusCode == 200) {
callback(false, body)
} else {
callback(true, "")
}
})
}
getMinerDashboard(miner, callback){
if (!miner) {
throw new Error("No miner specified");
@@ -174,4 +165,13 @@ module.exports = class Ethermine {
}
})
}
setAPIurl(url = 'https://api.ethermine.org', callback){
let validapi = ['https://api.ethermine.org', 'https://api-zcash.flypool.org', 'https://api-ycash.flypool.org', 'https://api-etc.ethermine.org', 'https://api-beam.flypool.org', 'https://api-ravencoin.flypool.org'];
if (url in validapi) {
this.apiurl = url;
callback(true, 'API URL set to: ' + url);
}else{
callback(true, 'API not supported');
}
}
}
18 changes: 18 additions & 0 deletions tests/general.js
Original file line number Diff line number Diff line change
@@ -144,3 +144,21 @@ describe('getWorkerCurrentStats() test', function () {
})
});
});

describe('setAPIurl() test', function() {
it('changes the api endpoint based on whitelist', function(){
ethermine.setAPIurl('https://api-zcash.flypool.org', function(err, data){
expect(err).to.be.equal(false);
expect(data).to.be.a('string')
})
})
})

describe('setAPIurl() test', function() {
it('changes the api endpoint based on whitelist, not whitelisted domain', function(){
ethermine.setAPIurl('https://example.com', function(err, data){
expect(err).to.be.equal(false);
expect(data).to.be.a('string')
})
})
})

0 comments on commit a50044f

Please sign in to comment.