diff --git a/proxy_mutator.c b/proxy_mutator.c index 6ee66c2d7..894f01732 100644 --- a/proxy_mutator.c +++ b/proxy_mutator.c @@ -140,8 +140,8 @@ static void _mut_check_idx(lua_State *L, int tidx) { if (!isnum) { proxy_lua_ferror(L, "mutator step %d: must provide 'idx' argument as an integer", tidx); } - if (i < 2) { - proxy_lua_ferror(L, "mutator step %d: 'idx' argument must be greater than 1", tidx); + if (i < 1) { + proxy_lua_ferror(L, "mutator step %d: 'idx' argument must be greater than 0", tidx); } } else { proxy_lua_ferror(L, "mutator step %d: must provide 'idx' argument", tidx); @@ -880,7 +880,8 @@ static int mcp_mutator_new(lua_State *L, enum mcp_mut_type type) { // around the much larger mcp_mut_entries at runtime. mut->steps[scount].n = mcp_mut_entries[st].n; mut->steps[scount].r = mcp_mut_entries[st].r; - mut->steps[scount].idx++; // actual args are "self, etc, etc" + // actual args are "self, dst, args". start user idx's at 3 + mut->steps[scount].idx += 2; } lua_pop(L, 1); // drop t or nil scount++; diff --git a/t/proxymut.lua b/t/proxymut.lua index 15bda6e05..b036aef22 100644 --- a/t/proxymut.lua +++ b/t/proxymut.lua @@ -40,14 +40,14 @@ function mcp_config_routes(p) -- res with value. local mut_mgresval = mcp.res_mutator_new( { t = "rescodeset", str = "VA" }, - { t = "valcopy", idx = 2, arg = "string" } + { t = "valcopy", idx = 1, arg = "string" } ) -- res with flags. local mut_mgresflag = mcp.res_mutator_new( { t = "rescodeset", str = "HD" }, { t = "flagset", flag = "t", val = "37" }, - { t = "flagcopy", flag = "O", idx = 2 } + { t = "flagcopy", flag = "O", idx = 1 } ) mgfg:ready({