Redis Challenge #CF8

I am stuck on sending an empty rdb file to the replica. I am able to send a correctly parsed rdb file, but the test runner says

Error: Expected 176 bytes of data in RDB file message, got 116

This is the code theat generates the rdb file:

pub fn str_from_empty() -> String {
    let whitespace = &[' ', '\t', '\n', '\r'] as &[_];
    let hex_string = "52 45 44 49 53 30 30 31  31 fa 09 72 65 64 69 73 
                            2d 76 65 72 05 37 2e 32  2e 35 fa 0a 72 65 64 69  
                            73 2d 62 69 74 73 c0 40  fa 05 63 74 69 6d 65 c2 
                            c4 56 0a 67 fa 08 75 73  65 64 2d 6d 65 6d c2 70
                            52 13 00 fa 08 61 6f 66  2d 62 61 73 65 c0 00 ff
                            8e 5e 7f 5f b5 78 4f ce".replace(whitespace, "");                           


    format!("${}\r\n{}", hex_string.len(), String::from_utf8_lossy(&crate::util::util::hex_to_binary(&hex_string)))
}

pub fn hex_to_binary(hex: &str) -> Vec<u8> {
    hex.as_bytes().chunks(2).map(|byte| u8::from_str_radix(std::str::from_utf8(byte).unwrap(), 16).unwrap()).collect()
}

Can anyone tell me why this file is not the correct number of bytes?

Actually, my bad. I needed to pass the legth of string after removing whitespace. The real error is:

client: Received bytes: "$120\r\nREDIS0011�\tredis-ver\x057.2.0�\nredis-bits�@�\x05ctime�m\b�e�\bused-mem°�\x10\x00�\baof-base�\x00��n;���Z�"
[tester::#CF8] Invalid RDB file: illegal length encoding: bf
[tester::#CF8] Test failed

@paebanks Looks like you’ve got past #CF8 (Replication - Empty RDB Transfer). :tada:

Feel free to post again if you need any further help or run into any more issues.

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.