Skip to content

Commit

Permalink
improving approval test
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrzn committed Aug 30, 2020
1 parent 2f59022 commit fdfce3d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/arc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
Address,
Arc,
Plugin,
REDEEMER_CONTRACT_VERSIONS
REDEEMER_CONTRACT_VERSIONS,
Token
} from '../src/index'
import {
fromWei,
Expand Down Expand Up @@ -322,8 +323,18 @@ it('arc.approveToken should return tx with status one', async () => {
const arc = await newArc()
const addresses = getTestAddresses()
const tokenAddress = addresses.dao.DAOToken
const account = '0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1'
const approval = await arc.approveTokens(tokenAddress, account, new BN(1)).send();
const spender = '0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1'
const amount = toWei('31415')
const approval = await arc.approveTokens(tokenAddress, spender, amount).send();
expect(approval.transactionHash).toBeDefined();
expect(approval.receipt!.status).toEqual(1);
const token = new Token(arc, tokenAddress);
const signer = (arc.web3 as JsonRpcProvider).getSigner(arc.defaultAccount as any)
const allowances: Array<BN> = []
const lastAllowance = () => allowances[allowances.length - 1]
await token.allowance(await signer.getAddress(), spender).subscribe(
(next: any) => allowances.push(next)
)
await waitUntilTrue(() => allowances.length > 0 && lastAllowance().gte(amount))
expect(lastAllowance()).toMatchObject(amount)
})

0 comments on commit fdfce3d

Please sign in to comment.