Skip to content

Commit 84fbda1

Browse files
authored
Add staking fuzz tests. Run semi random inputs to staking contract. Validate result as expected. (#963)
* Added staking fuzz tests Save latest work Commit latest progress Fix comments in stakingActionsGenerator.js Fix contract name Fix some stuff from Mike's CR Commit latest progress Commit latest progress Add revert msgs Modify random generation, console log validity states, complete withdrawal checks Move random number generation to helper file, return if check fails Remove console.log * Minor fixes * Add CRLF * Use winston for logging into file * Round progress percentage
1 parent de10452 commit 84fbda1

File tree

7 files changed

+1393
-0
lines changed

7 files changed

+1393
-0
lines changed

package-lock.json

Lines changed: 185 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"truffle-flattener": "1.4.2",
3535
"web3": "1.2.4",
3636
"web3-utils": "1.2.4",
37+
"winston": "^3.3.3",
3738
"yargs": "11.1.1"
3839
},
3940
"devDependencies": {

scripts/randomNumberGenerator.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const BN = web3.utils.BN;
2+
module.exports.genRandomSeed = genRandomSeed;
3+
function genRandomSeed(base) {
4+
return Math.floor(Math.random() * Math.random() * base) % base;
5+
}
6+
7+
module.exports.genRandomBN = function(minBN, maxBN) {
8+
let seed = new BN(genRandomSeed(1000000000000000));
9+
// normalise seed
10+
return (maxBN.sub(minBN).mul(seed).div(new BN(1000000000000000))).add(minBN);
11+
}

0 commit comments

Comments
 (0)