Skip to content

Commit ca97dce

Browse files
authored
Merge pull request #183 from codecrafters-io/andy/upgrade
Upgrade hdt3213/rdb to eliminate trailing LF in RDB
2 parents b963c36 + 52acc34 commit ca97dce

File tree

4 files changed

+132
-116
lines changed

4 files changed

+132
-116
lines changed

go.mod

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@ toolchain go1.24.2
66

77
require (
88
github.com/codecrafters-io/tester-utils v0.4.3
9-
github.com/hdt3213/rdb v1.1.0
9+
github.com/hdt3213/rdb v1.1.1
1010
github.com/stretchr/testify v1.10.0
1111
github.com/tidwall/pretty v1.2.1
1212
gopkg.in/yaml.v3 v3.0.1
1313
)
1414

1515
require (
16+
github.com/bytedance/sonic v1.12.1 // indirect
17+
github.com/bytedance/sonic/loader v0.2.0 // indirect
18+
github.com/cloudwego/base64x v0.1.4 // indirect
19+
github.com/cloudwego/iasm v0.2.0 // indirect
1620
github.com/davecgh/go-spew v1.1.1 // indirect
1721
github.com/fatih/color v1.18.0 // indirect
22+
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
1823
github.com/mattn/go-colorable v0.1.14 // indirect
1924
github.com/mattn/go-isatty v0.0.20 // indirect
2025
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
2126
github.com/pmezard/go-difflib v1.0.0 // indirect
27+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
28+
golang.org/x/arch v0.9.0 // indirect
2229
golang.org/x/sys v0.33.0 // indirect
2330
gopkg.in/yaml.v2 v2.4.0 // indirect
2431
)

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
2+
github.com/bytedance/sonic v1.12.1 h1:jWl5Qz1fy7X1ioY74WqO0KjAMtAGQs4sYnjiEBiyX24=
23
github.com/bytedance/sonic v1.12.1/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
34
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
5+
github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM=
46
github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
57
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
68
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
9+
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
710
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
11+
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
812
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
913
github.com/codecrafters-io/tester-utils v0.4.3 h1:ZUA0BCvLK4LJ+yRYrA6nc1s5LymElYkv2JP7rpufhcc=
1014
github.com/codecrafters-io/tester-utils v0.4.3/go.mod h1:Fyrv4IebzjWtvKfpYf8ooYDoOtjYe2qx8bV7KAJpX+w=
@@ -15,7 +19,10 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
1519
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
1620
github.com/hdt3213/rdb v1.1.0 h1:PntkgzBCK5Ss4lncvKAQnWHqb7bCR50/d7LZmNHHk3k=
1721
github.com/hdt3213/rdb v1.1.0/go.mod h1:p2O7ep2/CDdaZt4gywZevL6Vdjash4+imZ0wpinogm8=
22+
github.com/hdt3213/rdb v1.1.1 h1:lrA1DYAEo02rj9qxJXZOP/jq0o8onedBdlcwm6j1vE0=
23+
github.com/hdt3213/rdb v1.1.1/go.mod h1:p2O7ep2/CDdaZt4gywZevL6Vdjash4+imZ0wpinogm8=
1824
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
25+
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
1926
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
2027
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
2128
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
@@ -37,8 +44,10 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
3744
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
3845
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
3946
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
47+
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
4048
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
4149
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
50+
golang.org/x/arch v0.9.0 h1:ub9TgUInamJ8mrZIGlBG6/4TqWeMszd4N8lNorbrr6k=
4251
golang.org/x/arch v0.9.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
4352
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4453
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

