aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/unlimited_allowance_token.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/test/unlimited_allowance_token.ts')
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts26
1 files changed, 20 insertions, 6 deletions
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index 7f4fef987..34d2ba33b 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -44,6 +44,14 @@ describe('UnlimitedAllowanceToken', () => {
await blockchainLifecycle.revertAsync();
});
describe('transfer', () => {
+ it('should throw if owner has insufficient balance', async () => {
+ const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = ownerBalance.plus(1);
+ return expect(token.transfer.call(spender, amountToTransfer, { from: owner })).to.be.rejectedWith(
+ constants.REVERT,
+ );
+ });
+
it('should transfer balance from sender to receiver', async () => {
const receiver = spender;
const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
@@ -67,15 +75,18 @@ describe('UnlimitedAllowanceToken', () => {
});
describe('transferFrom', () => {
- it('should return false if owner has insufficient balance', async () => {
+ it('should throw if owner has insufficient balance', async () => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance.plus(1);
await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
- expect(didReturnTrue).to.be.false();
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
- it('should return false if spender has insufficient allowance', async () => {
+ it('should throw if spender has insufficient allowance', async () => {
const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
const amountToTransfer = ownerBalance;
@@ -83,8 +94,11 @@ describe('UnlimitedAllowanceToken', () => {
const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
expect(spenderAllowanceIsInsufficient).to.be.true();
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, { from: spender });
- expect(didReturnTrue).to.be.false();
+ return expect(
+ token.transferFrom.call(owner, spender, amountToTransfer, {
+ from: spender,
+ }),
+ ).to.be.rejectedWith(constants.REVERT);
});
it('should return true on a 0 value transfer', async () => {