Move constants over to ContractLibError enum and update all tests

This commit is contained in:
Fabio Berger
2018-06-22 18:36:15 +02:00
parent ba14850c9a
commit 0e7c254b93
5 changed files with 42 additions and 44 deletions

View File

@@ -19,19 +19,6 @@ const TESTRPC_PRIVATE_KEYS_STRINGS = [
export const constants = { export const constants = {
INVALID_OPCODE: 'invalid opcode', INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert', REVERT: 'revert',
LIB_BYTES_GREATER_THAN_ZERO_LENGTH_REQUIRED: 'GREATER_THAN_ZERO_LENGTH_REQUIRED',
LIB_BYTES_GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED',
LIB_BYTES_GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED',
LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED',
LIB_BYTES_GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED',
LIB_BYTES_GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED: 'GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED',
ERC20_INSUFFICIENT_BALANCE: 'Insufficient balance to complete transfer.',
ERC20_INSUFFICIENT_ALLOWANCE: 'Insufficient allowance to complete transfer.',
EXCHANGE_LENGTH_GREATER_THAN_0_REQUIRED: 'LENGTH_GREATER_THAN_0_REQUIRED',
EXCHANGE_SIGNATURE_UNSUPPORTED: 'SIGNATURE_UNSUPPORTED',
EXCHANGE_SIGNATURE_ILLEGAL: 'SIGNATURE_ILLEGAL',
EXCHANGE_LENGTH_0_REQUIRED: 'LENGTH_0_REQUIRED',
EXCHANGE_LENGTH_65_REQUIRED: 'LENGTH_65_REQUIRED',
TESTRPC_NETWORK_ID: 50, TESTRPC_NETWORK_ID: 50,
// Note(albrow): In practice V8 and most other engines limit the minimum // Note(albrow): In practice V8 and most other engines limit the minimum
// interval for setInterval to 10ms. We still set it to 0 here in order to // interval for setInterval to 10ms. We still set it to 0 here in order to

View File

@@ -173,8 +173,8 @@ export enum ContractLibErrors {
AssetProxyMismatch = 'ASSET_PROXY_MISMATCH', AssetProxyMismatch = 'ASSET_PROXY_MISMATCH',
AssetProxyIdMismatch = 'ASSET_PROXY_ID_MISMATCH', AssetProxyIdMismatch = 'ASSET_PROXY_ID_MISMATCH',
LengthGreaterThan0Required = 'LENGTH_GREATER_THAN_0_REQUIRED', LengthGreaterThan0Required = 'LENGTH_GREATER_THAN_0_REQUIRED',
Length1Required = 'LENGTH_1_REQUIRED', ExchangeLength0Required = 'LENGTH_0_REQUIRED',
Length66Required = 'LENGTH_66_REQUIRED', ExchangeLength65Required = 'LENGTH_65_REQUIRED',
InvalidAmount = 'INVALID_AMOUNT', InvalidAmount = 'INVALID_AMOUNT',
TransferFailed = 'TRANSFER_FAILED', TransferFailed = 'TRANSFER_FAILED',
SenderNotAuthorized = 'SENDER_NOT_AUTHORIZED', SenderNotAuthorized = 'SENDER_NOT_AUTHORIZED',
@@ -186,4 +186,12 @@ export enum ContractLibErrors {
MakerNotWhitelisted = 'MAKER_NOT_WHITELISTED', MakerNotWhitelisted = 'MAKER_NOT_WHITELISTED',
TakerNotWhitelisted = 'TAKER_NOT_WHITELISTED', TakerNotWhitelisted = 'TAKER_NOT_WHITELISTED',
AssetProxyDoesNotExist = 'ASSET_PROXY_DOES_NOT_EXIST', AssetProxyDoesNotExist = 'ASSET_PROXY_DOES_NOT_EXIST',
LibBytesGreaterThanZeroLengthRequired = 'GREATER_THAN_ZERO_LENGTH_REQUIRED',
LibBytesGreaterOrEqualTo4LengthRequired = 'GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED',
LibBytesGreaterOrEqualTo20LengthRequired = 'GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED',
LibBytesGreaterOrEqualTo32LengthRequired = 'GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED',
LibBytesGreaterOrEqualToNestedBytesLengthRequired = 'GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED',
LibBytesGreaterOrEqualToSourceBytesLengthRequired = 'GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED',
Erc20InsufficientBalance = 'ERC20_INSUFFICIENT_BALANCE',
Erc20InsufficientAllowance = 'ERC20_INSUFFICIENT_ALLOWANCE',
} }

View File

@@ -18,6 +18,7 @@ import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants'; import { constants } from '../../src/utils/constants';
import { LogDecoder } from '../../src/utils/log_decoder'; import { LogDecoder } from '../../src/utils/log_decoder';
import { OrderFactory } from '../../src/utils/order_factory'; import { OrderFactory } from '../../src/utils/order_factory';
import { ContractLibErrors } from '../../src/utils/types';
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
@@ -107,7 +108,7 @@ describe('MixinSignatureValidator', () => {
signedOrder.makerAddress, signedOrder.makerAddress,
emptySignature, emptySignature,
), ),
constants.EXCHANGE_LENGTH_GREATER_THAN_0_REQUIRED, ContractLibErrors.LengthGreaterThan0Required,
); );
}); });
@@ -121,7 +122,7 @@ describe('MixinSignatureValidator', () => {
signedOrder.makerAddress, signedOrder.makerAddress,
unsupportedSignatureHex, unsupportedSignatureHex,
), ),
constants.EXCHANGE_SIGNATURE_UNSUPPORTED, ContractLibErrors.SignatureUnsupported,
); );
}); });
@@ -134,7 +135,7 @@ describe('MixinSignatureValidator', () => {
signedOrder.makerAddress, signedOrder.makerAddress,
unsupportedSignatureHex, unsupportedSignatureHex,
), ),
constants.EXCHANGE_SIGNATURE_ILLEGAL, ContractLibErrors.SignatureIllegal,
); );
}); });
@@ -161,7 +162,7 @@ describe('MixinSignatureValidator', () => {
signedOrder.makerAddress, signedOrder.makerAddress,
signatureHex, signatureHex,
), ),
constants.EXCHANGE_LENGTH_0_REQUIRED, ContractLibErrors.ExchangeLength0Required,
); );
}); });

