diff --git a/contracts/test-utils/src/hex_utils.ts b/contracts/test-utils/src/hex_utils.ts index 95c2435b1f..d1a70442c2 100644 --- a/contracts/test-utils/src/hex_utils.ts +++ b/contracts/test-utils/src/hex_utils.ts @@ -1,3 +1,4 @@ +import * as crypto from 'crypto'; import * as ethUtil from 'ethereumjs-util'; /** @@ -6,3 +7,9 @@ import * as ethUtil from 'ethereumjs-util'; export function hexConcat(...args: Array): string { return ethUtil.bufferToHex(Buffer.concat(args.map(h => ethUtil.toBuffer(h)))); } +/** + * Generate a random hex string. + */ +export function hexRandom(size: number = 32): string { + return ethUtil.bufferToHex(crypto.randomBytes(size)); +} diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index 3abd3f6070..20b0aa47bc 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -26,7 +26,7 @@ export { OrderFactory } from './order_factory'; export { bytes32Values, testCombinatoriallyWithReferenceFuncAsync, uint256Values } from './combinatorial_utils'; export { TransactionFactory } from './transaction_factory'; export { testWithReferenceFuncAsync } from './test_with_reference'; -export { hexConcat } from './hex_utils'; +export { hexConcat, hexRandom } from './hex_utils'; export { BatchMatchedFillResults, BatchMatchOrder,