aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-05-25 01:56:47 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-06-08 06:36:18 +0800
commit3d65341080177bdd436e7628a76e65774b947a38 (patch)
tree22214bf411e1cd564a5af5f50c5d8e02cfe7b875
parent80215ea1818874bcd3661259df6f2d3279cc59f2 (diff)
downloaddexon-sol-tools-3d65341080177bdd436e7628a76e65774b947a38.tar
dexon-sol-tools-3d65341080177bdd436e7628a76e65774b947a38.tar.gz
dexon-sol-tools-3d65341080177bdd436e7628a76e65774b947a38.tar.bz2
dexon-sol-tools-3d65341080177bdd436e7628a76e65774b947a38.tar.lz
dexon-sol-tools-3d65341080177bdd436e7628a76e65774b947a38.tar.xz
dexon-sol-tools-3d65341080177bdd436e7628a76e65774b947a38.tar.zst
dexon-sol-tools-3d65341080177bdd436e7628a76e65774b947a38.zip
Tests for libMem
-rw-r--r--packages/contracts/package.json2
-rw-r--r--packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol23
-rw-r--r--packages/contracts/src/utils/artifacts.ts2
-rw-r--r--packages/contracts/src/utils/types.ts1
-rw-r--r--packages/contracts/test/libraries/lib_mem.ts68
5 files changed, 80 insertions, 16 deletions
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 99c507197..009fe87ec 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -30,7 +30,7 @@
"test:circleci": "yarn test"
},
"config": {
- "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
+ "abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyDispatcher|TestLibBytes|TestLibMem|TestLibs|TestSignatureValidator|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
},
"repository": {
"type": "git",
diff --git a/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol b/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol
index 4cf62bf3a..0c6f8fbc9 100644
--- a/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol
+++ b/packages/contracts/src/contracts/current/test/TestLibMem/TestLibMem.sol
@@ -27,8 +27,7 @@ contract TestLibMem is
{
function test1()
- public
- pure
+ external
{
// Length of array & length to copy
uint256 length = 0;
@@ -52,8 +51,7 @@ contract TestLibMem is
}
function test2()
- public
- pure
+ external
{
// Length of array & length to copy
uint256 length = 1;
@@ -78,8 +76,7 @@ contract TestLibMem is
}
function test3()
- public
- pure
+ external
{
// Length of array & length to copy
uint256 length = 11;
@@ -106,8 +103,7 @@ contract TestLibMem is
}
function test4()
- public
- pure
+ external
{
// Length of array & length to copy
uint256 length = 32;
@@ -134,8 +130,7 @@ contract TestLibMem is
}
function test5()
- public
- pure
+ external
{
// Length of array & length to copy
uint256 length = 72;
@@ -163,8 +158,7 @@ contract TestLibMem is
function test6()
- public
- pure
+ external
{
// Length of arrays
uint256 length1 = 72;
@@ -208,8 +202,7 @@ contract TestLibMem is
}
function test7()
- public
- pure
+ external
{
// Length of array & length to copy
uint256 length = 72;
@@ -232,7 +225,7 @@ contract TestLibMem is
// We expect this to fail
require(
areBytesEqual(sourceArray, destArray),
- "Test #7 failed. Array contents are not the same."
+ "Test #7 failed. Array contents are not the same. This is expected."
);
}
}
diff --git a/packages/contracts/src/utils/artifacts.ts b/packages/contracts/src/utils/artifacts.ts
index 357c66a0a..1b47f1d41 100644
--- a/packages/contracts/src/utils/artifacts.ts
+++ b/packages/contracts/src/utils/artifacts.ts
@@ -11,6 +11,7 @@ import * as MultiSigWallet from '../artifacts/MultiSigWallet.json';
import * as MultiSigWalletWithTimeLock from '../artifacts/MultiSigWalletWithTimeLock.json';
import * as TestAssetProxyDispatcher from '../artifacts/TestAssetProxyDispatcher.json';
import * as TestLibBytes from '../artifacts/TestLibBytes.json';
+import * as TestLibMem from '../artifacts/TestLibMem.json';
import * as TestLibs from '../artifacts/TestLibs.json';
import * as TestSignatureValidator from '../artifacts/TestSignatureValidator.json';
import * as TokenRegistry from '../artifacts/TokenRegistry.json';
@@ -31,6 +32,7 @@ export const artifacts = {
MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact,
TestAssetProxyDispatcher: (TestAssetProxyDispatcher as any) as ContractArtifact,
TestLibBytes: (TestLibBytes as any) as ContractArtifact,
+ TestLibMem: (TestLibMem as any) as ContractArtifact,
TestLibs: (TestLibs as any) as ContractArtifact,
TestSignatureValidator: (TestSignatureValidator as any) as ContractArtifact,
TokenRegistry: (TokenRegistry as any) as ContractArtifact,
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index 491890fa1..cc6f00b95 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -91,6 +91,7 @@ export enum ContractName {
EtherDelta = 'EtherDelta',
Arbitrage = 'Arbitrage',
TestAssetProxyDispatcher = 'TestAssetProxyDispatcher',
+ TestLibMem = 'TestLibMem',
TestLibs = 'TestLibs',
TestSignatureValidator = 'TestSignatureValidator',
ERC20Proxy = 'ERC20Proxy',
diff --git a/packages/contracts/test/libraries/lib_mem.ts b/packages/contracts/test/libraries/lib_mem.ts
new file mode 100644
index 000000000..c861484f3
--- /dev/null
+++ b/packages/contracts/test/libraries/lib_mem.ts
@@ -0,0 +1,68 @@
+import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
+import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import BN = require('bn.js');
+import * as chai from 'chai';
+import ethUtil = require('ethereumjs-util');
+import * as Web3 from 'web3';
+
+import { TestLibMemContract } from '../../src/contract_wrappers/generated/test_lib_mem';
+import { artifacts } from '../../src/utils/artifacts';
+import { chaiSetup } from '../../src/utils/chai_setup';
+import { constants } from '../../src/utils/constants';
+import { AssetProxyId } from '../../src/utils/types';
+import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
+
+chaiSetup.configure();
+const expect = chai.expect;
+const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
+
+describe.only('LibMem', () => {
+ let owner: string;
+ let testLibMem: TestLibMemContract;
+
+ before(async () => {
+ // Setup accounts & addresses
+ const accounts = await web3Wrapper.getAvailableAddressesAsync();
+ owner = accounts[0];
+ // Deploy TestLibMem
+ testLibMem = await TestLibMemContract.deployFrom0xArtifactAsync(artifacts.TestLibMem, provider, txDefaults);
+ });
+ beforeEach(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ afterEach(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+
+ describe('LibMem', () => {
+ it('should )', async () => {
+ await testLibMem.test1.sendTransactionAsync();
+ });
+
+ it('should )', async () => {
+ await testLibMem.test2.sendTransactionAsync();
+ });
+
+ it('should )', async () => {
+ await testLibMem.test3.sendTransactionAsync();
+ });
+
+ it('should )', async () => {
+ await testLibMem.test4.sendTransactionAsync();
+ });
+
+ it('should )', async () => {
+ await testLibMem.test5.sendTransactionAsync();
+ });
+
+ it('should )', async () => {
+ await testLibMem.test6.sendTransactionAsync();
+ });
+
+ it('should )', async () => {
+ return expect(testLibMem.test7.sendTransactionAsync()).to.be.rejectedWith(constants.REVERT);
+ });
+ });
+});