aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package.json3
-rw-r--r--packages/contracts/src/utils/constants.ts5
-rw-r--r--packages/contracts/src/utils/web3_wrapper.ts2
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts52
-rw-r--r--yarn.lock116
5 files changed, 43 insertions, 135 deletions
diff --git a/package.json b/package.json
index f25438224..20fcea3fd 100644
--- a/package.json
+++ b/package.json
@@ -47,6 +47,7 @@
},
"resolutions": {
"ethereumjs-tx": "0xProject/ethereumjs-tx#fake-tx-include-signature-by-default",
- "ethers": "0xproject/ethers.js#eip-838-reasons"
+ "ethers": "0xproject/ethers.js#eip-838-reasons",
+ "ganache-core": "0xProject/ganache-core#feature/revert-strings"
}
}
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts
index 144e22bc2..a0369c256 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/src/utils/constants.ts
@@ -20,6 +20,11 @@ export const constants = {
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
ALWAYS_FAILING_TRANSACTION: 'always failing transaction',
+ LIB_BYTES_GT_ZERO_LENGTH_REQUIRED: 'Length must be greater than 0.',
+ LIB_BYTES_GTE_4_LENGTH_REQUIRED: 'Length must be greater than or equal to 4.',
+ LIB_BYTES_GTE_20_LENGTH_REQUIRED: 'Length must be greater than or equal to 20.',
+ LIB_BYTES_GTE_32_LENGTH_REQUIRED: 'Length must be greater than or equal to 32.',
+ LIB_BYTES_INDEX_OUT_OF_BOUNDS: 'Specified array index is out of bounds.',
TESTRPC_NETWORK_ID: 50,
AWAIT_TRANSACTION_MINED_MS: 100,
MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts
index bd582e841..49744dea1 100644
--- a/packages/contracts/src/utils/web3_wrapper.ts
+++ b/packages/contracts/src/utils/web3_wrapper.ts
@@ -5,7 +5,7 @@ import { Provider } from 'ethereum-types';
import { coverage } from './coverage';
-const useGeth = false;
+const useGeth = true;
const ganacheTxDefaults = {
from: devConstants.TESTRPC_FIRST_ADDRESS,
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 22d40cfd1..26802a60d 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -64,7 +64,9 @@ describe('LibBytes', () => {
describe('popByte', () => {
it('should revert if length is 0', async () => {
- return expect(libBytes.publicPopByte.callAsync(constants.NULL_BYTES)).to.be.rejectedWith(constants.REVERT);
+ return expect(libBytes.publicPopByte.callAsync(constants.NULL_BYTES)).to.be.rejectedWith(
+ constants.LIB_BYTES_GT_ZERO_LENGTH_REQUIRED,
+ );
});
it('should pop the last byte from the input and return it', async () => {
@@ -79,7 +81,7 @@ describe('LibBytes', () => {
describe('popAddress', () => {
it('should revert if length is less than 20', async () => {
return expect(libBytes.publicPopAddress.callAsync(byteArrayShorterThan20Bytes)).to.be.rejectedWith(
- constants.REVERT,
+ constants.LIB_BYTES_GTE_20_LENGTH_REQUIRED,
);
});
@@ -160,18 +162,20 @@ describe('LibBytes', () => {
return expect(address).to.be.equal(testAddress);
});
- // TOOD(albrow): AssertionError: expected promise to be rejected but it was fulfilled with '0x0000000000000000000000000000000000000000'
- it.skip('should fail if the byte array is too short to hold an address)', async () => {
+ it('should fail if the byte array is too short to hold an address)', async () => {
const shortByteArray = '0xabcdef';
const offset = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadAddress.callAsync(shortByteArray, offset));
+ return expect(libBytes.publicReadAddress.callAsync(shortByteArray, offset)).to.be.rejectedWith(
+ constants.LIB_BYTES_GTE_20_LENGTH_REQUIRED,
+ );
});
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with '0x0000000000000000000000000000000000000000'
- it.skip('should fail if the length between the offset and end of the byte array is too short to hold an address)', async () => {
+ it('should fail if the length between the offset and end of the byte array is too short to hold an address)', async () => {
const byteArray = ethUtil.addHexPrefix(testAddress);
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
- return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadAddress.callAsync(byteArray, badOffset));
+ return expect(libBytes.publicReadAddress.callAsync(byteArray, badOffset)).to.be.rejectedWith(
+ constants.LIB_BYTES_GTE_20_LENGTH_REQUIRED,
+ );
});
});
@@ -203,18 +207,18 @@ describe('LibBytes', () => {
return expect(bytes32).to.be.equal(testBytes32);
});
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with '0x08c379a000000000000000000000000000000000000000000000000000000000'
- it.skip('should fail if the byte array is too short to hold a bytes32)', async () => {
+ it('should fail if the byte array is too short to hold a bytes32)', async () => {
const offset = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransaction(
- libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset),
+ return expect(libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith(
+ constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
);
});
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with '0x08c379a000000000000000000000000000000000000000000000000000000000'
- it.skip('should fail if the length between the offset and end of the byte array is too short to hold a bytes32)', async () => {
+ it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32)', async () => {
const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength);
- return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset));
+ return expect(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset)).to.be.rejectedWith(
+ constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
+ );
});
});
@@ -250,21 +254,21 @@ describe('LibBytes', () => {
return expect(uint256).to.bignumber.equal(testUint256);
});
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with { Object (s, e, ...) }
- it.skip('should fail if the byte array is too short to hold a uint256)', async () => {
+ it('should fail if the byte array is too short to hold a uint256)', async () => {
const offset = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransaction(
- libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset),
+ return expect(libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith(
+ constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
);
});
- // TODO(albrow): AssertionError: expected promise to be rejected but it was fulfilled with { Object (s, e, ...) }
- it.skip('should fail if the length between the offset and end of the byte array is too short to hold a uint256)', async () => {
+ it('should fail if the length between the offset and end of the byte array is too short to hold a uint256)', async () => {
const formattedTestUint256 = new BN(testUint256.toString(10));
const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256);
const byteArray = ethUtil.bufferToHex(testUint256AsBuffer);
const badOffset = new BigNumber(testUint256AsBuffer.byteLength);
- return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadUint256.callAsync(byteArray, badOffset));
+ return expect(libBytes.publicReadUint256.callAsync(byteArray, badOffset)).to.be.rejectedWith(
+ constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
+ );
});
});
@@ -281,10 +285,10 @@ describe('LibBytes', () => {
describe('readFirst4', () => {
// AssertionError: expected promise to be rejected with an error including 'revert' but it was fulfilled with '0x08c379a0'
- it.skip('should revert if byte array has a length < 4', async () => {
+ it('should revert if byte array has a length < 4', async () => {
const byteArrayLessThan4Bytes = '0x010101';
return expect(libBytes.publicReadFirst4.callAsync(byteArrayLessThan4Bytes)).to.be.rejectedWith(
- constants.REVERT,
+ constants.LIB_BYTES_GTE_4_LENGTH_REQUIRED,
);
});
it('should return the first 4 bytes of a byte array of arbitrary length', async () => {
diff --git a/yarn.lock b/yarn.lock
index d05dc42bc..b61756bdd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2589,12 +2589,6 @@ commander@2.13.0, commander@~2.13.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
-commander@2.9.0:
- version "2.9.0"
- resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4"
- dependencies:
- graceful-readlink ">= 1.0.0"
-
commander@^2.12.1, commander@^2.8.1, commander@^2.9.0:
version "2.15.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
@@ -3260,12 +3254,6 @@ debug@2.2.0:
dependencies:
ms "0.7.1"
-debug@2.6.0:
- version "2.6.0"
- resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b"
- dependencies:
- ms "0.7.2"
-
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.6, debug@^2.6.8:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -3535,10 +3523,6 @@ detect-node@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.3.tgz#a2033c09cc8e158d37748fbde7507832bd6ce127"
-diff@3.2.0:
- version "3.2.0"
- resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9"
-
diff@3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.1.tgz#aa8567a6eed03c531fc89d3f711cd0e5259dec75"
@@ -4068,14 +4052,7 @@ ethereum-common@^0.0.18:
version "0.0.18"
resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.0.18.tgz#2fdc3576f232903358976eb39da783213ff9523f"
-ethereumjs-abi@^0.6.4:
- version "0.6.5"
- resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.5.tgz#5a637ef16ab43473fa72a29ad90871405b3f5241"
- dependencies:
- bn.js "^4.10.0"
- ethereumjs-util "^4.3.0"
-
-"ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git":
+ethereumjs-abi@^0.6.4, "ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git":
version "0.6.5"
resolved "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf"
dependencies:
@@ -4124,7 +4101,7 @@ ethereumjs-tx@0xProject/ethereumjs-tx#fake-tx-include-signature-by-default, ethe
ethereum-common "^0.0.18"
ethereumjs-util "^5.0.0"
-ethereumjs-util@^4.0.1, ethereumjs-util@^4.3.0, ethereumjs-util@^4.4.0:
+ethereumjs-util@^4.0.1, ethereumjs-util@^4.4.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-4.5.0.tgz#3e9428b317eebda3d7260d854fddda954b1f1bc6"
dependencies:
@@ -4192,7 +4169,7 @@ ethereumjs-wallet@~0.6.0:
ethers@0xproject/ethers.js#eip-838-reasons, ethers@^3.0.15:
version "3.0.18"
- resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/3cc32db979b308b636cddb812b6418f8256865ff"
+ resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447"
dependencies:
aes-js "3.0.0"
bn.js "^4.4.0"
@@ -4872,9 +4849,9 @@ ganache-cli@^6.1.0:
source-map-support "^0.5.3"
webpack-cli "^2.0.9"
-ganache-core@0xProject/ganache-core:
+ganache-core@0xProject/ganache-core, ganache-core@0xProject/ganache-core#feature/revert-strings:
version "2.1.0"
- resolved "https://codeload.github.com/0xProject/ganache-core/tar.gz/a5bf2cdd541beed1bae5a6e7bbab22541345dd42"
+ resolved "https://codeload.github.com/0xProject/ganache-core/tar.gz/6210a543ca024baffb8e757744761a86bb6430b0"
dependencies:
abstract-leveldown "^3.0.0"
async "^2.5.0"
@@ -4897,7 +4874,6 @@ ganache-core@0xProject/ganache-core:
localstorage-down "^0.6.7"
lodash "^4.17.5"
merkle-patricia-tree "^2.2.0"
- mocha "~3.3.0"
pify "^3.0.0"
prepend-file "^1.3.1"
seedrandom "~2.4.2"
@@ -4906,7 +4882,7 @@ ganache-core@0xProject/ganache-core:
temp "^0.8.3"
tmp "0.0.31"
web3 "^1.0.0-beta.30"
- web3-provider-engine "^13.6.5"
+ web3-provider-engine "^14.0.4"
websocket "^1.0.24"
yargs "^7.0.2"
@@ -5116,17 +5092,6 @@ glob2base@^0.0.12:
dependencies:
find-index "^0.1.1"
-glob@7.1.1:
- version "7.1.1"
- resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
- dependencies:
- fs.realpath "^1.0.0"
- inflight "^1.0.4"
- inherits "2"
- minimatch "^3.0.2"
- once "^1.3.0"
- path-is-absolute "^1.0.0"
-
glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@^7.1.2, glob@~7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
@@ -5332,10 +5297,6 @@ growl@1.10.3:
version "1.10.3"
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.3.tgz#1926ba90cf3edfe2adb4927f5880bc22c66c790f"
-growl@1.9.2:
- version "1.9.2"
- resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f"
-
gud@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0"
@@ -6598,7 +6559,7 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.0, json-stringify-safe@~5.0
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
-json3@3.3.2, json3@^3.3.2:
+json3@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"
@@ -7028,21 +6989,10 @@ lodash-es@^4.17.5, lodash-es@^4.2.1:
version "4.17.8"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.8.tgz#6fa8c8c5d337481df0bdf1c0d899d42473121e45"
-lodash._baseassign@^3.0.0:
- version "3.2.0"
- resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e"
- dependencies:
- lodash._basecopy "^3.0.0"
- lodash.keys "^3.0.0"
-
lodash._basecopy@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"
-lodash._basecreate@^3.0.0:
- version "3.0.3"
- resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821"
-
lodash._basetostring@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5"
@@ -7096,14 +7046,6 @@ lodash.camelcase@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
-lodash.create@3.1.1:
- version "3.1.1"
- resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7"
- dependencies:
- lodash._baseassign "^3.0.0"
- lodash._basecreate "^3.0.0"
- lodash._isiterateecall "^3.0.0"
-
lodash.deburr@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash.deburr/-/lodash.deburr-3.2.0.tgz#6da8f54334a366a7cf4c4c76ef8d80aa1b365ed5"
@@ -7729,22 +7671,6 @@ mocha@^4.0.1:
mkdirp "0.5.1"
supports-color "4.4.0"
-mocha@~3.3.0:
- version "3.3.0"
- resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.3.0.tgz#d29b7428d3f52c82e2e65df1ecb7064e1aabbfb5"
- dependencies:
- browser-stdout "1.3.0"
- commander "2.9.0"
- debug "2.6.0"
- diff "3.2.0"
- escape-string-regexp "1.0.5"
- glob "7.1.1"
- growl "1.9.2"
- json3 "3.3.2"
- lodash.create "3.1.1"
- mkdirp "0.5.1"
- supports-color "3.1.2"
-
mock-fs@^4.1.0:
version "4.4.2"
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.4.2.tgz#09dec5313f97095a450be6aa2ad8ab6738d63d6b"
@@ -7780,10 +7706,6 @@ ms@0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"
-ms@0.7.2:
- version "0.7.2"
- resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765"
-
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
@@ -12593,30 +12515,6 @@ web3-provider-engine@^13.3.2:
xhr "^2.2.0"
xtend "^4.0.1"
-web3-provider-engine@^13.6.5:
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-13.6.6.tgz#7d8972ffcd31e103bd2ce8a521b1b7da08cb173f"
- dependencies:
- async "^2.5.0"
- clone "^2.0.0"
- eth-block-tracker "^2.2.2"
- eth-sig-util "^1.4.2"
- ethereumjs-block "^1.2.2"
- ethereumjs-tx "^1.2.0"
- ethereumjs-util "^5.1.1"
- ethereumjs-vm "^2.0.2"
- fetch-ponyfill "^4.0.0"
- json-rpc-error "^2.0.0"
- json-stable-stringify "^1.0.1"
- promise-to-callback "^1.0.0"
- readable-stream "^2.2.9"
- request "^2.67.0"
- semaphore "^1.0.3"
- solc "^0.4.2"
- tape "^4.4.0"
- xhr "^2.2.0"
- xtend "^4.0.1"
-
web3-provider-engine@^14.0.4:
version "14.0.4"
resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-14.0.4.tgz#6f96b71ea1b3a76cc67cd52007116c8d4b64465b"