Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
add test for user's staked balance
Browse files Browse the repository at this point in the history
  • Loading branch information
b-pmcg committed Jul 8, 2021
1 parent 46979fd commit b8c55a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/dai-plugin-governance/src/VoteDelegateService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LocalService } from '@makerdao/services-core';
import VoteDelegate from './VoteDelegate';
import BigNumber from 'bignumber.js';
import { MKR, VOTE_DELEGATE_FACTORY, ZERO_ADDRESS } from './utils/constants';
import { fromBuffer, getCurrency } from './utils/helpers';
import voteDelegateAbi from '../contracts/abis/VoteDelegate.json';
Expand Down Expand Up @@ -68,7 +69,11 @@ export default class VoteDelegateService extends LocalService {
}

async getStakedBalanceForAddress(delegateAddress, address) {
return await this._getStakedBalanceForAddress(delegateAddress, address);
const bal = await this._getStakedBalanceForAddress(
delegateAddress,
address
);
return new BigNumber(bal).shiftedBy(-18);
}

async getAllDelegates() {
Expand Down
10 changes: 10 additions & 0 deletions packages/dai-plugin-governance/test/VoteDelegateService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ test('user can lock MKR with a delegate', async () => {
expect(postLockDeposits.toNumber()).toBe(amountToLock);
});

test("can check a user's delegated stake", async () => {
const stakedAmt = 3;
const deposits = await vds.getStakedBalanceForAddress(
delegateContractAddress,
maker.currentAccount().address
);

expect(deposits.toNumber()).toBe(stakedAmt);
});

test('delegate can cast an executive vote and retrieve voted on addresses from slate', async () => {
maker.useAccountWithAddress(delegateAddress);

Expand Down

0 comments on commit b8c55a3

Please sign in to comment.