aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/libraries
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-06-06 07:20:38 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-07 03:40:31 +0800
commitd6d7f4e875b161aa7284467a61f67989f76ec89e (patch)
treed0287504809489cec96a9673ffac41429cf14cd7 /packages/contracts/test/libraries
parent63caddea62453863de84a4b53e14fe3e61d3008f (diff)
downloaddexon-sol-tools-d6d7f4e875b161aa7284467a61f67989f76ec89e.tar.gz
dexon-sol-tools-d6d7f4e875b161aa7284467a61f67989f76ec89e.tar.zst
dexon-sol-tools-d6d7f4e875b161aa7284467a61f67989f76ec89e.zip
Update more things to work with both Geth and Ganache
Diffstat (limited to 'packages/contracts/test/libraries')
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts29
1 files changed, 19 insertions, 10 deletions
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 26802a60d..f5435a81e 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -10,7 +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 { expectRevertOrAlwaysFailingTransaction, expectRevertOrOtherError } 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';
@@ -64,7 +64,8 @@ describe('LibBytes', () => {
describe('popByte', () => {
it('should revert if length is 0', async () => {
- return expect(libBytes.publicPopByte.callAsync(constants.NULL_BYTES)).to.be.rejectedWith(
+ return expectRevertOrOtherError(
+ libBytes.publicPopByte.callAsync(constants.NULL_BYTES),
constants.LIB_BYTES_GT_ZERO_LENGTH_REQUIRED,
);
});
@@ -80,7 +81,8 @@ describe('LibBytes', () => {
describe('popAddress', () => {
it('should revert if length is less than 20', async () => {
- return expect(libBytes.publicPopAddress.callAsync(byteArrayShorterThan20Bytes)).to.be.rejectedWith(
+ return expectRevertOrOtherError(
+ libBytes.publicPopAddress.callAsync(byteArrayShorterThan20Bytes),
constants.LIB_BYTES_GTE_20_LENGTH_REQUIRED,
);
});
@@ -165,7 +167,8 @@ 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(
+ return expectRevertOrOtherError(
+ libBytes.publicReadAddress.callAsync(shortByteArray, offset),
constants.LIB_BYTES_GTE_20_LENGTH_REQUIRED,
);
});
@@ -173,7 +176,8 @@ describe('LibBytes', () => {
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(
+ return expectRevertOrOtherError(
+ libBytes.publicReadAddress.callAsync(byteArray, badOffset),
constants.LIB_BYTES_GTE_20_LENGTH_REQUIRED,
);
});
@@ -209,14 +213,16 @@ 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(
+ return expectRevertOrOtherError(
+ libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset),
constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
);
});
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(
+ return expectRevertOrOtherError(
+ libBytes.publicReadBytes32.callAsync(testBytes32, badOffset),
constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
);
});
@@ -256,7 +262,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(
+ return expectRevertOrOtherError(
+ libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset),
constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
);
});
@@ -266,7 +273,8 @@ 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(
+ return expectRevertOrOtherError(
+ libBytes.publicReadUint256.callAsync(byteArray, badOffset),
constants.LIB_BYTES_GTE_32_LENGTH_REQUIRED,
);
});
@@ -287,7 +295,8 @@ describe('LibBytes', () => {
// AssertionError: expected promise to be rejected with an error including 'revert' but it was fulfilled with '0x08c379a0'
it('should revert if byte array has a length < 4', async () => {
const byteArrayLessThan4Bytes = '0x010101';
- return expect(libBytes.publicReadFirst4.callAsync(byteArrayLessThan4Bytes)).to.be.rejectedWith(
+ return expectRevertOrOtherError(
+ libBytes.publicReadFirst4.callAsync(byteArrayLessThan4Bytes),
constants.LIB_BYTES_GTE_4_LENGTH_REQUIRED,
);
});