aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-05-25 17:48:21 +0800
committerGitHub <noreply@github.com>2017-05-25 17:48:21 +0800
commit334d2f175fd9dcb3f9e336250d21c7916a2671ae (patch)
tree52cfb1e8923864978a50e9fe304f952218c8a43f /test
parentd23dbf53fd3689613f28d576d03ccfdce94b6646 (diff)
parent8fe580ea526a048148df2b3545f903eae660ed58 (diff)
downloaddexon-sol-tools-334d2f175fd9dcb3f9e336250d21c7916a2671ae.tar
dexon-sol-tools-334d2f175fd9dcb3f9e336250d21c7916a2671ae.tar.gz
dexon-sol-tools-334d2f175fd9dcb3f9e336250d21c7916a2671ae.tar.bz2
dexon-sol-tools-334d2f175fd9dcb3f9e336250d21c7916a2671ae.tar.lz
dexon-sol-tools-334d2f175fd9dcb3f9e336250d21c7916a2671ae.tar.xz
dexon-sol-tools-334d2f175fd9dcb3f9e336250d21c7916a2671ae.tar.zst
dexon-sol-tools-334d2f175fd9dcb3f9e336250d21c7916a2671ae.zip
Merge pull request #9 from 0xProject/generateSalt
Add generateSalt and tests for it
Diffstat (limited to 'test')
-rw-r--r--test/0x.js.ts13
1 files changed, 13 insertions, 0 deletions
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;
+ });
+ });
});