Remove use of generatePseudoRandomAddress in favor of randomAddress
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
import { addressUtils, chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
 | 
					import { chaiSetup, constants, provider, randomAddress, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
 | 
				
			||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
 | 
					import { BlockchainLifecycle } from '@0x/dev-utils';
 | 
				
			||||||
import { transactionHashUtils } from '@0x/order-utils';
 | 
					import { transactionHashUtils } from '@0x/order-utils';
 | 
				
			||||||
import { BigNumber, providerUtils } from '@0x/utils';
 | 
					import { BigNumber, providerUtils } from '@0x/utils';
 | 
				
			||||||
@@ -13,7 +13,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
 | 
				
			|||||||
describe('Libs tests', () => {
 | 
					describe('Libs tests', () => {
 | 
				
			||||||
    let coordinatorContract: CoordinatorContract;
 | 
					    let coordinatorContract: CoordinatorContract;
 | 
				
			||||||
    let chainId: number;
 | 
					    let chainId: number;
 | 
				
			||||||
    const exchangeAddress = addressUtils.generatePseudoRandomAddress();
 | 
					    const exchangeAddress = randomAddress();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    before(async () => {
 | 
					    before(async () => {
 | 
				
			||||||
        await blockchainLifecycle.startAsync();
 | 
					        await blockchainLifecycle.startAsync();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,11 @@
 | 
				
			|||||||
import { constants as exchangeConstants, exchangeDataEncoder, ExchangeFunctionName } from '@0x/contracts-exchange';
 | 
					import { constants as exchangeConstants, exchangeDataEncoder, ExchangeFunctionName } from '@0x/contracts-exchange';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    addressUtils,
 | 
					 | 
				
			||||||
    chaiSetup,
 | 
					    chaiSetup,
 | 
				
			||||||
    constants,
 | 
					    constants,
 | 
				
			||||||
    expectContractCallFailedAsync,
 | 
					    expectContractCallFailedAsync,
 | 
				
			||||||
    getLatestBlockTimestampAsync,
 | 
					    getLatestBlockTimestampAsync,
 | 
				
			||||||
    provider,
 | 
					    provider,
 | 
				
			||||||
 | 
					    randomAddress,
 | 
				
			||||||
    TransactionFactory,
 | 
					    TransactionFactory,
 | 
				
			||||||
    txDefaults,
 | 
					    txDefaults,
 | 
				
			||||||
    web3Wrapper,
 | 
					    web3Wrapper,
 | 
				
			||||||
@@ -33,7 +33,7 @@ describe('Mixins tests', () => {
 | 
				
			|||||||
    let approvalFactory1: ApprovalFactory;
 | 
					    let approvalFactory1: ApprovalFactory;
 | 
				
			||||||
    let approvalFactory2: ApprovalFactory;
 | 
					    let approvalFactory2: ApprovalFactory;
 | 
				
			||||||
    let defaultOrder: SignedOrder;
 | 
					    let defaultOrder: SignedOrder;
 | 
				
			||||||
    const exchangeAddress = addressUtils.generatePseudoRandomAddress();
 | 
					    const exchangeAddress = randomAddress();
 | 
				
			||||||
    let exchangeDomain: EIP712DomainWithDefaultSchema;
 | 
					    let exchangeDomain: EIP712DomainWithDefaultSchema;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    before(async () => {
 | 
					    before(async () => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
import { addressUtils, blockchainTests, constants, expect } from '@0x/contracts-test-utils';
 | 
					import { blockchainTests, constants, expect, randomAddress } from '@0x/contracts-test-utils';
 | 
				
			||||||
import { BigNumber, signTypedDataUtils } from '@0x/utils';
 | 
					import { BigNumber, signTypedDataUtils } from '@0x/utils';
 | 
				
			||||||
import * as ethUtil from 'ethereumjs-util';
 | 
					import * as ethUtil from 'ethereumjs-util';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -28,7 +28,7 @@ blockchainTests('LibEIP712ExchangeDomain', env => {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
        it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to a non-null address', async () => {
 | 
					        it('should calculate the correct domain hash when verifyingContractAddressIfExists is set to a non-null address', async () => {
 | 
				
			||||||
            const chainId = 1;
 | 
					            const chainId = 1;
 | 
				
			||||||
            const verifyingContractAddress = addressUtils.generatePseudoRandomAddress();
 | 
					            const verifyingContractAddress = randomAddress();
 | 
				
			||||||
            const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync(
 | 
					            const libEIP712ExchangeDomainContract = await TestLibEIP712ExchangeDomainContract.deployFrom0xArtifactAsync(
 | 
				
			||||||
                artifacts.TestLibEIP712ExchangeDomain,
 | 
					                artifacts.TestLibEIP712ExchangeDomain,
 | 
				
			||||||
                env.provider,
 | 
					                env.provider,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,11 @@
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
    addressUtils,
 | 
					 | 
				
			||||||
    blockchainTests,
 | 
					    blockchainTests,
 | 
				
			||||||
    constants,
 | 
					    constants,
 | 
				
			||||||
    expect,
 | 
					    expect,
 | 
				
			||||||
    hexRandom,
 | 
					    hexRandom,
 | 
				
			||||||
    OrderStatus,
 | 
					    OrderStatus,
 | 
				
			||||||
    orderUtils,
 | 
					    orderUtils,
 | 
				
			||||||
 | 
					    randomAddress,
 | 
				
			||||||
} from '@0x/contracts-test-utils';
 | 
					} from '@0x/contracts-test-utils';
 | 
				
			||||||
import { ExchangeRevertErrors, generatePseudoRandomSalt } from '@0x/order-utils';
 | 
					import { ExchangeRevertErrors, generatePseudoRandomSalt } from '@0x/order-utils';
 | 
				
			||||||
import { BigNumber, RevertError } from '@0x/utils';
 | 
					import { BigNumber, RevertError } from '@0x/utils';
 | 
				
			||||||
@@ -59,8 +59,8 @@ blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults })
 | 
				
			|||||||
    (() => {
 | 
					    (() => {
 | 
				
			||||||
        const errorCode = ExchangeRevertErrors.SignatureErrorCode.Illegal;
 | 
					        const errorCode = ExchangeRevertErrors.SignatureErrorCode.Illegal;
 | 
				
			||||||
        const orderHash = orderUtils.generatePseudoRandomOrderHash();
 | 
					        const orderHash = orderUtils.generatePseudoRandomOrderHash();
 | 
				
			||||||
        const signer = addressUtils.generatePseudoRandomAddress();
 | 
					        const signer = randomAddress();
 | 
				
			||||||
        const validator = addressUtils.generatePseudoRandomAddress();
 | 
					        const validator = randomAddress();
 | 
				
			||||||
        const data = hexRandom(ERROR_DATA_LENGTH);
 | 
					        const data = hexRandom(ERROR_DATA_LENGTH);
 | 
				
			||||||
        const signature = hexRandom(SIGNATURE_LENGTH);
 | 
					        const signature = hexRandom(SIGNATURE_LENGTH);
 | 
				
			||||||
        const errorData = hexRandom(ERROR_DATA_LENGTH);
 | 
					        const errorData = hexRandom(ERROR_DATA_LENGTH);
 | 
				
			||||||
@@ -78,7 +78,7 @@ blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults })
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    (() => {
 | 
					    (() => {
 | 
				
			||||||
        const orderHash = orderUtils.generatePseudoRandomOrderHash();
 | 
					        const orderHash = orderUtils.generatePseudoRandomOrderHash();
 | 
				
			||||||
        const address = addressUtils.generatePseudoRandomAddress();
 | 
					        const address = randomAddress();
 | 
				
			||||||
        createDecodeTest(ExchangeRevertErrors.ExchangeInvalidContextError, [
 | 
					        createDecodeTest(ExchangeRevertErrors.ExchangeInvalidContextError, [
 | 
				
			||||||
            ExchangeRevertErrors.ExchangeContextErrorCodes.InvalidMaker,
 | 
					            ExchangeRevertErrors.ExchangeContextErrorCodes.InvalidMaker,
 | 
				
			||||||
            orderHash,
 | 
					            orderHash,
 | 
				
			||||||
@@ -103,14 +103,14 @@ blockchainTests.resets('LibExchangeRichErrorDecoder', ({ provider, txDefaults })
 | 
				
			|||||||
    })();
 | 
					    })();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    (() => {
 | 
					    (() => {
 | 
				
			||||||
        const maker = addressUtils.generatePseudoRandomAddress();
 | 
					        const maker = randomAddress();
 | 
				
			||||||
        const sender = addressUtils.generatePseudoRandomAddress();
 | 
					        const sender = randomAddress();
 | 
				
			||||||
        const currentEpoch = generatePseudoRandomSalt();
 | 
					        const currentEpoch = generatePseudoRandomSalt();
 | 
				
			||||||
        createDecodeTest(ExchangeRevertErrors.OrderEpochError, [maker, sender, currentEpoch]);
 | 
					        createDecodeTest(ExchangeRevertErrors.OrderEpochError, [maker, sender, currentEpoch]);
 | 
				
			||||||
    })();
 | 
					    })();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    (() => {
 | 
					    (() => {
 | 
				
			||||||
        const assetProxyAddress = addressUtils.generatePseudoRandomAddress();
 | 
					        const assetProxyAddress = randomAddress();
 | 
				
			||||||
        createDecodeTest(ExchangeRevertErrors.AssetProxyExistsError, [
 | 
					        createDecodeTest(ExchangeRevertErrors.AssetProxyExistsError, [
 | 
				
			||||||
            hexRandom(ASSET_PROXY_ID_LENGTH),
 | 
					            hexRandom(ASSET_PROXY_ID_LENGTH),
 | 
				
			||||||
            assetProxyAddress,
 | 
					            assetProxyAddress,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
    addressUtils,
 | 
					 | 
				
			||||||
    blockchainTests,
 | 
					    blockchainTests,
 | 
				
			||||||
    constants,
 | 
					    constants,
 | 
				
			||||||
    expect,
 | 
					    expect,
 | 
				
			||||||
@@ -8,6 +7,7 @@ import {
 | 
				
			|||||||
    LogDecoder,
 | 
					    LogDecoder,
 | 
				
			||||||
    OrderFactory,
 | 
					    OrderFactory,
 | 
				
			||||||
    orderUtils,
 | 
					    orderUtils,
 | 
				
			||||||
 | 
					    randomAddress,
 | 
				
			||||||
    TransactionFactory,
 | 
					    TransactionFactory,
 | 
				
			||||||
} from '@0x/contracts-test-utils';
 | 
					} from '@0x/contracts-test-utils';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
@@ -428,11 +428,11 @@ blockchainTests.resets('MixinSignatureValidator', env => {
 | 
				
			|||||||
            const defaultOrderParams = {
 | 
					            const defaultOrderParams = {
 | 
				
			||||||
                ...constants.STATIC_ORDER_PARAMS,
 | 
					                ...constants.STATIC_ORDER_PARAMS,
 | 
				
			||||||
                makerAddress,
 | 
					                makerAddress,
 | 
				
			||||||
                feeRecipientAddress: addressUtils.generatePseudoRandomAddress(),
 | 
					                feeRecipientAddress: randomAddress(),
 | 
				
			||||||
                makerAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
 | 
					                makerAssetData: assetDataUtils.encodeERC20AssetData(randomAddress()),
 | 
				
			||||||
                takerAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
 | 
					                takerAssetData: assetDataUtils.encodeERC20AssetData(randomAddress()),
 | 
				
			||||||
                makerFeeAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
 | 
					                makerFeeAssetData: assetDataUtils.encodeERC20AssetData(randomAddress()),
 | 
				
			||||||
                takerFeeAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
 | 
					                takerFeeAssetData: assetDataUtils.encodeERC20AssetData(randomAddress()),
 | 
				
			||||||
                makerFee: constants.ZERO_AMOUNT,
 | 
					                makerFee: constants.ZERO_AMOUNT,
 | 
				
			||||||
                takerFee: constants.ZERO_AMOUNT,
 | 
					                takerFee: constants.ZERO_AMOUNT,
 | 
				
			||||||
                domain: {
 | 
					                domain: {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,9 @@
 | 
				
			|||||||
import { constants } from './constants';
 | 
					import { constants } from './constants';
 | 
				
			||||||
import { hexRandom } from './hex_utils';
 | 
					import { hexRandom } from './hex_utils';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Generates a random address.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
export function randomAddress(): string {
 | 
					export function randomAddress(): string {
 | 
				
			||||||
    return hexRandom(constants.ADDRESS_LENGTH);
 | 
					    return hexRandom(constants.ADDRESS_LENGTH);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
import { addressUtils, chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
 | 
					import { chaiSetup, provider, randomAddress, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
 | 
				
			||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
 | 
					import { BlockchainLifecycle } from '@0x/dev-utils';
 | 
				
			||||||
import { BigNumber, LibAddressArrayRevertErrors } from '@0x/utils';
 | 
					import { BigNumber, LibAddressArrayRevertErrors } from '@0x/utils';
 | 
				
			||||||
import * as chai from 'chai';
 | 
					import * as chai from 'chai';
 | 
				
			||||||
@@ -29,23 +29,23 @@ describe('LibAddressArray', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    describe('append', () => {
 | 
					    describe('append', () => {
 | 
				
			||||||
        it('should append to empty array', async () => {
 | 
					        it('should append to empty array', async () => {
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const result = await lib.publicAppend.callAsync([], addr);
 | 
					            const result = await lib.publicAppend.callAsync([], addr);
 | 
				
			||||||
            const expected = [addr];
 | 
					            const expected = [addr];
 | 
				
			||||||
            expect(result).to.deep.equal(expected);
 | 
					            expect(result).to.deep.equal(expected);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should append to non-empty array', async () => {
 | 
					        it('should append to non-empty array', async () => {
 | 
				
			||||||
            const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(3, () => randomAddress());
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const expected = [...arr, addr];
 | 
					            const expected = [...arr, addr];
 | 
				
			||||||
            const result = await lib.publicAppend.callAsync(arr, addr);
 | 
					            const result = await lib.publicAppend.callAsync(arr, addr);
 | 
				
			||||||
            expect(result).to.deep.equal(expected);
 | 
					            expect(result).to.deep.equal(expected);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should revert if the free memory pointer was moved to before the end of the array', async () => {
 | 
					        it('should revert if the free memory pointer was moved to before the end of the array', async () => {
 | 
				
			||||||
            const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(3, () => randomAddress());
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const freeMemOffset = new BigNumber(-1);
 | 
					            const freeMemOffset = new BigNumber(-1);
 | 
				
			||||||
            const addressArrayEndPtr = new BigNumber(256);
 | 
					            const addressArrayEndPtr = new BigNumber(256);
 | 
				
			||||||
            const expectedError = new LibAddressArrayRevertErrors.MismanagedMemoryError(
 | 
					            const expectedError = new LibAddressArrayRevertErrors.MismanagedMemoryError(
 | 
				
			||||||
@@ -56,8 +56,8 @@ describe('LibAddressArray', () => {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should keep the same memory address if free memory pointer does not move', async () => {
 | 
					        it('should keep the same memory address if free memory pointer does not move', async () => {
 | 
				
			||||||
            const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(3, () => randomAddress());
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const freeMemOffset = new BigNumber(0);
 | 
					            const freeMemOffset = new BigNumber(0);
 | 
				
			||||||
            const expected = [...arr, addr];
 | 
					            const expected = [...arr, addr];
 | 
				
			||||||
            const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync(
 | 
					            const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync(
 | 
				
			||||||
@@ -70,8 +70,8 @@ describe('LibAddressArray', () => {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should change memory address if free memory pointer advances', async () => {
 | 
					        it('should change memory address if free memory pointer advances', async () => {
 | 
				
			||||||
            const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(3, () => randomAddress());
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const freeMemOffset = new BigNumber(1);
 | 
					            const freeMemOffset = new BigNumber(1);
 | 
				
			||||||
            const expectedArray = [...arr, addr];
 | 
					            const expectedArray = [...arr, addr];
 | 
				
			||||||
            const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync(
 | 
					            const [result, oldArrayMemStart, newArrayMemStart] = await lib.testAppendRealloc.callAsync(
 | 
				
			||||||
@@ -88,27 +88,27 @@ describe('LibAddressArray', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    describe('contains', () => {
 | 
					    describe('contains', () => {
 | 
				
			||||||
        it('should return false on an empty array', async () => {
 | 
					        it('should return false on an empty array', async () => {
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const isFound = await lib.publicContains.callAsync([], addr);
 | 
					            const isFound = await lib.publicContains.callAsync([], addr);
 | 
				
			||||||
            expect(isFound).to.equal(false);
 | 
					            expect(isFound).to.equal(false);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should return false on a missing item', async () => {
 | 
					        it('should return false on a missing item', async () => {
 | 
				
			||||||
            const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(3, () => randomAddress());
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const isFound = await lib.publicContains.callAsync(arr, addr);
 | 
					            const isFound = await lib.publicContains.callAsync(arr, addr);
 | 
				
			||||||
            expect(isFound).to.equal(false);
 | 
					            expect(isFound).to.equal(false);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should return true on an included item', async () => {
 | 
					        it('should return true on an included item', async () => {
 | 
				
			||||||
            const arr = _.times(4, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(4, () => randomAddress());
 | 
				
			||||||
            const addr = _.sample(arr) as string;
 | 
					            const addr = _.sample(arr) as string;
 | 
				
			||||||
            const isFound = await lib.publicContains.callAsync(arr, addr);
 | 
					            const isFound = await lib.publicContains.callAsync(arr, addr);
 | 
				
			||||||
            expect(isFound).to.equal(true);
 | 
					            expect(isFound).to.equal(true);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should return true on the only item in the array', async () => {
 | 
					        it('should return true on the only item in the array', async () => {
 | 
				
			||||||
            const arr = _.times(1, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(1, () => randomAddress());
 | 
				
			||||||
            const isFound = await lib.publicContains.callAsync(arr, arr[0]);
 | 
					            const isFound = await lib.publicContains.callAsync(arr, arr[0]);
 | 
				
			||||||
            expect(isFound).to.equal(true);
 | 
					            expect(isFound).to.equal(true);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@@ -116,20 +116,20 @@ describe('LibAddressArray', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    describe('indexOf', () => {
 | 
					    describe('indexOf', () => {
 | 
				
			||||||
        it('should fail on an empty array', async () => {
 | 
					        it('should fail on an empty array', async () => {
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const [isSuccess] = await lib.publicIndexOf.callAsync([], addr);
 | 
					            const [isSuccess] = await lib.publicIndexOf.callAsync([], addr);
 | 
				
			||||||
            expect(isSuccess).to.equal(false);
 | 
					            expect(isSuccess).to.equal(false);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should fail on a missing item', async () => {
 | 
					        it('should fail on a missing item', async () => {
 | 
				
			||||||
            const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(3, () => randomAddress());
 | 
				
			||||||
            const addr = addressUtils.generatePseudoRandomAddress();
 | 
					            const addr = randomAddress();
 | 
				
			||||||
            const [isSuccess] = await lib.publicIndexOf.callAsync(arr, addr);
 | 
					            const [isSuccess] = await lib.publicIndexOf.callAsync(arr, addr);
 | 
				
			||||||
            expect(isSuccess).to.equal(false);
 | 
					            expect(isSuccess).to.equal(false);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should succeed on an included item', async () => {
 | 
					        it('should succeed on an included item', async () => {
 | 
				
			||||||
            const arr = _.times(4, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(4, () => randomAddress());
 | 
				
			||||||
            const expectedIndexOf = _.random(0, arr.length - 1);
 | 
					            const expectedIndexOf = _.random(0, arr.length - 1);
 | 
				
			||||||
            const addr = arr[expectedIndexOf];
 | 
					            const addr = arr[expectedIndexOf];
 | 
				
			||||||
            const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, addr);
 | 
					            const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, addr);
 | 
				
			||||||
@@ -138,7 +138,7 @@ describe('LibAddressArray', () => {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it('should succeed on the only item in the array', async () => {
 | 
					        it('should succeed on the only item in the array', async () => {
 | 
				
			||||||
            const arr = _.times(1, () => addressUtils.generatePseudoRandomAddress());
 | 
					            const arr = _.times(1, () => randomAddress());
 | 
				
			||||||
            const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, arr[0]);
 | 
					            const [isSuccess, index] = await lib.publicIndexOf.callAsync(arr, arr[0]);
 | 
				
			||||||
            expect(isSuccess).to.equal(true);
 | 
					            expect(isSuccess).to.equal(true);
 | 
				
			||||||
            expect(index).bignumber.to.equal(0);
 | 
					            expect(index).bignumber.to.equal(0);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user