-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
243 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{ "dirs": [ "./easyseed-bip39", "./testcases", "./wordlists" ] } | ||
{ "dirs": [ "./input/easyseed-bip39", "./testcases", "./input/wordlists" ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
|
||
import { ethers } from "ethers"; | ||
|
||
export function randomBytes(seed: string, lower: number, upper?: number): Uint8Array { | ||
if (!upper) { upper = lower; } | ||
|
||
if (upper === 0 && upper === lower) { return new Uint8Array(0); } | ||
|
||
let result = ethers.utils.arrayify(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(seed))); | ||
while (result.length < upper) { | ||
result = ethers.utils.concat([result, ethers.utils.keccak256(result)]); | ||
} | ||
|
||
let top = ethers.utils.arrayify(ethers.utils.keccak256(result)); | ||
let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; | ||
|
||
return result.slice(0, lower + Math.floor((upper - lower) * percent)); | ||
} | ||
|
||
export function randomHexString(seed: string, lower: number, upper?: number): string { | ||
return ethers.utils.hexlify(randomBytes(seed, lower, upper)); | ||
} | ||
|
||
export function randomNumber(seed: string, lower: number, upper: number): number { | ||
let top = randomBytes(seed, 3); | ||
let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; | ||
return lower + Math.floor((upper - lower) * percent); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,40 @@ | ||
{ | ||
"name": "@ethersproject/tests", | ||
"version": "5.0.0-beta.142", | ||
"description": "Testing package for ethers.", | ||
"main": "./lib/index.js", | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"browser": { | ||
"@ethersproject/ethers": "./tests/browser-ethers.js" | ||
}, | ||
"scripts": { | ||
"dist-phantomjs": "browserify -g @ethersproject/testcases/scripts/browser-fs.js -s tests ./tests/browser.js -o ./dist/tests.js", | ||
"test": "if [ \"$RUN_PHANTOMJS\" = \"1\" ]; then npm run-script test-phantomjs; else npm run-script test-node; fi", | ||
"test-node": "mocha --no-colors --reporter tests/reporter tests/test-*.js", | ||
"test-phantomjs": "npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js" | ||
"ethers": "./lib/browser-ethers.js" | ||
}, | ||
"dependencies": { | ||
"@ethersproject/testcases": ">=5.0.0-beta.131", | ||
"@types/mocha": "^5.2.0", | ||
"ethers": ">=5.0.0-beta.156", | ||
"mocha-phantomjs-core": "2.1.2" | ||
}, | ||
"description": "Testing package for ethers.", | ||
"devDependencies": { | ||
"browserify": "16.2.3", | ||
"mocha": "^5.2.0", | ||
"web3-providers-http": "1.0.0-beta.35" | ||
}, | ||
"ethereum": "donations.ethers.eth", | ||
"keywords": [ | ||
"Ethereum", | ||
"ethers" | ||
], | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"module": "./lib.esm/index.js", | ||
"name": "@ethersproject/tests", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/ethers-io/ethers.js.git" | ||
}, | ||
"module": "./lib.esm/index.js", | ||
"scripts": { | ||
"test": "exit 1" | ||
}, | ||
"tarballHash": "0xe35d27339acf100689bdafbc29234a5e2469164ae6badd271dab620931d2c2d0", | ||
"types": "./lib/index.d.ts", | ||
"ethereum": "donations.ethers.eth", | ||
"tarballHash": "0x016eddde4135966b3c9a3343aa29579816661d677a01dbc3933db9ee392de4e5" | ||
"version": "5.0.0-beta.143" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"use strict"; | ||
|
||
import "./test-account"; | ||
import "./test-contract"; | ||
import "./test-contract-interface"; | ||
import "./test-hdnode"; | ||
import "./test-providers"; | ||
import "./test-utils"; | ||
import "./test-wallet"; | ||
import "./test-wordlists"; | ||
|
||
import { Reporter } from "./reporter"; | ||
|
||
export { Reporter } |
Oops, something went wrong.