You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.3 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package types
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestResponseQuery(t *testing.T) {
  7. res := ResponseQuery{
  8. Code: CodeTypeOK,
  9. Index: 0,
  10. Key: []byte("hello"),
  11. Value: []byte("world"),
  12. Height: 1,
  13. }
  14. assert.False(t, res.IsErr())
  15. res = ResponseQuery{
  16. Code: 1,
  17. Index: 0,
  18. Key: []byte("hello"),
  19. Value: []byte("world"),
  20. Height: 1,
  21. Log: "bad",
  22. }
  23. assert.True(t, res.IsErr())
  24. assert.Equal(t, "Error code (1): bad", res.Error())
  25. }
  26. func TestResponseDeliverTx(t *testing.T) {
  27. res := ResponseDeliverTx{
  28. Code: CodeTypeOK,
  29. Data: []byte("Victor Mancha"),
  30. }
  31. assert.False(t, res.IsErr())
  32. res = ResponseDeliverTx{
  33. Code: 1,
  34. Log: "bad",
  35. }
  36. assert.True(t, res.IsErr())
  37. assert.Equal(t, "Error code (1): bad", res.Error())
  38. }
  39. func TestResponseCheckTx(t *testing.T) {
  40. res := ResponseCheckTx{
  41. Code: CodeTypeOK,
  42. Data: []byte("Talos"),
  43. }
  44. assert.False(t, res.IsErr())
  45. res = ResponseCheckTx{
  46. Code: 1,
  47. Log: "bad",
  48. }
  49. assert.True(t, res.IsErr())
  50. assert.Equal(t, "Error code (1): bad", res.Error())
  51. }
  52. func TestResponseCommit(t *testing.T) {
  53. res := ResponseCommit{
  54. Code: CodeTypeOK,
  55. Data: []byte("Old Lace"),
  56. }
  57. assert.False(t, res.IsErr())
  58. res = ResponseCommit{
  59. Code: 1,
  60. Log: "bad",
  61. }
  62. assert.True(t, res.IsErr())
  63. assert.Equal(t, "Error code (1): bad", res.Error())
  64. }