internal/test_helpers/fixtures/rdb-read-value-with-expiry/pass

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Debug = true
1313
[tester::#SM4] 0050 | 00 00 00 05 6d 61 6e 67 6f 05 61 70 70 6c 65 fc | ....mango.apple.
1414
[tester::#SM4] 0060 | 00 0c 28 8a c7 01 00 00 00 09 70 69 6e 65 61 70 | ..(.......pineap
1515
[tester::#SM4] 0070 | 70 6c 65 09 62 6c 75 65 62 65 72 72 79 ff 34 d0 | ple.blueberry.4.
16-
[tester::#SM4] 0080 | 8c 58 51 4a 5d 62 0a | .XQJ]b.
16+
[tester::#SM4] 0080 | 8c 58 51 4a 5d 62 | .XQJ]b
1717
[tester::#SM4] 
18-
[tester::#SM4] $ ./spawn_redis_server.sh --dir /private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles929673943 --dbfilename pear.rdb
18+
[tester::#SM4] $ ./spawn_redis_server.sh --dir /private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles3149764048 --dbfilename pear.rdb
1919
[tester::#SM4] client: $ redis-cli GET orange
2020
[tester::#SM4] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$6\r\norange\r\n"
2121
[tester::#SM4] client: Received bytes: "$10\r\nstrawberry\r\n"
@@ -48,9 +48,9 @@ Debug = true
4848
[tester::#DQ3] 0050 | 06 62 61 6e 61 6e 61 05 61 70 70 6c 65 00 05 6d | .banana.apple..m
4949
[tester::#DQ3] 0060 | 61 6e 67 6f 06 6f 72 61 6e 67 65 00 06 6f 72 61 | ango.orange..ora
5050
[tester::#DQ3] 0070 | 6e 67 65 04 70 65 61 72 ff 33 20 d4 0d 23 b2 9b | nge.pear.3 ..#..
51-
[tester::#DQ3] 0080 | af 0a | ..
51+
[tester::#DQ3] 0080 | af | .
5252
[tester::#DQ3] 
53-
[tester::#DQ3] $ ./spawn_redis_server.sh --dir /private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles2186235464 --dbfilename raspberry.rdb
53+
[tester::#DQ3] $ ./spawn_redis_server.sh --dir /private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles1908574589 --dbfilename raspberry.rdb
5454
[tester::#DQ3] client: $ redis-cli GET grape
5555
[tester::#DQ3] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$5\r\ngrape\r\n"
5656
[tester::#DQ3] client: Received bytes: "$9\r\npineapple\r\n"
@@ -85,21 +85,21 @@ Debug = true
8585
[tester::#JW4] Hexdump of RDB file contents: 
8686
[tester::#JW4] Idx | Hex | ASCII
8787
[tester::#JW4] -----+-------------------------------------------------+-----------------
88-
[tester::#JW4] 0000 | 52 45 44 49 53 30 30 31 31 fa 0a 72 65 64 69 73 | REDIS0011..redis
89-
[tester::#JW4] 0010 | 2d 62 69 74 73 c0 40 fa 09 72 65 64 69 73 2d 76 | -[email protected]
90-
[tester::#JW4] 0020 | 65 72 05 37 2e 32 2e 30 fe 00 fb 03 00 00 06 62 | er.7.2.0.......b
88+
[tester::#JW4] 0000 | 52 45 44 49 53 30 30 31 31 fa 09 72 65 64 69 73 | REDIS0011..redis
89+
[tester::#JW4] 0010 | 2d 76 65 72 05 37 2e 32 2e 30 fa 0a 72 65 64 69 | -ver.7.2.0..redi
90+
[tester::#JW4] 0020 | 73 2d 62 69 74 73 c0 40 fe 00 fb 03 00 00 06 62 | s-bits.@.......b
9191
[tester::#JW4] 0030 | 61 6e 61 6e 61 09 70 69 6e 65 61 70 70 6c 65 00 | anana.pineapple.
9292
[tester::#JW4] 0040 | 05 61 70 70 6c 65 09 72 61 73 70 62 65 72 72 79 | .apple.raspberry
9393
[tester::#JW4] 0050 | 00 09 62 6c 75 65 62 65 72 72 79 04 70 65 61 72 | ..blueberry.pear
94-
[tester::#JW4] 0060 | ff 1f f4 52 38 d3 e4 55 25 0a | ...R8..U%.
94+
[tester::#JW4] 0060 | ff 5c f3 42 ee 46 08 a6 3f | .\.B.F..?
9595
[tester::#JW4] 
96-
[tester::#JW4] $ ./spawn_redis_server.sh --dir /private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles102569330 --dbfilename blueberry.rdb
96+
[tester::#JW4] $ ./spawn_redis_server.sh --dir /private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles2192822744 --dbfilename blueberry.rdb
9797
[tester::#JW4] client: $ redis-cli KEYS *
9898
[tester::#JW4] client: Sent bytes: "*2\r\n$4\r\nKEYS\r\n$1\r\n*\r\n"
99-
[tester::#JW4] client: Received bytes: "*3\r\n$6\r\nbanana\r\n$9\r\nblueberry\r\n$5\r\napple\r\n"
100-
[tester::#JW4] client: Received RESP array: ["banana", "blueberry", "apple"]
99+
[tester::#JW4] client: Received bytes: "*3\r\n$9\r\nblueberry\r\n$6\r\nbanana\r\n$5\r\napple\r\n"
100+
[tester::#JW4] client: Received RESP array: ["blueberry", "banana", "apple"]
101101
[tester::#JW4] 
102-
[tester::#JW4] Received ["banana", "blueberry", "apple"]
102+
[tester::#JW4] Received ["blueberry", "banana", "apple"]
103103
[tester::#JW4] 
104104
[tester::#JW4] Test passed.
105105
[tester::#JW4] Terminating program
@@ -114,9 +114,9 @@ Debug = true
114114
[tester::#GC6] 0010 | 2d 76 65 72 05 37 2e 32 2e 30 fa 0a 72 65 64 69 | -ver.7.2.0..redi
115115
[tester::#GC6] 0020 | 73 2d 62 69 74 73 c0 40 fe 00 fb 01 00 00 05 67 | [email protected]
116116
[tester::#GC6] 0030 | 72 61 70 65 09 70 69 6e 65 61 70 70 6c 65 ff 12 | rape.pineapple..
117-
[tester::#GC6] 0040 | 7d 54 51 cd 7a 5c 8d 0a | }TQ.z\..
117+
[tester::#GC6] 0040 | 7d 54 51 cd 7a 5c 8d | }TQ.z\.
118118
[tester::#GC6] 
119-
[tester::#GC6] $ ./spawn_redis_server.sh --dir /private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles3330322718 --dbfilename orange.rdb
119+
[tester::#GC6] $ ./spawn_redis_server.sh --dir /private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles346935627 --dbfilename orange.rdb
120120
[tester::#GC6] client: $ redis-cli GET grape
121121
[tester::#GC6] client: Sent bytes: "*2\r\n$3\r\nGET\r\n$5\r\ngrape\r\n"
122122
[tester::#GC6] client: Received bytes: "$9\r\npineapple\r\n"
@@ -135,9 +135,9 @@ Debug = true
135135
[tester::#JZ6] 0010 | 2d 76 65 72 05 37 2e 32 2e 30 fa 0a 72 65 64 69 | -ver.7.2.0..redi
136136
[tester::#JZ6] 0020 | 73 2d 62 69 74 73 c0 40 fe 00 fb 01 00 00 05 6d | [email protected]
137137
[tester::#JZ6] 0030 | 61 6e 67 6f 09 70 69 6e 65 61 70 70 6c 65 ff 0c | ango.pineapple..
138-
[tester::#JZ6] 0040 | 1b cb 91 b2 ed f6 19 0a | ........
138+
[tester::#JZ6] 0040 | 1b cb 91 b2 ed f6 19 | .......
139139
[tester::#JZ6] 
140-
[tester::#JZ6] $ ./spawn_redis_server.sh --dir /private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles1609755512 --dbfilename pear.rdb
140+
[tester::#JZ6] $ ./spawn_redis_server.sh --dir /private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles327712362 --dbfilename pear.rdb
141141
[tester::#JZ6] client: $ redis-cli KEYS *
142142
[tester::#JZ6] client: Sent bytes: "*2\r\n$4\r\nKEYS\r\n$1\r\n*\r\n"
143143
[tester::#JZ6] client: Received bytes: "*1\r\n$5\r\nmango\r\n"
@@ -150,18 +150,18 @@ Debug = true
150150
[tester::#JZ6] Program terminated successfully
151151

152152
[tester::#ZG5] Running tests for Stage #ZG5 (zg5)
153-
[tester::#ZG5] $ ./spawn_redis_server.sh --dir /private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles2020244584 --dbfilename blueberry.rdb
153+
[tester::#ZG5] $ ./spawn_redis_server.sh --dir /private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles2458619384 --dbfilename blueberry.rdb
154154
[tester::#ZG5] client: $ redis-cli CONFIG GET dir
155155
[tester::#ZG5] client: Sent bytes: "*3\r\n$6\r\nCONFIG\r\n$3\r\nGET\r\n$3\r\ndir\r\n"
156-
[tester::#ZG5] client: Received bytes: "*2\r\n$3\r\ndir\r\n$75\r\n/private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles2020244584\r\n"
156+
[tester::#ZG5] client: Received bytes: "*2\r\n$3\r\ndir\r\n$75\r\n/private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles2458619384\r\n"
157157
[tester::#ZG5] client: Received RESP array: [
158158
[tester::#ZG5]  "dir",
159-
[tester::#ZG5]  "/private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles2020244584"
159+
[tester::#ZG5]  "/private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles2458619384"
160160
[tester::#ZG5] ]
161161
[tester::#ZG5] 
162162
[tester::#ZG5] Received [
163163
[tester::#ZG5]  "dir",
164-
[tester::#ZG5]  "/private/var/folders/sn/8vpsm6lx6m53blpdh2yhlzw40000gn/T/rdbfiles2020244584"
164+
[tester::#ZG5]  "/private/var/folders/nm/b5lzlxrs65vgxg9gg1x477zw0000gn/T/rdbfiles2458619384"
165165
[tester::#ZG5] ]
166166
[tester::#ZG5] 
167167
[tester::#ZG5] Test passed.
@@ -175,15 +175,15 @@ Debug = true
175175
[tester::#YZ1] Received bytes: "+OK\r\n"
176176
[tester::#YZ1] Received RESP simple string: "OK"
177177
[tester::#YZ1] Received "OK"
178-
[tester::#YZ1] Received OK at 09:03:40.627
179-
[tester::#YZ1] Fetching key "strawberry" at 09:03:40.627 (should not be expired)
178+
[tester::#YZ1] Received OK at 19:06:40.492
179+
[tester::#YZ1] Fetching key "strawberry" at 19:06:40.492 (should not be expired)
180180
[tester::#YZ1] > GET strawberry
181181
[tester::#YZ1] Sent bytes: "*2\r\n$3\r\nGET\r\n$10\r\nstrawberry\r\n"
182182
[tester::#YZ1] Received bytes: "$4\r\npear\r\n"
183183
[tester::#YZ1] Received RESP bulk string: "pear"
184184
[tester::#YZ1] Received "pear"
185185
[tester::#YZ1] Sleeping for 101ms
186-
[tester::#YZ1] Fetching key "strawberry" at 09:03:40.730 (should be expired)
186+
[tester::#YZ1] Fetching key "strawberry" at 19:06:40.596 (should be expired)
187187
[tester::#YZ1] > GET strawberry
188188
[tester::#YZ1] Sent bytes: "*2\r\n$3\r\nGET\r\n$10\r\nstrawberry\r\n"
189189
[tester::#YZ1] Received bytes: "$-1\r\n"

0 commit comments

Comments
 (0)