From 522300c0ab05b6f8f4c2874b2d0a690196715165 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 24 May 2017 18:58:31 +0200 Subject: change tests descriptions --- test/0x.js.ts | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/test/0x.js.ts b/test/0x.js.ts index 9783e69b7..651407af3 100644 --- a/test/0x.js.ts +++ b/test/0x.js.ts @@ -22,31 +22,40 @@ describe('ZeroEx library', () => { const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); expect(isValid).to.be.false; }); - it('malformed r', () => { + it('r lacks 0x prefix', () => { + const malformedR = signature.r.replace('0x', ''); const malformedSignature = { v: signature.v, - r: signature.r.replace('0x', ''), + r: malformedR, s: signature.s, }; const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); expect(isValid).to.be.false; }); - }); - describe('should return false for invalid signature', () => { - it('wrong data', () => { - const isValid = ZeroEx.isValidSignature('wrong data', signature, address); - expect(isValid).to.be.false; - }); - it('wrong signer', () => { - const isValid = ZeroEx.isValidSignature(data, signature, '0xIamWrong'); - expect(isValid).to.be.false; - }); - it('wrong signature', () => { - const wrongSignature = Object.assign({}, signature, {v: 28}); - const isValid = ZeroEx.isValidSignature(data, wrongSignature, address); + it('r is too short', () => { + const malformedR = signature.r.substr(10); + const malformedSignature = { + v: signature.v, + r: malformedR, + s: signature.s, + }; + const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); expect(isValid).to.be.false; }); }); + it('should return false if the data doesn\'t pertain to the signature & address', () => { + const isValid = ZeroEx.isValidSignature('wrong data', signature, address); + expect(isValid).to.be.false; + }); + it('should return false if the address doesn\'t pertain to the signature & data', () => { + const isValid = ZeroEx.isValidSignature(data, signature, '0xIamWrong'); + expect(isValid).to.be.false; + }); + it('should return false if the signature doesn\'t pertain to the data & address', () => { + const wrongSignature = Object.assign({}, signature, {v: 28}); + const isValid = ZeroEx.isValidSignature(data, wrongSignature, address); + expect(isValid).to.be.false; + }); it('should return true for valid signature', () => { const isValid = ZeroEx.isValidSignature(data, signature, address); expect(isValid).to.be.true; -- cgit