Skip to content

Commit

Permalink
Fix bug in LockedGold.relock wrapper (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
Asa Oines authored and celo-ci-bot-user committed Nov 26, 2019
1 parent 85ad78e commit ab316cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions packages/cli/src/commands/lockedgold/lock.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { newKitFromWeb3 } from '@celo/contractkit'
import { testWithGanache } from '@celo/dev-utils/lib/ganache-test'
import Web3 from 'web3'
import Register from '../account/register'
import Lock from './lock'
import Unlock from './unlock'

process.env.NO_SYNCCHECK = 'true'

testWithGanache('lockedgold:lock cmd', (web3: Web3) => {
test('can lock with pending withdrawals', async () => {
const accounts = await web3.eth.getAccounts()
const account = accounts[0]
const kit = newKitFromWeb3(web3)
const lockedGold = await kit.contracts.getLockedGold()
await Register.run(['--from', account])
await Lock.run(['--from', account, '--value', '100'])
await Unlock.run(['--from', account, '--value', '50'])
await Lock.run(['--from', account, '--value', '75'])
const pendingWithdrawalsTotalValue = await lockedGold.getPendingWithdrawalsTotalValue(account)
expect(pendingWithdrawalsTotalValue.toFixed()).toBe('0')
})
})
2 changes: 1 addition & 1 deletion packages/contractkit/src/wrappers/LockedGold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class LockedGoldWrapper extends BaseWrapper<LockedGold> {
i: number
) => {
const valueToRelock = BigNumber.minimum(pw.value, remainingToRelock)
if (valueToRelock.isZero()) {
if (!valueToRelock.isZero()) {
remainingToRelock = remainingToRelock.minus(valueToRelock)
acc.push(this._relock(i, valueToRelock))
}
Expand Down

0 comments on commit ab316cb

Please sign in to comment.