diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl
index ec5230bf..a17892d3 100644
--- a/tests/unit/scripting.tcl
+++ b/tests/unit/scripting.tcl
@@ -417,5 +417,17 @@ start_server {tags {"scripting repl"}} {
             }
             set res
         } {a 1}
+
+        test {EVALSHA replication when first call is readonly} {
+            r del x
+            r eval {if tonumber(KEYS[1]) > 0 then redis.call('incr', 'x') end} 1 0
+            r evalsha 38fe3ddf5284a1d48f37f824b4c4e826879f3cb9 1 0
+            r evalsha 38fe3ddf5284a1d48f37f824b4c4e826879f3cb9 1 1
+            wait_for_condition 50 100 {
+                [r -1 get x] eq {1}
+            } else {
+                fail "Expected 1 in x, but value is '[r -1 get x]'"
+            }
+        }
     }
 }