protocol.tcl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. start_server {tags {"protocol"}} {
  2. test "Handle an empty query" {
  3. reconnect
  4. r write "\r\n"
  5. r flush
  6. assert_equal "PONG" [r ping]
  7. }
  8. test "Negative multibulk length" {
  9. reconnect
  10. r write "*-10\r\n"
  11. r flush
  12. assert_equal PONG [r ping]
  13. }
  14. test "Out of range multibulk length" {
  15. reconnect
  16. r write "*20000000\r\n"
  17. r flush
  18. assert_error "*invalid multibulk length*" {r read}
  19. }
  20. test "Wrong multibulk payload header" {
  21. reconnect
  22. r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\nfooz\r\n"
  23. r flush
  24. assert_error "*expected '$', got 'f'*" {r read}
  25. }
  26. test "Negative multibulk payload length" {
  27. reconnect
  28. r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$-10\r\n"
  29. r flush
  30. assert_error "*invalid bulk length*" {r read}
  31. }
  32. test "Out of range multibulk payload length" {
  33. reconnect
  34. r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$2000000000\r\n"
  35. r flush
  36. assert_error "*invalid bulk length*" {r read}
  37. }
  38. test "Non-number multibulk payload length" {
  39. reconnect
  40. r write "*3\r\n\$3\r\nSET\r\n\$1\r\nx\r\n\$blabla\r\n"
  41. r flush
  42. assert_error "*invalid bulk length*" {r read}
  43. }
  44. test "Multi bulk request not followed by bulk arguments" {
  45. reconnect
  46. r write "*1\r\nfoo\r\n"
  47. r flush
  48. assert_error "*expected '$', got 'f'*" {r read}
  49. }
  50. test "Generic wrong number of args" {
  51. reconnect
  52. assert_error "*wrong*arguments*ping*" {r ping x y z}
  53. }
  54. }