From 55c491f8ea8bb0ba8cb1b856b3c42dd05c31565d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 25 May 2017 11:19:14 +0200 Subject: Add generateSalt and tests for it --- test/0x.js.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/0x.js.ts b/test/0x.js.ts index 71126c7da..e4e3cc0a7 100644 --- a/test/0x.js.ts +++ b/test/0x.js.ts @@ -1,6 +1,7 @@ import {ZeroEx} from '../src/ts/0x.js'; import {expect} from 'chai'; import 'mocha'; +import * as BigNumber from 'bignumber.js'; describe('ZeroEx library', () => { describe('#isValidSignature', () => { @@ -73,4 +74,16 @@ describe('ZeroEx library', () => { expect(isValid).to.be.true; }); }); + describe('#generateSalt', () => { + it('generates different salts', () => { + const equal = ZeroEx.generatePseudoRandomSalt().eq(ZeroEx.generatePseudoRandomSalt()); + expect(equal).to.be.false; + }); + it('generates salt in range [0..2^256)', () => { + const salt = ZeroEx.generatePseudoRandomSalt(); + expect(salt.greaterThanOrEqualTo(0)).to.be.true; + const twoPow256 = new BigNumber(2).pow(256); + expect(salt.lessThan(twoPow256)).to.be.true; + }); + }); }); -- cgit v1.2.3