aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-05-25 00:58:31 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-05-25 00:58:31 +0800
commit522300c0ab05b6f8f4c2874b2d0a690196715165 (patch)
tree5502ac7fcaaf907778677d0ffa07bff8bd2f0dca
parent7a566c6988d48cbfffb5a8946751ea0a644c5c6a (diff)
downloaddexon-sol-tools-522300c0ab05b6f8f4c2874b2d0a690196715165.tar
dexon-sol-tools-522300c0ab05b6f8f4c2874b2d0a690196715165.tar.gz
dexon-sol-tools-522300c0ab05b6f8f4c2874b2d0a690196715165.tar.bz2
dexon-sol-tools-522300c0ab05b6f8f4c2874b2d0a690196715165.tar.lz
dexon-sol-tools-522300c0ab05b6f8f4c2874b2d0a690196715165.tar.xz
dexon-sol-tools-522300c0ab05b6f8f4c2874b2d0a690196715165.tar.zst
dexon-sol-tools-522300c0ab05b6f8f4c2874b2d0a690196715165.zip
change tests descriptions
-rw-r--r--test/0x.js.ts39
1 files 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;