aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-05-25 19:57:40 +0800
committerGitHub <noreply@github.com>2017-05-25 19:57:40 +0800
commitf7b8378a6eb4b4c6c3461ff677723869c67a4753 (patch)
treeacd0984b53d3e47c094784e39cd24cbdd75b2b04 /test
parentdfb7b039f15d572ddf2e417f71ecb069114100a8 (diff)
parentf3cfd3e708608cc88f61fcb9c6c8b56fcfa9d030 (diff)
downloaddexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.gz
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.bz2
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.lz
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.xz
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.tar.zst
dexon-sol-tools-f7b8378a6eb4b4c6c3461ff677723869c67a4753.zip
Merge pull request #11 from 0xProject/isValidOrderHash
Port isValidOrderHash and tests
Diffstat (limited to 'test')
-rw-r--r--test/0x.js.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/0x.js.ts b/test/0x.js.ts
index 46e5c4da5..a913fd6b5 100644
--- a/test/0x.js.ts
+++ b/test/0x.js.ts
@@ -57,7 +57,7 @@ describe('ZeroEx library', () => {
});
});
it('should return false if the data doesn\'t pertain to the signature & address', () => {
- const isValid = ZeroEx.isValidSignature('wrong data', signature, address);
+ const isValid = ZeroEx.isValidSignature('0x0', signature, address);
expect(isValid).to.be.false;
});
it('should return false if the address doesn\'t pertain to the signature & data', () => {
@@ -87,6 +87,20 @@ describe('ZeroEx library', () => {
expect(salt.lessThan(twoPow256)).to.be.true;
});
});
+ describe('#isValidOrderHash', () => {
+ it('returns false if the value is not a hex string', () => {
+ const isValid = ZeroEx.isValidOrderHash('not a hex');
+ expect(isValid).to.be.false;
+ });
+ it('returns false if the length is wrong', () => {
+ const isValid = ZeroEx.isValidOrderHash('0xdeadbeef');
+ expect(isValid).to.be.false;
+ });
+ it('returns true if order hash is correct', () => {
+ const isValid = ZeroEx.isValidOrderHash('0x' + Array(65).join('0'));
+ expect(isValid).to.be.true;
+ });
+ });
describe('#toUnitAmount', () => {
it('Should return the expected unit amount for the decimals passed in', () => {
const baseUnitAmount = new BigNumber(1000000000);