From d3aabd7f13a8ad4d6b45767cce04dc284dce5b0f Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Wed, 29 Jan 2025 13:20:38 -0800 Subject: [PATCH] Hex encode the data in dump test (#1637) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses the failure here: https://github.com/valkey-io/valkey/actions/runs/13000845302/job/36259016156#step:5:7272. This change does three things: 1. For some reason TCL 8.5 (which is used on macos) is handling `\x03ba` as `\0xba`, according to https://www.tcl-lang.org/man/tcl8.5/TclCmd/Tcl.htm#M27 so we encode "bar" using hex escapes too. 2. Fix a spacing issue. 3. Make it so that if the restore fails, it immediately errors. --------- Signed-off-by: Madelyn Olson Signed-off-by: Viktor Söderqvist Co-authored-by: Viktor Söderqvist --- tests/unit/dump.tcl | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/unit/dump.tcl b/tests/unit/dump.tcl index 5f1de4f6b..37eaffc0c 100644 --- a/tests/unit/dump.tcl +++ b/tests/unit/dump.tcl @@ -125,22 +125,20 @@ start_server {tags {"dump"}} { } {} {needs:repl} test {RESTORE key with future RDB version, strict version check} { - # str len RDB 222 CRC64 checksum - # | | | | - set bar_dump "\x00\x03bar\xde\x00\x0fYUza\xd3\xec\xe0" - assert_error {ERR DUMP payload version or checksum are wrong} {r restore foo 0 $bar_dump replace} + # str len "bar" RDB 222 CRC64 checksum + # | | | | | + set bar_dump "\x00\x03\x62\x61\x72\xde\x00\x0fYUza\xd3\xec\xe0" + assert_error {ERR DUMP payload version or checksum are wrong} {r restore foo 0 $bar_dump replace} } test {RESTORE key with future RDB version, relaxed version check} { - # str len RDB 222 CRC64 checksum - # | | | | - set bar_dump "\x00\x03bar\xde\x00\x0fYUza\xd3\xec\xe0" - r config set rdb-version-check relaxed - catch {r restore foo 0 $bar_dump replace} e + r config set rdb-version-check relaxed + # |type|len| | RDB | CRC64 | + # |str | 3 | "bar" | 222 | checksum | + r restore foo 0 "\x00\x03\x62\x61\x72\xde\x00\x0fYUza\xd3\xec\xe0" replace r config set rdb-version-check strict assert_equal {bar} [r get foo] - set e - } {OK} + } test {DUMP of non existing key returns nil} { r dump nonexisting_key