aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/libraries
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-05-23 03:47:37 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-07 03:39:42 +0800
commit1cc9d9c0713a56b59717498fcae6dc2720ca4fb0 (patch)
treeeb20715294306fc61f77ecacaecc85c6d1144165 /packages/contracts/test/libraries
parent72fb8460e90237fb7879fc47e95d84b6aa54911b (diff)
downloaddexon-sol-tools-1cc9d9c0713a56b59717498fcae6dc2720ca4fb0.tar
dexon-sol-tools-1cc9d9c0713a56b59717498fcae6dc2720ca4fb0.tar.gz
dexon-sol-tools-1cc9d9c0713a56b59717498fcae6dc2720ca4fb0.tar.bz2
dexon-sol-tools-1cc9d9c0713a56b59717498fcae6dc2720ca4fb0.tar.lz
dexon-sol-tools-1cc9d9c0713a56b59717498fcae6dc2720ca4fb0.tar.xz
dexon-sol-tools-1cc9d9c0713a56b59717498fcae6dc2720ca4fb0.tar.zst
dexon-sol-tools-1cc9d9c0713a56b59717498fcae6dc2720ca4fb0.zip
Replace constant.REVERT test assertions with expectRevertOrAlwaysFailingTransaction
Diffstat (limited to 'packages/contracts/test/libraries')
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts25
1 files changed, 9 insertions, 16 deletions
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 26cfa8291..e639e6db1 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -10,6 +10,7 @@ import * as Web3 from 'web3';
import { TestLibBytesContract } from '../../src/contract_wrappers/generated/test_lib_bytes';
import { artifacts } from '../../src/utils/artifacts';
+import { expectRevertOrAlwaysFailingTransaction } from '../../src/utils/assertions';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
@@ -162,17 +163,13 @@ describe('LibBytes', () => {
it('should fail if the byte array is too short to hold an address)', async () => {
const shortByteArray = '0xabcdef';
const offset = new BigNumber(0);
- return expect(libBytes.publicReadAddress.callAsync(shortByteArray, offset)).to.be.rejectedWith(
- constants.REVERT,
- );
+ return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadAddress.callAsync(shortByteArray, offset));
});
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 expect(libBytes.publicReadAddress.callAsync(byteArray, badOffset)).to.be.rejectedWith(
- constants.REVERT,
- );
+ return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadAddress.callAsync(byteArray, badOffset));
});
});
@@ -206,16 +203,14 @@ describe('LibBytes', () => {
it('should fail if the byte array is too short to hold a bytes32)', async () => {
const offset = new BigNumber(0);
- return expect(libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith(
- constants.REVERT,
+ return expectRevertOrAlwaysFailingTransaction(
+ libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset),
);
});
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 expect(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset)).to.be.rejectedWith(
- constants.REVERT,
- );
+ return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset));
});
});
@@ -253,8 +248,8 @@ describe('LibBytes', () => {
it('should fail if the byte array is too short to hold a uint256)', async () => {
const offset = new BigNumber(0);
- return expect(libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith(
- constants.REVERT,
+ return expectRevertOrAlwaysFailingTransaction(
+ libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset),
);
});
@@ -263,9 +258,7 @@ describe('LibBytes', () => {
const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256);
const byteArray = ethUtil.bufferToHex(testUint256AsBuffer);
const badOffset = new BigNumber(testUint256AsBuffer.byteLength);
- return expect(libBytes.publicReadUint256.callAsync(byteArray, badOffset)).to.be.rejectedWith(
- constants.REVERT,
- );
+ return expectRevertOrAlwaysFailingTransaction(libBytes.publicReadUint256.callAsync(byteArray, badOffset));
});
});