diff options
author | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2024-01-16 11:59:07 +0100 |
---|---|---|
committer | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2024-01-16 11:59:07 +0100 |
commit | e51cfc2b93de245dd7a54d05445fd9eab6644a81 (patch) | |
tree | a2a129c83ae26a18c15cf3393303c71e4aa24782 | |
parent | 01b47f5ec7799a52913e1bc29d5dd6b6c018197d (diff) | |
download | fuzzer-e51cfc2b93de245dd7a54d05445fd9eab6644a81.tar.gz |
detect when undo causes random seed change
-rwxr-xr-x | rtt-module.js | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/rtt-module.js b/rtt-module.js index c0bc30f..5fe60ba 100755 --- a/rtt-module.js +++ b/rtt-module.js @@ -118,6 +118,7 @@ module.exports.fuzz = function(fuzzerInputData) { let action = data.pickValue(Object.keys(actions)) let args = actions[action] + let seed = state.seed if (args !== undefined && args !== null && typeof args !== "number" && typeof args !== "boolean") { // check for NaN as any suggested action argument and raise an error on those @@ -138,9 +139,15 @@ module.exports.fuzz = function(fuzzerInputData) { throw new RulesCrashError(e, e.stack) } - if (action === "undo" && state.active !== active) { - log_crash(replay, state, view, step, active) - throw new UndoActiveError(`undo caused active to switch from ${active} to ${state.active}`) + if (action === "undo") { + if (state.active !== active) { + log_crash(replay, state, view, step, active) + throw new UndoActiveError(`undo caused active to switch from ${active} to ${state.active}`) + } + if (state.seed !== seed) { + log_crash(replay, state, view, step, active) + throw new UndoSeedError(`undo caused seed change from ${seed} to ${state.seed}`) + } } step += 1 } @@ -198,6 +205,13 @@ class UndoActiveError extends Error { } } +class UndoSeedError extends Error { + constructor(message) { + super(message) + this.name = "UndoSeedError" + } +} + class RulesCrashError extends Error { constructor(message, stack) { super(message) |