Merge branch 'development' into 3.0
This commit is contained in:
@@ -31,6 +31,7 @@ describe('Authorizable', () => {
|
||||
artifacts.Authorizable,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -16,7 +16,12 @@ describe('LibAddress', () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
nonContract = (await web3Wrapper.getAvailableAddressesAsync())[0];
|
||||
// Deploy LibAddress
|
||||
lib = await TestLibAddressContract.deployFrom0xArtifactAsync(artifacts.TestLibAddress, provider, txDefaults);
|
||||
lib = await TestLibAddressContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLibAddress,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
@@ -20,6 +20,7 @@ describe('LibAddressArray', () => {
|
||||
artifacts.TestLibAddressArray,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
});
|
||||
after(async () => {
|
||||
|
@@ -59,7 +59,12 @@ describe('LibBytes', () => {
|
||||
testAddress = accounts[1];
|
||||
testAddressB = accounts[2];
|
||||
// Deploy LibBytes
|
||||
libBytes = await TestLibBytesContract.deployFrom0xArtifactAsync(artifacts.TestLibBytes, provider, txDefaults);
|
||||
libBytes = await TestLibBytesContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLibBytes,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
// Verify lengths of test data
|
||||
const byteArrayShorterThan32BytesLength = ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength;
|
||||
expect(byteArrayShorterThan32BytesLength).to.be.lessThan(32);
|
||||
|
@@ -17,7 +17,7 @@ describe('LibEIP712', () => {
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
// Deploy LibEIP712
|
||||
lib = await TestLibEIP712Contract.deployFrom0xArtifactAsync(artifacts.TestLibEIP712, provider, txDefaults);
|
||||
lib = await TestLibEIP712Contract.deployFrom0xArtifactAsync(artifacts.TestLibEIP712, provider, txDefaults, {});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
@@ -20,6 +20,7 @@ describe('LibRichErrors', () => {
|
||||
artifacts.TestLibRichErrors,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
95
contracts/utils/test/log_decoding.ts
Normal file
95
contracts/utils/test/log_decoding.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import { DecodedLogArgs, LogWithDecodedArgs } from 'ethereum-types';
|
||||
|
||||
import { artifacts, TestLogDecodingContract } from '../src';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
describe('TestLogDecoding', () => {
|
||||
let testLogDecodingWithDependencies: TestLogDecodingContract;
|
||||
let testLogDecodingDeployedWithoutDependencies: TestLogDecodingContract;
|
||||
const expectedEvent = {
|
||||
foo: new BigNumber(256),
|
||||
bar: '0x1234',
|
||||
car: '4321',
|
||||
};
|
||||
const expectedDownstreamEvent = {
|
||||
lorem: new BigNumber(256),
|
||||
ipsum: '4321',
|
||||
};
|
||||
const emptyDependencyList = {};
|
||||
|
||||
before(async () => {
|
||||
testLogDecodingDeployedWithoutDependencies = await TestLogDecodingContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLogDecoding,
|
||||
provider,
|
||||
txDefaults,
|
||||
emptyDependencyList,
|
||||
);
|
||||
testLogDecodingWithDependencies = await TestLogDecodingContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestLogDecoding,
|
||||
provider,
|
||||
txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
|
||||
describe('Decoding Log Arguments', () => {
|
||||
it('should decode locally emitted event args when no dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEvent.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
});
|
||||
it('should not decode event args when no dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.undefined();
|
||||
});
|
||||
it('should decode args for local but not downstream event when no dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingDeployedWithoutDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(2);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[1] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.undefined();
|
||||
});
|
||||
it('should decode locally emitted event args when dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingWithDependencies.emitEvent.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
});
|
||||
it('should decode downstream event args when dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingWithDependencies.emitEventDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(1);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(
|
||||
expectedDownstreamEvent,
|
||||
);
|
||||
});
|
||||
it('should decode args for both local and downstream events when dependencies are passed into wrapper', async () => {
|
||||
const txReceipt = await testLogDecodingWithDependencies.emitEventsLocalAndDownstream.awaitTransactionSuccessAsync();
|
||||
expect(txReceipt.logs.length).to.be.equal(2);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[0] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(expectedEvent);
|
||||
// tslint:disable no-unnecessary-type-assertion
|
||||
expect((txReceipt.logs[1] as LogWithDecodedArgs<DecodedLogArgs>).args).to.be.deep.equal(
|
||||
expectedDownstreamEvent,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
@@ -22,7 +22,7 @@ describe('Ownable', () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
// Deploy Ownable from the owner address
|
||||
txDefaults.from = owner;
|
||||
ownable = await TestOwnableContract.deployFrom0xArtifactAsync(artifacts.TestOwnable, provider, txDefaults);
|
||||
ownable = await TestOwnableContract.deployFrom0xArtifactAsync(artifacts.TestOwnable, provider, txDefaults, {});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
|
@@ -20,6 +20,7 @@ describe('ReentrancyGuard', () => {
|
||||
artifacts.TestReentrancyGuard,
|
||||
provider,
|
||||
txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
@@ -19,6 +19,7 @@ blockchainTests('SafeMath', env => {
|
||||
artifacts.TestSafeMath,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user