aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-06-22 08:14:14 +0800
committerGitHub <noreply@github.com>2018-06-22 08:14:14 +0800
commit7c0fdc7ecf170e17aa27cb88a2b62a02ea49ca41 (patch)
treec56450a8d0b92dae973978ba7eba5bd8bd9f3036 /packages/contracts/test
parentc7159b2be443ff3cc123472afbce9b443cdee2d5 (diff)
parentb333ed91de8d4f08cd614a52e2b0d602995c2b27 (diff)
downloaddexon-0x-contracts-7c0fdc7ecf170e17aa27cb88a2b62a02ea49ca41.tar.gz
dexon-0x-contracts-7c0fdc7ecf170e17aa27cb88a2b62a02ea49ca41.tar.zst
dexon-0x-contracts-7c0fdc7ecf170e17aa27cb88a2b62a02ea49ca41.zip
Merge pull request #740 from 0xProject/feature/contracts/updateEvents
Update events
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/exchange/core.ts2
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts52
2 files changed, 52 insertions, 2 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index ea37a1e99..89a1c6492 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -399,6 +399,7 @@ describe('Exchange core', () => {
expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress);
expect(takerAddress).to.be.equal(logArgs.takerAddress);
+ expect(takerAddress).to.be.equal(logArgs.senderAddress);
expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
expect(signedOrder.makerAssetData).to.be.equal(logArgs.makerAssetData);
expect(signedOrder.takerAssetData).to.be.equal(logArgs.takerAssetData);
@@ -577,6 +578,7 @@ describe('Exchange core', () => {
const logArgs = log.args;
expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress);
+ expect(signedOrder.makerAddress).to.be.equal(logArgs.senderAddress);
expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
expect(signedOrder.makerAssetData).to.be.equal(logArgs.makerAssetData);
expect(signedOrder.takerAssetData).to.be.equal(logArgs.takerAssetData);
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index 2a94ab25a..8e221e3f1 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -2,9 +2,13 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { addSignedMessagePrefix, assetProxyUtils, MessagePrefixType, orderHashUtils } from '@0xproject/order-utils';
import { SignatureType, SignedOrder } from '@0xproject/types';
import * as chai from 'chai';
+import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
-import { TestSignatureValidatorContract } from '../../src/generated_contract_wrappers/test_signature_validator';
+import {
+ SignatureValidatorApprovalContractEventArgs,
+ TestSignatureValidatorContract,
+} from '../../src/generated_contract_wrappers/test_signature_validator';
import { TestValidatorContract } from '../../src/generated_contract_wrappers/test_validator';
import { TestWalletContract } from '../../src/generated_contract_wrappers/test_wallet';
import { addressUtils } from '../../src/utils/address_utils';
@@ -12,6 +16,7 @@ import { artifacts } from '../../src/utils/artifacts';
import { expectRevertOrOtherErrorAsync } from '../../src/utils/assertions';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
+import { LogDecoder } from '../../src/utils/log_decoder';
import { OrderFactory } from '../../src/utils/order_factory';
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
@@ -19,7 +24,7 @@ chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-
+// tslint:disable:no-unnecessary-type-assertion
describe('MixinSignatureValidator', () => {
let signedOrder: SignedOrder;
let orderFactory: OrderFactory;
@@ -30,6 +35,7 @@ describe('MixinSignatureValidator', () => {
let signerPrivateKey: Buffer;
let notSignerAddress: string;
let notSignerPrivateKey: Buffer;
+ let signatureValidatorLogDecoder: LogDecoder;
before(async () => {
await blockchainLifecycle.startAsync();
@@ -59,6 +65,7 @@ describe('MixinSignatureValidator', () => {
txDefaults,
signerAddress,
);
+ signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, signatureValidator.address);
await web3Wrapper.awaitTransactionSuccessAsync(
await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(testValidator.address, true, {
from: signerAddress,
@@ -456,4 +463,45 @@ describe('MixinSignatureValidator', () => {
expect(isValidSignature).to.be.false();
});
});
+
+ describe('setSignatureValidatorApproval', () => {
+ it('should emit a SignatureValidatorApprovalSet with correct args when a validator is approved', async () => {
+ const approval = true;
+ const res = await signatureValidatorLogDecoder.getTxWithDecodedLogsAsync(
+ await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(
+ testValidator.address,
+ approval,
+ {
+ from: signerAddress,
+ },
+ ),
+ );
+ expect(res.logs.length).to.equal(1);
+ const log = res.logs[0] as LogWithDecodedArgs<SignatureValidatorApprovalContractEventArgs>;
+ const logArgs = log.args;
+ expect(logArgs.signerAddress).to.equal(signerAddress);
+ expect(logArgs.validatorAddress).to.equal(testValidator.address);
+ expect(logArgs.approved).to.equal(approval);
+ });
+ it('should emit a SignatureValidatorApprovalSet with correct args when a validator is disapproved', async () => {
+ const approval = false;
+ const res = await signatureValidatorLogDecoder.getTxWithDecodedLogsAsync(
+ await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(
+ testValidator.address,
+ approval,
+ {
+ from: signerAddress,
+ },
+ ),
+ );
+ expect(res.logs.length).to.equal(1);
+ const log = res.logs[0] as LogWithDecodedArgs<SignatureValidatorApprovalContractEventArgs>;
+ const logArgs = log.args;
+ expect(logArgs.signerAddress).to.equal(signerAddress);
+ expect(logArgs.validatorAddress).to.equal(testValidator.address);
+ expect(logArgs.approved).to.equal(approval);
+ });
+ });
});
+// tslint:disable:max-file-line-count
+// tslint:enable:no-unnecessary-type-assertion