View File

@@ -11,6 +11,7 @@ import { artifacts } from '../../src/utils/artifacts';
import { expectRevertOrOtherErrorAsync } from '../../src/utils/assertions'; import { expectRevertOrOtherErrorAsync } from '../../src/utils/assertions';
import { chaiSetup } from '../../src/utils/chai_setup'; import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants'; import { constants } from '../../src/utils/constants';
import { ContractLibErrors } from '../../src/utils/types';
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
@@ -95,7 +96,7 @@ describe('LibBytes', () => {
it('should revert if length is 0', async () => { it('should revert if length is 0', async () => {
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicPopLastByte.callAsync(constants.NULL_BYTES), libBytes.publicPopLastByte.callAsync(constants.NULL_BYTES),
constants.LIB_BYTES_GREATER_THAN_ZERO_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterThanZeroLengthRequired,
); );
}); });
it('should pop the last byte from the input and return it', async () => { it('should pop the last byte from the input and return it', async () => {
@@ -111,7 +112,7 @@ describe('LibBytes', () => {
it('should revert if length is less than 20', async () => { it('should revert if length is less than 20', async () => {
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicPopLast20Bytes.callAsync(byteArrayShorterThan20Bytes), libBytes.publicPopLast20Bytes.callAsync(byteArrayShorterThan20Bytes),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo20LengthRequired
); );
}); });
it('should pop the last 20 bytes from the input and return it', async () => { it('should pop the last 20 bytes from the input and return it', async () => {
@@ -172,7 +173,7 @@ describe('LibBytes', () => {
it('should revert if dest is shorter than source', async () => { it('should revert if dest is shorter than source', async () => {
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicDeepCopyBytes.callAsync(byteArrayShorterThan32Bytes, byteArrayLongerThan32Bytes), libBytes.publicDeepCopyBytes.callAsync(byteArrayShorterThan32Bytes, byteArrayLongerThan32Bytes),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualToSourceBytesLengthRequired
); );
}); });
it('should overwrite dest with source if source and dest have equal length', async () => { it('should overwrite dest with source if source and dest have equal length', async () => {
@@ -225,7 +226,7 @@ describe('LibBytes', () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadAddress.callAsync(shortByteArray, offset), libBytes.publicReadAddress.callAsync(shortByteArray, offset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo20LengthRequired,
); );
}); });
it('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 () => {
@@ -233,7 +234,7 @@ describe('LibBytes', () => {
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadAddress.callAsync(byteArray, badOffset), libBytes.publicReadAddress.callAsync(byteArray, badOffset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo20LengthRequired,
); );
}); });
}); });
@@ -269,7 +270,7 @@ describe('LibBytes', () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteAddress.callAsync(byteArrayShorterThan20Bytes, offset, testAddress), libBytes.publicWriteAddress.callAsync(byteArrayShorterThan20Bytes, offset, testAddress),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo20LengthRequired,
); );
}); });
it('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 () => {
@@ -277,7 +278,7 @@ describe('LibBytes', () => {
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteAddress.callAsync(byteArray, badOffset, testAddress), libBytes.publicWriteAddress.callAsync(byteArray, badOffset, testAddress),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo20LengthRequired,
); );
}); });
}); });
@@ -301,14 +302,14 @@ describe('LibBytes', () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset), libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
it('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); const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadBytes32.callAsync(testBytes32, badOffset), libBytes.publicReadBytes32.callAsync(testBytes32, badOffset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
}); });
@@ -344,7 +345,7 @@ describe('LibBytes', () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteBytes32.callAsync(byteArrayShorterThan32Bytes, offset, testBytes32), libBytes.publicWriteBytes32.callAsync(byteArrayShorterThan32Bytes, offset, testBytes32),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
it('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 () => {
@@ -352,7 +353,7 @@ describe('LibBytes', () => {
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteBytes32.callAsync(byteArray, badOffset, testBytes32), libBytes.publicWriteBytes32.callAsync(byteArray, badOffset, testBytes32),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
}); });
@@ -380,7 +381,7 @@ describe('LibBytes', () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset), libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
it('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 () => {
@@ -390,7 +391,7 @@ describe('LibBytes', () => {
const badOffset = new BigNumber(testUint256AsBuffer.byteLength); const badOffset = new BigNumber(testUint256AsBuffer.byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadUint256.callAsync(byteArray, badOffset), libBytes.publicReadUint256.callAsync(byteArray, badOffset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
}); });
@@ -430,7 +431,7 @@ describe('LibBytes', () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteUint256.callAsync(byteArrayShorterThan32Bytes, offset, testUint256), libBytes.publicWriteUint256.callAsync(byteArrayShorterThan32Bytes, offset, testUint256),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
it('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 () => {
@@ -438,7 +439,7 @@ describe('LibBytes', () => {
const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteUint256.callAsync(byteArray, badOffset, testUint256), libBytes.publicWriteUint256.callAsync(byteArray, badOffset, testUint256),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
}); });
@@ -449,7 +450,7 @@ describe('LibBytes', () => {
const byteArrayLessThan4Bytes = '0x010101'; const byteArrayLessThan4Bytes = '0x010101';
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadFirst4.callAsync(byteArrayLessThan4Bytes), libBytes.publicReadFirst4.callAsync(byteArrayLessThan4Bytes),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo4LengthRequired,
); );
}); });
it('should return the first 4 bytes of a byte array of arbitrary length', async () => { it('should return the first 4 bytes of a byte array of arbitrary length', async () => {
@@ -504,28 +505,28 @@ describe('LibBytes', () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadBytes.callAsync(byteArrayShorterThan32Bytes, offset), libBytes.publicReadBytes.callAsync(byteArrayShorterThan32Bytes, offset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
it('should fail if we store a nested byte array length, without a nested byte array', async () => { it('should fail if we store a nested byte array length, without a nested byte array', async () => {
const offset = new BigNumber(0); const offset = new BigNumber(0);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadBytes.callAsync(testBytes32, offset), libBytes.publicReadBytes.callAsync(testBytes32, offset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualToNestedBytesLengthRequired,
); );
}); });
it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array', async () => { it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array', async () => {
const badOffset = new BigNumber(ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength); const badOffset = new BigNumber(ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadBytes.callAsync(byteArrayShorterThan32Bytes, badOffset), libBytes.publicReadBytes.callAsync(byteArrayShorterThan32Bytes, badOffset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
it('should fail if the length between the offset and end of the byte array is too short to hold the nested byte array', async () => { it('should fail if the length between the offset and end of the byte array is too short to hold the nested byte array', async () => {
const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength); const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicReadBytes.callAsync(testBytes32, badOffset), libBytes.publicReadBytes.callAsync(testBytes32, badOffset),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualTo32LengthRequired,
); );
}); });
}); });
@@ -605,7 +606,7 @@ describe('LibBytes', () => {
const emptyByteArray = ethUtil.bufferToHex(new Buffer(1)); const emptyByteArray = ethUtil.bufferToHex(new Buffer(1));
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteBytes.callAsync(emptyByteArray, offset, longData), libBytes.publicWriteBytes.callAsync(emptyByteArray, offset, longData),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualToNestedBytesLengthRequired,
); );
}); });
it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array)', async () => { it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array)', async () => {
@@ -613,7 +614,7 @@ describe('LibBytes', () => {
const badOffset = new BigNumber(ethUtil.toBuffer(shortTestBytesAsBuffer).byteLength); const badOffset = new BigNumber(ethUtil.toBuffer(shortTestBytesAsBuffer).byteLength);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
libBytes.publicWriteBytes.callAsync(emptyByteArray, badOffset, shortData), libBytes.publicWriteBytes.callAsync(emptyByteArray, badOffset, shortData),
constants.LIB_BYTES_GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED, ContractLibErrors.LibBytesGreaterOrEqualToNestedBytesLengthRequired,
); );
}); });
}); });

