aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-06-11 19:52:54 +0800
committerGitHub <noreply@github.com>2017-06-11 19:52:54 +0800
commit4ac0ead5ce931871cf12fdaa83d87597bfc9979d (patch)
tree0813864d3920321e64acadebdacfd1525ea4e998 /test
parent4e56c299263cf6a3397a1d7b95fb92a8b61da3c0 (diff)
parentbbe9a811fb28417377ec3d089e0cdd3693480c35 (diff)
downloaddexon-sol-tools-4ac0ead5ce931871cf12fdaa83d87597bfc9979d.tar
dexon-sol-tools-4ac0ead5ce931871cf12fdaa83d87597bfc9979d.tar.gz
dexon-sol-tools-4ac0ead5ce931871cf12fdaa83d87597bfc9979d.tar.bz2
dexon-sol-tools-4ac0ead5ce931871cf12fdaa83d87597bfc9979d.tar.lz
dexon-sol-tools-4ac0ead5ce931871cf12fdaa83d87597bfc9979d.tar.xz
dexon-sol-tools-4ac0ead5ce931871cf12fdaa83d87597bfc9979d.tar.zst
dexon-sol-tools-4ac0ead5ce931871cf12fdaa83d87597bfc9979d.zip
Merge pull request #62 from 0xProject/private
Prefix private vars with _
Diffstat (limited to 'test')
-rw-r--r--test/0x.js_test.ts36
-rw-r--r--test/assert_test.ts6
-rw-r--r--test/exchange_wrapper_test.ts4
3 files changed, 23 insertions, 23 deletions
diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts
index 1349d6360..346ef69f8 100644
--- a/test/0x.js_test.ts
+++ b/test/0x.js_test.ts
@@ -19,10 +19,10 @@ describe('ZeroEx library', () => {
const web3 = web3Factory.create();
const zeroEx = new ZeroEx(web3);
// Instantiate the contract instances with the current provider
- await (zeroEx.exchange as any).getExchangeContractAsync();
- await (zeroEx.tokenRegistry as any).getTokenRegistryContractAsync();
- expect((zeroEx.exchange as any).exchangeContractIfExists).to.not.be.undefined();
- expect((zeroEx.tokenRegistry as any).tokenRegistryContractIfExists).to.not.be.undefined();
+ await (zeroEx.exchange as any)._getExchangeContractAsync();
+ await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
+ expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
+ expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
const newProvider = web3Factory.getRpcProvider();
// Add property to newProvider so that we can differentiate it from old provider
@@ -30,15 +30,15 @@ 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.tokenRegistry as any).tokenRegistryContractIfExists).to.be.undefined();
+ expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
+ expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.be.undefined();
// Check that all nested web3 instances return the updated provider
- const nestedWeb3WrapperProvider = (zeroEx as any).web3Wrapper.getCurrentProvider();
+ const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getCurrentProvider();
expect((nestedWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
- const exchangeWeb3WrapperProvider = (zeroEx.exchange as any).web3Wrapper.getCurrentProvider();
+ const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getCurrentProvider();
expect((exchangeWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
- const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any).web3Wrapper.getCurrentProvider();
+ const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getCurrentProvider();
expect((tokenRegistryWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
});
});
@@ -57,14 +57,14 @@ describe('ZeroEx library', () => {
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(
- (zeroEx.exchange as any).isValidSignatureUsingContractCallAsync('0x0', signature, address),
+ (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync('0x0', signature, address),
).to.become(false);
});
it('should return false if the address doesn\'t pertain to the signature & data', async () => {
const validUnrelatedAddress = '0x8b0292B11a196601eD2ce54B665CaFEca0347D42';
expect(ZeroEx.isValidSignature(dataHex, signature, validUnrelatedAddress)).to.be.false();
return expect(
- (zeroEx.exchange as any).isValidSignatureUsingContractCallAsync(dataHex, signature,
+ (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature,
validUnrelatedAddress),
).to.become(false);
});
@@ -72,14 +72,14 @@ describe('ZeroEx library', () => {
const wrongSignature = _.assign({}, signature, {v: 28});
expect(ZeroEx.isValidSignature(dataHex, wrongSignature, address)).to.be.false();
return expect(
- (zeroEx.exchange as any).isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address),
+ (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address),
).to.become(false);
});
it('should return true if the signature does pertain to the dataHex & address', async () => {
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);
return expect(isValidSignatureOnContract).to.be.true();
});
});
@@ -154,7 +154,7 @@ describe('ZeroEx library', () => {
const zeroEx = new ZeroEx(web3);
stubs = [
- Sinon.stub((zeroEx as any), 'getExchangeAddressAsync')
+ Sinon.stub((zeroEx as any), '_getExchangeAddressAsync')
.returns(Promise.resolve(exchangeContractAddress)),
];
@@ -197,9 +197,9 @@ describe('ZeroEx library', () => {
s: '0x050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb02',
};
stubs = [
- Sinon.stub((zeroEx as any).web3Wrapper, 'getNodeVersionAsync')
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'getNodeVersionAsync')
.returns(Promise.resolve(newParityNodeVersion)),
- Sinon.stub((zeroEx as any).web3Wrapper, 'signTransactionAsync')
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync')
.returns(Promise.resolve(signature)),
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
@@ -218,9 +218,9 @@ describe('ZeroEx library', () => {
s: '0x2dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960',
};
stubs = [
- Sinon.stub((zeroEx as any).web3Wrapper, 'getNodeVersionAsync')
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'getNodeVersionAsync')
.returns(Promise.resolve(newParityNodeVersion)),
- Sinon.stub((zeroEx as any).web3Wrapper, 'signTransactionAsync')
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync')
.returns(Promise.resolve(signature)),
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
diff --git a/test/assert_test.ts b/test/assert_test.ts
index 6b623eaad..338027ad3 100644
--- a/test/assert_test.ts
+++ b/test/assert_test.ts
@@ -13,13 +13,13 @@ describe('Assertion library', () => {
it('throws when address is invalid', async () => {
const address = '0xdeadbeef';
const varName = 'address';
- return expect(assert.isSenderAddressAsync(varName, address, (zeroEx as any).web3Wrapper))
+ return expect(assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper))
.to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`);
});
it('throws when address is unavailable', async () => {
const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42';
const varName = 'address';
- return expect(assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any).web3Wrapper))
+ return expect(assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper))
.to.be.rejectedWith(
`Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 instance`,
);
@@ -27,7 +27,7 @@ describe('Assertion library', () => {
it('doesn\'t throw if address is available', async () => {
const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0];
const varName = 'address';
- return expect(assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any).web3Wrapper))
+ return expect(assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper))
.to.become(undefined);
});
});
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 1b97d7b05..633fa3c5d 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -618,7 +618,7 @@ describe('ExchangeWrapper', () => {
);
});
afterEach(async () => {
- await (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,
@@ -705,7 +705,7 @@ describe('ExchangeWrapper', () => {
);
const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder);
const orderHashFromContract = await (zeroEx.exchange as any)
- .getOrderHashHexUsingContractCallAsync(signedOrder);
+ ._getOrderHashHexUsingContractCallAsync(signedOrder);
expect(orderHash).to.equal(orderHashFromContract);
});
});