This repository has been archived by the owner on Sep 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34c745f
commit 747e931
Showing
7 changed files
with
373 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import AdminServer from '../src/services/AdminServer' | ||
import CodiusDB from '../src/util/CodiusDB' | ||
import Ildcp from '../src/services/Ildcp' | ||
import BigNumber from 'bignumber.js' | ||
import chai = require('chai') | ||
import * as reduct from 'reduct' | ||
const assert = chai.assert | ||
|
||
describe('AdminServer', () => { | ||
let codiusdb: any | ||
let ildcp: any | ||
let server: any | ||
|
||
beforeEach(async () => { | ||
const deps = reduct() | ||
ildcp = deps(Ildcp) | ||
codiusdb = deps(CodiusDB) | ||
server = deps(AdminServer).getServer() | ||
await ildcp.init() | ||
}) | ||
|
||
describe('/getAllUptime', () => { | ||
|
||
it('should return earnings and pod uptime', async () => { | ||
const request = { | ||
method: 'GET', | ||
url: '/getAllUptime' | ||
} | ||
const response = await server.inject(request) | ||
const res = JSON.parse(response.payload) | ||
assert.isOk(res, 'Returns object') | ||
assert.hasAllKeys(res, ['aggregate_pod_uptime', 'aggregate_earnings']) | ||
assert.strictEqual(res.aggregate_pod_uptime, '0') | ||
assert.isOk(res.aggregate_earnings) | ||
}) | ||
|
||
it('should return zero for no profits', async () => { | ||
const request = { | ||
method: 'GET', | ||
url: '/getAllUptime' | ||
} | ||
const response = await server.inject(request) | ||
const res = JSON.parse(response.payload) | ||
const expectedEarnings = {} | ||
expectedEarnings[ildcp.getAssetCode()] = '0' | ||
assert.deepEqual(res.aggregate_earnings, expectedEarnings) | ||
}) | ||
|
||
it('should return profits', async () => { | ||
await codiusdb.setProfit('USD', 2, new BigNumber(100)) | ||
await codiusdb.setProfit('XRP', 6, new BigNumber(2000000)) | ||
await codiusdb.setProfit('XRP', 9, new BigNumber(3000000000)) | ||
const request = { | ||
method: 'GET', | ||
url: '/getAllUptime' | ||
} | ||
const response = await server.inject(request) | ||
const res = JSON.parse(response.payload) | ||
const expectedEarnings = { | ||
USD: '1', | ||
XRP: '5' | ||
} | ||
expectedEarnings[ildcp.getAssetCode()] = '0' | ||
assert.deepEqual(res.aggregate_earnings, expectedEarnings) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.