]> git.saurik.com Git - redis.git/blobdiff - tests/unit/scripting.tcl
cluster config file entries added to the example configuration file
[redis.git] / tests / unit / scripting.tcl
index 22b553d011b656c8ddc568e35356d2a96571b77f..d8a2e023e2216ab664951dabae628ab15d8da211 100644 (file)
@@ -123,4 +123,43 @@ start_server {tags {"scripting"}} {
         } e
         set _ $e
     } {*execution time*}
+
+    test {EVAL - Scripts can't run certain commands} {
+        set e {}
+        catch {r eval {return redis.call('spop','x')} 0} e
+        set e
+    } {*not allowed*}
+
+    test {EVAL - Scripts can't run certain commands} {
+        set e {}
+        catch {
+            r eval "redis.call('randomkey'); return redis.call('set','x','ciao')" 0
+        } e
+        set e
+    } {*not allowed after*}
+
+}
+
+start_server {tags {"scripting repl"}} {
+    start_server {} {
+        test {Before the slave connects we issue an EVAL command} {
+            r eval {return redis.call('incr','x')} 0
+        } {1}
+
+        test {Connect a slave to the main instance} {
+            r -1 slaveof [srv 0 host] [srv 0 port]
+            after 1000
+            s -1 role
+        } {slave}
+
+        test {Now use EVALSHA against the master} {
+            r evalsha ae3477e27be955de7e1bc9adfdca626b478d3cb2 0
+        } {2}
+
+        if {$::valgrind} {after 2000} else {after 100}
+
+        test {If EVALSHA was replicated as EVAL the slave should be ok} {
+            r -1 get x
+        } {2}
+    }
 }