View File

@@ -7,6 +7,7 @@ import { artifacts } from '../src/utils/artifacts';
import { expectRevertOrOtherErrorAsync } from '../src/utils/assertions'; import { expectRevertOrOtherErrorAsync } from '../src/utils/assertions';
import { chaiSetup } from '../src/utils/chai_setup'; import { chaiSetup } from '../src/utils/chai_setup';
import { constants } from '../src/utils/constants'; import { constants } from '../src/utils/constants';
import { ContractLibErrors } from '../src/utils/types';
import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper'; import { provider, txDefaults, web3Wrapper } from '../src/utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
@@ -55,7 +56,7 @@ describe('UnlimitedAllowanceToken', () => {
const amountToTransfer = ownerBalance.plus(1); const amountToTransfer = ownerBalance.plus(1);
return expectRevertOrOtherErrorAsync( return expectRevertOrOtherErrorAsync(
token.transfer.callAsync(spender, amountToTransfer, { from: owner }), token.transfer.callAsync(spender, amountToTransfer, { from: owner }),
constants.ERC20_INSUFFICIENT_BALANCE, ContractLibErrors.Erc20InsufficientBalance,
); );
}); });
@@ -96,7 +97,7 @@ describe('UnlimitedAllowanceToken', () => {
token.transferFrom.callAsync(owner, spender, amountToTransfer, { token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender, from: spender,
}), }),
constants.ERC20_INSUFFICIENT_BALANCE, ContractLibErrors.Erc20InsufficientBalance,
); );
}); });
@@ -112,7 +113,7 @@ describe('UnlimitedAllowanceToken', () => {
token.transferFrom.callAsync(owner, spender, amountToTransfer, { token.transferFrom.callAsync(owner, spender, amountToTransfer, {
from: spender, from: spender,
}), }),
constants.ERC20_INSUFFICIENT_ALLOWANCE, ContractLibErrors.Erc20InsufficientAllowance,
); );
}); });