diff options
author | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-08-27 22:46:33 +0200 |
---|---|---|
committer | Mischa Untaga <99098079+MischaU8@users.noreply.github.com> | 2023-08-27 22:46:33 +0200 |
commit | 846bb591653118316063e020326a221d940a1b30 (patch) | |
tree | 61024a1341044eea6bafc0a75199c5e5b2640b9b | |
parent | ba90f0109f0e327954487f86e7340f1ea9b429fc (diff) | |
download | fuzzer-846bb591653118316063e020326a221d940a1b30.tar.gz |
test resign and undo, can be disabled with NO-UNDO=true / NO_RESIGN=true
-rwxr-xr-x | rtt-module.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/rtt-module.js b/rtt-module.js index a12f520..f0c2c6c 100755 --- a/rtt-module.js +++ b/rtt-module.js @@ -5,6 +5,8 @@ const { FuzzedDataProvider } = require("@jazzer.js/core") const RULES_JS_FILE = process.env.RTT_RULES || "rules.js" const MAX_STEPS = parseInt(process.env.MAX_STEPS) || 2048 +const NO_UNDO = process.env.NO_UNDO === 'true' +const NO_RESIGN = process.env.NO_RESIGN === 'true' console.log(`Loading rtt-fuzzer RTT_RULES='${RULES_JS_FILE}' MAX_STEPS=${MAX_STEPS}`) if (!fs.existsSync(RULES_JS_FILE)) { @@ -61,9 +63,13 @@ module.exports.fuzz = function(fuzzerInputData) { } let actions = view.actions - if ('undo' in actions) { + if (NO_UNDO && 'undo' in actions) { + // remove `undo` from actions, useful to test for dead-ends delete actions['undo'] } + if (!NO_RESIGN) { + actions['_resign'] = 1 + } // Tor: view.actions["foo"] === 0 means the "foo" action is disabled (show the button in a disabled state) // Also ignoring the actions with `[]` as args, unsure about this but needed for Nevsky. @@ -80,7 +86,7 @@ module.exports.fuzz = function(fuzzerInputData) { let action = data.pickValue(Object.keys(actions)) let args = actions[action] - if (args !== undefined && args !== null && typeof args !== "number") { + 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 for (const arg in args) { if (isNaN(arg)) { @@ -90,9 +96,13 @@ module.exports.fuzz = function(fuzzerInputData) { } args = data.pickValue(args) } - + // console.log(action, args) try { - state = RULES.action(state, active, action, args) + if (action !== "_resign") { + state = RULES.action(state, active, action, args) + } else { + state = RULES.resign(state, active) + } } catch (e) { log_crash(game_setup, state, view, step, active, action, args) throw new RulesCrashError(e, e.stack) |