aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-06-06 19:45:25 +0800
committerGitHub <noreply@github.com>2017-06-06 19:45:25 +0800
commitd1d5477e8d798ca4379653b6e553c57c32d1655d (patch)
tree25898ba98670f5f828ed9c7549cb718ce5b6f086
parentaeec2a96b09b90ed98e0d21ee9467bda38f3b72c (diff)
parentb1ecb45f1bf5fed0762e7f17b00f46ae6fdc6b56 (diff)
downloaddexon-sol-tools-d1d5477e8d798ca4379653b6e553c57c32d1655d.tar
dexon-sol-tools-d1d5477e8d798ca4379653b6e553c57c32d1655d.tar.gz
dexon-sol-tools-d1d5477e8d798ca4379653b6e553c57c32d1655d.tar.bz2
dexon-sol-tools-d1d5477e8d798ca4379653b6e553c57c32d1655d.tar.lz
dexon-sol-tools-d1d5477e8d798ca4379653b6e553c57c32d1655d.tar.xz
dexon-sol-tools-d1d5477e8d798ca4379653b6e553c57c32d1655d.tar.zst
dexon-sol-tools-d1d5477e8d798ca4379653b6e553c57c32d1655d.zip
Merge branch 'master' into chai-setup
-rw-r--r--test/exchange_wrapper_test.ts9
-rw-r--r--test/token_wrapper_test.ts11
2 files changed, 16 insertions, 4 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 37f7b4941..def6d6902 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -4,6 +4,7 @@ import * as Web3 from 'web3';
import * as BigNumber from 'bignumber.js';
import {chaiSetup} from './utils/chai_setup';
import ChaiBigNumber = require('chai-bignumber');
+import * as chaiAsPromised from 'chai-as-promised';
import promisify = require('es6-promisify');
import {web3Factory} from './utils/web3_factory';
import {ZeroEx} from '../src/0x.js';
@@ -358,7 +359,7 @@ describe('ExchangeWrapper', () => {
describe('#getUnavailableTakerAmountAsync', () => {
it ('should throw if passed an invalid orderHash', async () => {
const invalidOrderHashHex = '0x123';
- expect(zeroEx.exchange.getUnavailableTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
+ return expect(zeroEx.exchange.getUnavailableTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
});
it ('should return zero if passed a valid but non-existent orderHash', async () => {
const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(NON_EXISTENT_ORDER_HASH);
@@ -373,7 +374,7 @@ describe('ExchangeWrapper', () => {
describe('#getFilledTakerAmountAsync', () => {
it ('should throw if passed an invalid orderHash', async () => {
const invalidOrderHashHex = '0x123';
- expect(zeroEx.exchange.getFilledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
+ return expect(zeroEx.exchange.getFilledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
});
it ('should return zero if passed a valid but non-existent orderHash', async () => {
const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(NON_EXISTENT_ORDER_HASH);
@@ -388,7 +389,7 @@ describe('ExchangeWrapper', () => {
describe('#getCanceledTakerAmountAsync', () => {
it ('should throw if passed an invalid orderHash', async () => {
const invalidOrderHashHex = '0x123';
- expect(zeroEx.exchange.getCanceledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
+ return expect(zeroEx.exchange.getCanceledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected();
});
it ('should return zero if passed a valid but non-existent orderHash', async () => {
const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(NON_EXISTENT_ORDER_HASH);
@@ -424,7 +425,7 @@ describe('ExchangeWrapper', () => {
);
});
afterEach(async () => {
- (zeroEx.exchange as any).stopWatchingExchangeLogEventsAsync();
+ await (zeroEx.exchange as any).stopWatchingExchangeLogEventsAsync();
});
// Hack: Mocha does not allow a test to be both async and have a `done` callback
// Since we need to await the receipt of the event in the `subscribeAsync` callback,
diff --git a/test/token_wrapper_test.ts b/test/token_wrapper_test.ts
index c258f8317..243d918ed 100644
--- a/test/token_wrapper_test.ts
+++ b/test/token_wrapper_test.ts
@@ -90,6 +90,17 @@ describe('TokenWrapper', () => {
token.address, fromAddress, toAddress, senderAddress, transferAmount,
)).to.be.rejectedWith(ZeroExError.INSUFFICIENT_ALLOWANCE_FOR_TRANSFER);
});
+ it('[regression] should fail to transfer tokens if set allowance for toAddress instead of senderAddress',
+ async () => {
+ const fromAddress = coinbase;
+ const transferAmount = new BigNumber(42);
+
+ await zeroEx.token.setAllowanceAsync(token.address, fromAddress, toAddress, transferAmount);
+
+ return expect(zeroEx.token.transferFromAsync(
+ token.address, fromAddress, toAddress, senderAddress, transferAmount,
+ )).to.be.rejectedWith(ZeroExError.INSUFFICIENT_ALLOWANCE_FOR_TRANSFER);
+ });
it('should fail to transfer tokens if fromAddress has insufficient balance', async () => {
const fromAddress = addressWithoutFunds;
const transferAmount = new BigNumber(42);