Use expect.to.throw
This commit is contained in:
parent
ec2d3cc599
commit
2117b4e0c8
@ -21,12 +21,7 @@ describe('ZeroEx library', () => {
|
|||||||
r: signature.r,
|
r: signature.r,
|
||||||
s: signature.s,
|
s: signature.s,
|
||||||
};
|
};
|
||||||
try {
|
expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw();
|
||||||
const isValid = ZeroEx.isValidSignature(data, malformedSignature, address);
|
|
||||||
throw new Error('isValidSignature should have thrown');
|
|
||||||
} catch (err) {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
it('r lacks 0x prefix', () => {
|
it('r lacks 0x prefix', () => {
|
||||||
const malformedR = signature.r.replace('0x', '');
|
const malformedR = signature.r.replace('0x', '');
|
||||||
@ -35,12 +30,7 @@ describe('ZeroEx library', () => {
|
|||||||
r: malformedR,
|
r: malformedR,
|
||||||
s: signature.s,
|
s: signature.s,
|
||||||
};
|
};
|
||||||
try {
|
expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw();
|
||||||
const isValid = ZeroEx.isValidSignature(data, malformedSignature, address);
|
|
||||||
throw new Error('isValidSignature should have thrown');
|
|
||||||
} catch (err) {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
it('r is too short', () => {
|
it('r is too short', () => {
|
||||||
const malformedR = signature.r.substr(10);
|
const malformedR = signature.r.substr(10);
|
||||||
@ -49,12 +39,7 @@ describe('ZeroEx library', () => {
|
|||||||
r: malformedR,
|
r: malformedR,
|
||||||
s: signature.s.replace('0', 'z'),
|
s: signature.s.replace('0', 'z'),
|
||||||
};
|
};
|
||||||
try {
|
expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw();
|
||||||
const isValid = ZeroEx.isValidSignature(data, malformedSignature, address);
|
|
||||||
throw new Error('isValidSignature should have thrown');
|
|
||||||
} catch (err) {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
it('s is not hex', () => {
|
it('s is not hex', () => {
|
||||||
const malformedS = signature.s.replace('0', 'z');
|
const malformedS = signature.s.replace('0', 'z');
|
||||||
@ -63,12 +48,7 @@ describe('ZeroEx library', () => {
|
|||||||
r: signature.r,
|
r: signature.r,
|
||||||
s: malformedS,
|
s: malformedS,
|
||||||
};
|
};
|
||||||
try {
|
expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw();
|
||||||
const isValid = ZeroEx.isValidSignature(data, malformedSignature, address);
|
|
||||||
throw new Error('isValidSignature should have thrown');
|
|
||||||
} catch (err) {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should return false if the data doesn\'t pertain to the signature & address', () => {
|
it('should return false if the data doesn\'t pertain to the signature & address', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user