diff options
author | Fabio Berger <me@fabioberger.com> | 2017-05-25 18:27:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 18:27:49 +0800 |
commit | b1a6c895cc095b39c263ff508d98395b1b901dc6 (patch) | |
tree | 355fd7e1f9a34a88a6f190d0942f4348c553ecd6 /test/0x.js.ts | |
parent | 334d2f175fd9dcb3f9e336250d21c7916a2671ae (diff) | |
parent | 2117b4e0c87df277f5e8df54e8df922bdf19c298 (diff) | |
download | dexon-sol-tools-b1a6c895cc095b39c263ff508d98395b1b901dc6.tar dexon-sol-tools-b1a6c895cc095b39c263ff508d98395b1b901dc6.tar.gz dexon-sol-tools-b1a6c895cc095b39c263ff508d98395b1b901dc6.tar.bz2 dexon-sol-tools-b1a6c895cc095b39c263ff508d98395b1b901dc6.tar.lz dexon-sol-tools-b1a6c895cc095b39c263ff508d98395b1b901dc6.tar.xz dexon-sol-tools-b1a6c895cc095b39c263ff508d98395b1b901dc6.tar.zst dexon-sol-tools-b1a6c895cc095b39c263ff508d98395b1b901dc6.zip |
Merge pull request #10 from 0xProject/addSchemas
Add schema validation
Diffstat (limited to 'test/0x.js.ts')
-rw-r--r-- | test/0x.js.ts | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/test/0x.js.ts b/test/0x.js.ts index e4e3cc0a7..09266018b 100644 --- a/test/0x.js.ts +++ b/test/0x.js.ts @@ -14,15 +14,14 @@ describe('ZeroEx library', () => { s: '0x2d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee', }; const address = '0x9b2055d370f73ec7d8a03e965129118dc8f5bf83'; - describe('should return false for malformed signature', () => { + describe('should throw if passed a malformed signature', () => { it('malformed v', () => { const malformedSignature = { v: 34, r: signature.r, s: signature.s, }; - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - expect(isValid).to.be.false; + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); it('r lacks 0x prefix', () => { const malformedR = signature.r.replace('0x', ''); @@ -31,18 +30,16 @@ describe('ZeroEx library', () => { r: malformedR, s: signature.s, }; - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - expect(isValid).to.be.false; + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); it('r is too short', () => { const malformedR = signature.r.substr(10); const malformedSignature = { v: signature.v, r: malformedR, - s: signature.s, + s: signature.s.replace('0', 'z'), }; - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - expect(isValid).to.be.false; + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); it('s is not hex', () => { const malformedS = signature.s.replace('0', 'z'); @@ -51,8 +48,7 @@ describe('ZeroEx library', () => { r: signature.r, s: malformedS, }; - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - expect(isValid).to.be.false; + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); }); it('should return false if the data doesn\'t pertain to the signature & address', () => { |