Hex encode the data in dump test (#1637)

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 <madelyneolson@gmail.com>
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
This commit is contained in:
Madelyn Olson 2025-01-29 13:20:38 -08:00 committed by GitHub
parent ff8a528fd6
commit d3aabd7f13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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