TestRequestWithOverride validates requests that have an overridden type. For requests with type overrides, we double-serialize the request to ensure the resulting encoding of the overridden and original type are identical.
(t *testing.T, version int16, msg protocol.Message)
| 49 | // TestRequestWithOverride validates requests that have an overridden type. For requests with type overrides, we |
| 50 | // double-serialize the request to ensure the resulting encoding of the overridden and original type are identical. |
| 51 | func TestRequestWithOverride(t *testing.T, version int16, msg protocol.Message) { |
| 52 | reset := load(msg) |
| 53 | |
| 54 | t.Run(fmt.Sprintf("v%d", version), func(t *testing.T) { |
| 55 | b1 := &bytes.Buffer{} |
| 56 | |
| 57 | if err := protocol.WriteRequest(b1, version, 1234, "me", msg); err != nil { |
| 58 | t.Fatal(err) |
| 59 | } |
| 60 | |
| 61 | reset() |
| 62 | t.Logf("\n%s\n", hex.Dump(b1.Bytes())) |
| 63 | |
| 64 | _, _, _, req, err := protocol.ReadRequest(b1) |
| 65 | if err != nil { |
| 66 | t.Fatal(err) |
| 67 | } |
| 68 | |
| 69 | b2 := &bytes.Buffer{} |
| 70 | if err := protocol.WriteRequest(b2, version, 1234, "me", req); err != nil { |
| 71 | t.Fatal(err) |
| 72 | } |
| 73 | |
| 74 | if !deepEqual(b1, b2) { |
| 75 | t.Errorf("request message mismatch:") |
| 76 | t.Logf("expected: %+v", hex.Dump(b1.Bytes())) |
| 77 | t.Logf("found: %+v", hex.Dump(b2.Bytes())) |
| 78 | } |
| 79 | }) |
| 80 | } |
| 81 | |
| 82 | func BenchmarkRequest(b *testing.B, version int16, msg protocol.Message) { |
| 83 | reset := load(msg) |
no test coverage detected