aboutsummaryrefslogtreecommitdiffstats
path: root/test/0x.js_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-27 10:33:49 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-27 10:44:21 +0800
commitde0e436aad5d6b1c8a9425f075dbc3074b2fe31f (patch)
tree2090b3c57415106e6c4c8f5f051dbc23225d8533 /test/0x.js_test.ts
parent2c5f2210730d9c477e612fb3cb70db8d87e8545c (diff)
downloaddexon-sol-tools-de0e436aad5d6b1c8a9425f075dbc3074b2fe31f.tar
dexon-sol-tools-de0e436aad5d6b1c8a9425f075dbc3074b2fe31f.tar.gz
dexon-sol-tools-de0e436aad5d6b1c8a9425f075dbc3074b2fe31f.tar.bz2
dexon-sol-tools-de0e436aad5d6b1c8a9425f075dbc3074b2fe31f.tar.lz
dexon-sol-tools-de0e436aad5d6b1c8a9425f075dbc3074b2fe31f.tar.xz
dexon-sol-tools-de0e436aad5d6b1c8a9425f075dbc3074b2fe31f.tar.zst
dexon-sol-tools-de0e436aad5d6b1c8a9425f075dbc3074b2fe31f.zip
Allow multiple exchange versions t be functional at the same time
Diffstat (limited to 'test/0x.js_test.ts')
-rw-r--r--test/0x.js_test.ts18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts
index 9ec0a0c8e..3ddb5db1d 100644
--- a/test/0x.js_test.ts
+++ b/test/0x.js_test.ts
@@ -16,10 +16,11 @@ describe('ZeroEx library', () => {
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.getAvailableContractAddressedAsync();
// Instantiate the contract instances with the current provider
- await (zeroEx.exchange as any)._getExchangeContractAsync();
+ await (zeroEx.exchange as any)._getExchangeContractAsync(exchangeContractAddress);
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
- expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
+ expect((zeroEx.exchange as any)._exchangeContractByAddress[exchangeContractAddress]).to.not.be.undefined();
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
const newProvider = web3Factory.getRpcProvider();
@@ -28,7 +29,7 @@ describe('ZeroEx library', () => {
await zeroEx.setProviderAsync(newProvider);
// Check that contractInstances with old provider are removed after provider update
- expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
+ 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
@@ -52,6 +53,10 @@ describe('ZeroEx library', () => {
const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
const web3 = web3Factory.create();
const zeroEx = new ZeroEx(web3.currentProvider);
+ let exchangeContractAddress: string;
+ before(async () => {
+ [exchangeContractAddress] = await zeroEx.exchange.getAvailableContractAddressedAsync();
+ });
it('should return false if the data doesn\'t pertain to the signature & address', async () => {
expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false();
return expect(
@@ -77,7 +82,7 @@ describe('ZeroEx library', () => {
const isValidSignatureLocal = ZeroEx.isValidSignature(dataHex, signature, address);
expect(isValidSignatureLocal).to.be.true();
const isValidSignatureOnContract = await (zeroEx.exchange as any)
- ._isValidSignatureUsingContractCallAsync(dataHex, signature, address);
+ ._isValidSignatureUsingContractCallAsync(dataHex, signature, address, exchangeContractAddress);
return expect(isValidSignatureOnContract).to.be.true();
});
});
@@ -126,14 +131,15 @@ describe('ZeroEx library', () => {
});
});
describe('#getOrderHashHexAsync', () => {
- const exchangeContractAddress = constants.NULL_ADDRESS;
- const expectedOrderHash = '0x103a5e97dab5dbeb8f385636f86a7d1e458a7ccbe1bd194727f0b2f85ab116c7';
+ const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';
+ const exchangeContractAddress = '0xb69e673309512a9d726f87304c6984054f87a93b';
const order: Order = {
maker: constants.NULL_ADDRESS,
taker: constants.NULL_ADDRESS,
feeRecipient: constants.NULL_ADDRESS,
makerTokenAddress: constants.NULL_ADDRESS,
takerTokenAddress: constants.NULL_ADDRESS,
+ exchangeContractAddress,
salt: new BigNumber(0),
makerFee: new BigNumber(0),
takerFee: new BigNumber(0),