Skip to content

Commit

Permalink
fix: fishManager e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpy committed Jun 18, 2020
1 parent 8313573 commit c2219b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -25,6 +25,7 @@ before_script:
- npm run ganache:test &
- npm run wait
- npm run start:withmain
- npm run simulate:interest #required for fishManager.test.js
- popd

script:
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -43,7 +43,7 @@
"homepage": "https://gooddollar.org",
"dependencies": {
"@babel/polyfill": "^7.4.4",
"@gooddollar/goodcontracts": "^2.0.0-beta.1",
"@gooddollar/goodcontracts": "^2.0.0-beta.2",
"@sendgrid/mail": "^6.4.0",
"apidoc": "^0.17.7",
"apidoc-markdown": "^0.2.1",
Expand Down
14 changes: 7 additions & 7 deletions src/server/blockchain/__tests__/fishManager.test.js
Expand Up @@ -13,29 +13,29 @@ describe('fishManager', () => {
await AdminWallet.ready
})

test(`fishManager get next day should be in the future`, async () => {
test(`fishManager get next day should be in the future (need to run script simulateInterestDays.js in goodcontracts)`, async () => {
const nextDay = await fishManager.getNextDay()
expect(nextDay.isAfter()).toBeTruthy()
})

test(`fishManager should find UBICalculated days`, async () => {
test(`fishManager should find UBICalculated days (need to run script simulateInterestDays.js in goodcontracts)`, async () => {
const { searchStartDay, searchEndDay, maxInactiveDays } = await fishManager.getUBICalculatedDays()
expect(maxInactiveDays).toBeGreaterThan(0)
expect(searchStartDay.returnValues.blockNumber.toNumber()).toBeGreaterThan(0)
expect(searchEndDay.returnValues.blockNumber.toNumber()).toBeGreaterThan(
searchStartDay.returnValues.blockNumber.toNumber()
)
expect(searchStartDay.returnValues.day.toNumber()).toEqual(1)
expect(searchEndDay.returnValues.day.toNumber()).toEqual(2)
expect(searchStartDay.returnValues.day.toNumber()).toBeGreaterThan(1)
expect(searchEndDay.returnValues.day.toNumber()).toEqual(searchStartDay.returnValues.day.toNumber() + 1)
})

test(`fishManager should find inactive accounts in interval`, async () => {
test(`fishManager should find inactive accounts in interval (need to run script simulateInterestDays.js in goodcontracts)`, async () => {
const inactiveAcounts = await fishManager.getInactiveAccounts()
expect(inactiveAcounts.length).toEqual(1)
expect(inactiveAcounts[0].length).toEqual(42) //eth address length
})

test(`fishManager should fish account and return next run time`, async () => {
test(`fishManager should fish account and return next run time (need to run script simulateInterestDays.js in goodcontracts)`, async () => {
const { result, cronTime, fishers } = await fishManager.run()
expect(result).toBeTruthy() //success
expect(cronTime.isAfter()).toBeTruthy() //crontime in future
Expand All @@ -49,6 +49,6 @@ describe('fishManager', () => {
)
)
const dailyUbi = await fishManager.ubiContract.methods.dailyUbi.call().then(_ => _.toNumber())
balances.forEach(b => expect(b).toEqual(dailyUbi)) //fisher balance should have the daily claim
balances.forEach(b => expect(b).toBeGreaterThanOrEqual(dailyUbi)) //fisher balance should have the daily claim
})
})

0 comments on commit c2219b7

Please sign in to comment.