aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-07-07 05:51:44 +0800
committerGitHub <noreply@github.com>2017-07-07 05:51:44 +0800
commit18050b7ea3eae19626a7976c004b237287ff5363 (patch)
treebde30c03faf91a4385cfa1393a143c2281ee97b1 /test
parentf2611d5b2be4c4c1b8bcfc9c964a13faf2329316 (diff)
parent9f89dbc8e4f3159e5fb80ea8d977911c404dd3bc (diff)
downloaddexon-sol-tools-18050b7ea3eae19626a7976c004b237287ff5363.tar
dexon-sol-tools-18050b7ea3eae19626a7976c004b237287ff5363.tar.gz
dexon-sol-tools-18050b7ea3eae19626a7976c004b237287ff5363.tar.bz2
dexon-sol-tools-18050b7ea3eae19626a7976c004b237287ff5363.tar.lz
dexon-sol-tools-18050b7ea3eae19626a7976c004b237287ff5363.tar.xz
dexon-sol-tools-18050b7ea3eae19626a7976c004b237287ff5363.tar.zst
dexon-sol-tools-18050b7ea3eae19626a7976c004b237287ff5363.zip
Merge pull request #94 from 0xProject/moveExchangeAddressGetters
Moves exchange contract address getters to zeroEx top level
Diffstat (limited to 'test')
-rw-r--r--test/0x.js_test.ts36
-rw-r--r--test/artifacts_test.ts2
-rw-r--r--test/assert_test.ts2
-rw-r--r--test/exchange_wrapper_test.ts20
-rw-r--r--test/proxy_wrapper_test.ts2
5 files changed, 28 insertions, 34 deletions
diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts
index 50db402c4..0d8d63985 100644
--- a/test/0x.js_test.ts
+++ b/test/0x.js_test.ts
@@ -6,17 +6,18 @@ import * as BigNumber from 'bignumber.js';
import * as Sinon from 'sinon';
import {ZeroEx, Order} from '../src';
import {constants} from './utils/constants';
+import {assert} from '../src/utils/assert';
import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
describe('ZeroEx library', () => {
+ const web3 = web3Factory.create();
+ const zeroEx = new ZeroEx(web3.currentProvider);
describe('#setProvider', () => {
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
- const web3 = web3Factory.create();
- const zeroEx = new ZeroEx(web3.currentProvider);
- const [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
+ const [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
// Instantiate the contract instances with the current provider
await (zeroEx.exchange as any)._getExchangeContractAsync(exchangeContractAddress);
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
@@ -32,7 +33,7 @@ describe('ZeroEx library', () => {
expect((zeroEx.exchange as any)._exchangeContractByAddress[exchangeContractAddress]).to.be.undefined();
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.be.undefined();
- // Check that all nested web3 instances return the updated provider
+ // Check that all nested web3 wrapper instances return the updated provider
const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getCurrentProvider();
expect((nestedWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getCurrentProvider();
@@ -51,11 +52,9 @@ describe('ZeroEx library', () => {
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
};
const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
- const web3 = web3Factory.create();
- const zeroEx = new ZeroEx(web3.currentProvider);
let exchangeContractAddress: string;
before(async () => {
- [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
+ [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
});
it('should return false if the data doesn\'t pertain to the signature & address', async () => {
expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false();
@@ -148,9 +147,6 @@ describe('ZeroEx library', () => {
expirationUnixTimestampSec: new BigNumber(0),
};
it('calculates the order hash', async () => {
- const web3 = web3Factory.create();
- const zeroEx = new ZeroEx(web3.currentProvider);
-
const orderHash = zeroEx.getOrderHashHex(order);
expect(orderHash).to.be.equal(expectedOrderHash);
});
@@ -158,8 +154,6 @@ describe('ZeroEx library', () => {
describe('#signOrderHashAsync', () => {
let stubs: Sinon.SinonStub[] = [];
let makerAddress: string;
- const web3 = web3Factory.create();
- const zeroEx = new ZeroEx(web3.currentProvider);
before(async () => {
const availableAddreses = await zeroEx.getAvailableAddressesAsync();
makerAddress = availableAddreses[0];
@@ -222,4 +216,22 @@ describe('ZeroEx library', () => {
expect(ecSignature).to.deep.equal(expectedECSignature);
});
});
+ describe('#getAvailableExchangeContractAddressesAsync', () => {
+ it('returns the exchange contract addresses', async () => {
+ const exchangeAddresses = await zeroEx.getAvailableExchangeContractAddressesAsync();
+ _.map(exchangeAddresses, exchangeAddress => {
+ assert.isETHAddressHex('exchangeAddress', exchangeAddress);
+ });
+ });
+ });
+ describe('#getProxyAuthorizedExchangeContractAddressesAsync', () => {
+ it('returns the Proxy authorized exchange contract addresses', async () => {
+ const exchangeAddresses = await zeroEx.getProxyAuthorizedExchangeContractAddressesAsync();
+ for (const exchangeAddress of exchangeAddresses) {
+ assert.isETHAddressHex('exchangeAddress', exchangeAddress);
+ const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(exchangeAddress);
+ expect(isAuthorized).to.be.true();
+ }
+ });
+ });
});
diff --git a/test/artifacts_test.ts b/test/artifacts_test.ts
index 22d55a2ee..8393250aa 100644
--- a/test/artifacts_test.ts
+++ b/test/artifacts_test.ts
@@ -27,7 +27,7 @@ describe('Artifacts', () => {
await (zeroEx.token as any)._getProxyAddressAsync();
}).timeout(TIMEOUT);
it('exchange contract is deployed', async () => {
- const exchangeContractAddresses = await zeroEx.exchange.getAvailableContractAddressesAsync();
+ const exchangeContractAddresses = await zeroEx.getAvailableExchangeContractAddressesAsync();
expect(exchangeContractAddresses).to.have.lengthOf.above(0);
}).timeout(TIMEOUT);
});
diff --git a/test/assert_test.ts b/test/assert_test.ts
index 6a8d30716..bfca95d9c 100644
--- a/test/assert_test.ts
+++ b/test/assert_test.ts
@@ -21,7 +21,7 @@ describe('Assertion library', () => {
const varName = 'address';
return expect(assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper))
.to.be.rejectedWith(
- `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 instance`,
+ `Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
);
});
it('doesn\'t throw if address is available', async () => {
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 0321eb569..45da44f54 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -44,7 +44,7 @@ describe('ExchangeWrapper', () => {
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider);
- [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
+ [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
userAddresses = await promisify(web3.eth.getAccounts)();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
tokenUtils = new TokenUtils(tokens);
@@ -819,22 +819,4 @@ describe('ExchangeWrapper', () => {
expect(orderHash).to.equal(orderHashFromContract);
});
});
- describe('#getAvailableContractAddressesAsync', () => {
- it('returns the exchange contract addresses', async () => {
- const exchangeAddresses = await zeroEx.exchange.getAvailableContractAddressesAsync();
- _.map(exchangeAddresses, exchangeAddress => {
- assert.isETHAddressHex('exchangeAddress', exchangeAddress);
- });
- });
- });
- describe('#getProxyAuthorizedContractAddressesAsync', () => {
- it('returns the Proxy authorized exchange contract addresses', async () => {
- const exchangeAddresses = await zeroEx.exchange.getProxyAuthorizedContractAddressesAsync();
- for (const exchangeAddress of exchangeAddresses) {
- assert.isETHAddressHex('exchangeAddress', exchangeAddress);
- const isAuthorized = await zeroEx.proxy.isAuthorizedAsync(exchangeAddress);
- expect(isAuthorized).to.be.true();
- }
- });
- });
});
diff --git a/test/proxy_wrapper_test.ts b/test/proxy_wrapper_test.ts
index c60159b81..c7f1a080a 100644
--- a/test/proxy_wrapper_test.ts
+++ b/test/proxy_wrapper_test.ts
@@ -13,7 +13,7 @@ describe('ProxyWrapper', () => {
before(async () => {
const web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider);
- [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressesAsync();
+ [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync();
});
describe('#isAuthorizedAsync', () => {
it('should return false if the address is not authorized', async () => {