From e51cfc2b93de245dd7a54d05445fd9eab6644a81 Mon Sep 17 00:00:00 2001 From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:59:07 +0100 Subject: detect when undo causes random seed change --- rtt-module.js | 20 +++++++++++++++++--- 1 file 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) -- cgit v1.2.3