From 3590c6188c50df5fd3048100f0760a349d974e0b Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Tue, 2 Apr 2024 02:48:51 +0000 Subject: [PATCH] Ignore 'redis.set_repl()' call --- cmd_scripting_test.go | 14 +++++++++++--- integration/script_test.go | 6 ++++++ lua.go | 9 +++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/cmd_scripting_test.go b/cmd_scripting_test.go index 2ba494ba..b8fcd69f 100644 --- a/cmd_scripting_test.go +++ b/cmd_scripting_test.go @@ -495,9 +495,17 @@ func TestCmdEvalAuth(t *testing.T) { func TestLuaReplicate(t *testing.T) { _, c := runWithClient(t) - mustNil(t, c, - "EVAL", "redis.replicate_commands()", "0", - ) + t.Run("replicate_commands", func(t *testing.T) { + mustNil(t, c, + "EVAL", "redis.replicate_commands()", "0", + ) + }) + + t.Run("set_repl", func(t *testing.T) { + mustNil(t, c, + "EVAL", "redis.set_repl(redis.REPL_NONE)", "0", + ) + }) } func TestLuaTX(t *testing.T) { diff --git a/integration/script_test.go b/integration/script_test.go index 2d4bfc91..d5f5f1ca 100644 --- a/integration/script_test.go +++ b/integration/script_test.go @@ -416,6 +416,12 @@ func TestScriptReplicate(t *testing.T) { "EVAL", `redis.replicate_commands();`, "0", ) }) + + testRaw(t, func(c *client) { + c.Do( + "EVAL", `redis.set_repl(redis.REPL_NONE);`, "0", + ) + }) } func TestScriptTx(t *testing.T) { diff --git a/lua.go b/lua.go index 7c7298cf..ff777a45 100644 --- a/lua.go +++ b/lua.go @@ -161,6 +161,15 @@ func mkLua(srv *server.Server, c *server.Peer, sha string) (map[string]lua.LGFun // ignored return 1 }, + "set_repl": func(l *lua.LState) int { + top := l.GetTop() + if top != 1 { + l.Error(lua.LString("wrong number of arguments"), 1) + return 0 + } + // ignored + return 1 + }, }, luaRedisConstants }