aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-08-25 05:06:46 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-08-25 05:06:46 +0800
commit6a9669a409a61c4645af43f39a4e4a0761354e32 (patch)
tree4054f02bf577ea213122cf5ad3694fc6586db85f /packages/contracts/test/exchange
parent070eff6f3a2f3775ef72248c3f345c05cd833798 (diff)
downloaddexon-sol-tools-6a9669a409a61c4645af43f39a4e4a0761354e32.tar
dexon-sol-tools-6a9669a409a61c4645af43f39a4e4a0761354e32.tar.gz
dexon-sol-tools-6a9669a409a61c4645af43f39a4e4a0761354e32.tar.bz2
dexon-sol-tools-6a9669a409a61c4645af43f39a4e4a0761354e32.tar.lz
dexon-sol-tools-6a9669a409a61c4645af43f39a4e4a0761354e32.tar.xz
dexon-sol-tools-6a9669a409a61c4645af43f39a4e4a0761354e32.tar.zst
dexon-sol-tools-6a9669a409a61c4645af43f39a4e4a0761354e32.zip
Rethrow Wallet and Validator errors
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r--packages/contracts/test/exchange/core.ts7
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts25
2 files changed, 14 insertions, 18 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index fdfb40155..f9d8b7783 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -195,7 +195,7 @@ describe('Exchange core', () => {
signedOrder.signature = `0x0${SignatureType.Wallet}`;
await expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
- RevertReason.InvalidOrderSignature,
+ RevertReason.WalletError,
);
});
@@ -209,13 +209,10 @@ describe('Exchange core', () => {
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- signedOrder = await orderFactory.newSignedOrderAsync({
- makerAddress: maliciousValidator.address,
- });
signedOrder.signature = `${maliciousValidator.address}0${SignatureType.Validator}`;
await expectTransactionFailedAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
- RevertReason.InvalidOrderSignature,
+ RevertReason.ValidatorError,
);
});
});
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index 947ebffcc..5b64d853c 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -352,7 +352,7 @@ describe('MixinSignatureValidator', () => {
expect(isValidSignature).to.be.false();
});
- it('should return false when `isValidSignature` attempts to update state and not allow state to be updated when SignatureType=Wallet', async () => {
+ it('should revert when `isValidSignature` attempts to update state and SignatureType=Wallet', async () => {
// Create EIP712 signature
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
const orderHashBuffer = ethUtil.toBuffer(orderHashHex);
@@ -365,13 +365,14 @@ describe('MixinSignatureValidator', () => {
ethUtil.toBuffer(`0x${SignatureType.Wallet}`),
]);
const signatureHex = ethUtil.bufferToHex(signature);
- // Validate signature
- const isValid = await signatureValidator.publicIsValidSignature.callAsync(
- orderHashHex,
- maliciousWallet.address,
- signatureHex,
+ await expectContractCallFailed(
+ signatureValidator.publicIsValidSignature.callAsync(
+ orderHashHex,
+ maliciousWallet.address,
+ signatureHex,
+ ),
+ RevertReason.WalletError,
);
- expect(isValid).to.be.equal(false);
});
it('should return true when SignatureType=Validator, signature is valid and validator is approved', async () => {
@@ -404,18 +405,16 @@ describe('MixinSignatureValidator', () => {
expect(isValidSignature).to.be.false();
});
- it('should return false when `isValidSignature` attempts to update state and not allow state to be updated when SignatureType=Validator', async () => {
+ it('should revert when `isValidSignature` attempts to update state and SignatureType=Validator', async () => {
const validatorAddress = ethUtil.toBuffer(`${maliciousValidator.address}`);
const signatureType = ethUtil.toBuffer(`0x${SignatureType.Validator}`);
const signature = Buffer.concat([validatorAddress, signatureType]);
const signatureHex = ethUtil.bufferToHex(signature);
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
- const isValid = await signatureValidator.publicIsValidSignature.callAsync(
- orderHashHex,
- maliciousValidator.address,
- signatureHex,
+ await expectContractCallFailed(
+ signatureValidator.publicIsValidSignature.callAsync(orderHashHex, signerAddress, signatureHex),
+ RevertReason.ValidatorError,
);
- expect(isValid).to.be.equal(false);
});
it('should return false when SignatureType=Validator, signature is valid and validator is not approved', async () => {
// Set approval of signature validator to false