In @0x/order-utils: Add signerAddress and signature to ExchangeRevertErrors.SignatureError.

In `@0x/contracts-exchange`: Add `signerAddress` and `signature` to `SignatureError` reverts.
This commit is contained in:
Lawrence Forman
2019-04-11 18:13:55 -04:00
committed by Amir Bandeali
parent ac18359410
commit a0223835b8
10 changed files with 142 additions and 106 deletions

View File

@@ -132,6 +132,8 @@ describe('MixinSignatureValidator', () => {
const expectedError = new ExchangeRevertErrors.SignatureError(
ExchangeRevertErrors.SignatureErrorCode.InvalidLength,
orderHashHex,
signedOrder.makerAddress,
emptySignature,
);
const tx = signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
@@ -148,6 +150,8 @@ describe('MixinSignatureValidator', () => {
const expectedError = new ExchangeRevertErrors.SignatureError(
ExchangeRevertErrors.SignatureErrorCode.Unsupported,
orderHashHex,
signedOrder.makerAddress,
unsupportedSignatureHex,
);
const tx = signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
@@ -158,16 +162,18 @@ describe('MixinSignatureValidator', () => {
});
it('should revert when SignatureType=Illegal', async () => {
const unsupportedSignatureHex = `0x${Buffer.from([SignatureType.Illegal]).toString('hex')}`;
const illegalSignatureHex = `0x${Buffer.from([SignatureType.Illegal]).toString('hex')}`;
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.SignatureError(
ExchangeRevertErrors.SignatureErrorCode.Illegal,
orderHashHex,
signedOrder.makerAddress,
illegalSignatureHex,
);
const tx = signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
unsupportedSignatureHex,
illegalSignatureHex,
);
return expect(tx).to.revertWith(expectedError);
});
@@ -192,6 +198,8 @@ describe('MixinSignatureValidator', () => {
const expectedError = new ExchangeRevertErrors.SignatureError(
ExchangeRevertErrors.SignatureErrorCode.InvalidLength,
orderHashHex,
signedOrder.makerAddress,
signatureHex,
);
const tx = signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
@@ -354,6 +362,8 @@ describe('MixinSignatureValidator', () => {
const expectedError = new ExchangeRevertErrors.SignatureError(
ExchangeRevertErrors.SignatureErrorCode.WalletError,
orderHashHex,
maliciousWallet.address,
signatureHex,
);
const tx = signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
@@ -402,6 +412,8 @@ describe('MixinSignatureValidator', () => {
const expectedError = new ExchangeRevertErrors.SignatureError(
ExchangeRevertErrors.SignatureErrorCode.ValidatorError,
orderHashHex,
signedOrder.makerAddress,
signatureHex,
);
const tx = signatureValidator.publicIsValidSignature.callAsync(orderHashHex, signerAddress, signatureHex);
return expect(tx).to.revertWith(expectedError);