aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-06-02 06:59:34 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-07 03:40:30 +0800
commit2dfc4680941293ca9f4a55f3ca58b9ee68872754 (patch)
treeb4f06876bfa2e18c455bf13c24a62b3d8787741c /packages/contracts/test
parent98ffe9931d4fd8886955c45c42eb63b33184ddd2 (diff)
downloaddexon-sol-tools-2dfc4680941293ca9f4a55f3ca58b9ee68872754.tar
dexon-sol-tools-2dfc4680941293ca9f4a55f3ca58b9ee68872754.tar.gz
dexon-sol-tools-2dfc4680941293ca9f4a55f3ca58b9ee68872754.tar.bz2
dexon-sol-tools-2dfc4680941293ca9f4a55f3ca58b9ee68872754.tar.lz
dexon-sol-tools-2dfc4680941293ca9f4a55f3ca58b9ee68872754.tar.xz
dexon-sol-tools-2dfc4680941293ca9f4a55f3ca58b9ee68872754.tar.zst
dexon-sol-tools-2dfc4680941293ca9f4a55f3ca58b9ee68872754.zip
Update more tests to pass on Geth
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/ether_token.ts15
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts21
2 files changed, 15 insertions, 21 deletions
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts
index f63d143a6..ee1a0a876 100644
--- a/packages/contracts/test/ether_token.ts
+++ b/packages/contracts/test/ether_token.ts
@@ -6,6 +6,7 @@ import 'make-promises-safe';
import { WETH9Contract } from '../src/contract_wrappers/generated/weth9';
import { artifacts } from '../src/utils/artifacts';
+import { expectInsufficientFunds, expectRevertOrAlwaysFailingTransaction } from '../src/utils/assertions';
import { chaiSetup } from '../src/utils/chai_setup';
import { constants } from '../src/utils/constants';
import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
@@ -41,14 +42,11 @@ describe('EtherToken', () => {
await blockchainLifecycle.revertAsync();
});
describe('deposit', () => {
- // TODO(albrow): AssertionError: expected promise to be rejected with an error including 'ender doesn\'t have enough funds to send tx.' but got 'insufficient funds for gas * price + value'
- it.skip('should throw if caller attempts to deposit more Ether than caller balance', async () => {
+ it('should throw if caller attempts to deposit more Ether than caller balance', async () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
const ethToDeposit = initEthBalance.plus(1);
- return expect(etherToken.deposit.sendTransactionAsync({ value: ethToDeposit })).to.be.rejectedWith(
- "ender doesn't have enough funds to send tx.",
- );
+ return expectInsufficientFunds(etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }));
});
it('should convert deposited Ether to wrapped Ether tokens', async () => {
@@ -73,13 +71,12 @@ describe('EtherToken', () => {
});
describe('withdraw', () => {
- // TODO(albrow): AssertionError: expected promise to be rejected with an error including 'revert' but got 'gas required exceeds allowance or always failing transaction'
- it.skip('should throw if caller attempts to withdraw greater than caller balance', async () => {
+ it('should throw if caller attempts to withdraw greater than caller balance', async () => {
const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
const ethTokensToWithdraw = initEthTokenBalance.plus(1);
- return expect(etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw)).to.be.rejectedWith(
- constants.REVERT,
+ return expectRevertOrAlwaysFailingTransaction(
+ etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw),
);
});
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index 1bf29c7e9..ea20df040 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -53,12 +53,11 @@ describe('UnlimitedAllowanceToken', () => {
await blockchainLifecycle.revertAsync();
});
describe('transfer', () => {
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with true
- it.skip('should throw if owner has insufficient balance', async () => {
+ it('should throw if owner has insufficient balance', async () => {
const ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1);
- return expectRevertOrAlwaysFailingTransaction(
- token.transfer.callAsync(spender, amountToTransfer, { from: owner }),
+ return expect(token.transfer.callAsync(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
+ constants.ERC20_INSUFFICIENT_BALANCE,
);
});
@@ -88,23 +87,21 @@ describe('UnlimitedAllowanceToken', () => {
});
describe('transferFrom', () => {
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with true
- it.skip('should throw if owner has insufficient balance', async () => {
+ it('should throw if owner has insufficient balance', async () => {
const ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1);
await web3Wrapper.awaitTransactionSuccessAsync(
await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expectRevertOrAlwaysFailingTransaction(
+ return expect(
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender,
}),
- );
+ ).to.be.rejectedWith(constants.ERC20_INSUFFICIENT_BALANCE);
});
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with true
- it.skip('should throw if spender has insufficient allowance', async () => {
+ it('should throw if spender has insufficient allowance', async () => {
const ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance;
@@ -112,11 +109,11 @@ describe('UnlimitedAllowanceToken', () => {
const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(isSpenderAllowanceInsufficient).to.be.true();
- return expectRevertOrAlwaysFailingTransaction(
+ return expect(
token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender,
}),
- );
+ ).to.be.rejectedWith(constants.ERC20_INSUFFICIENT_ALLOWANCE);
});
it('should return true on a 0 value transfer', async () => {