This test is used in the RFC.
(t *testing.T)
| 549 | |
| 550 | // This test is used in the RFC. |
| 551 | func TestRemoteRemoteEquivalence(t *testing.T) { |
| 552 | tt := testutils.T{T: t} |
| 553 | |
| 554 | err1 := errors.New("hello") |
| 555 | err2 := errors.New("hello") |
| 556 | err3 := errors.New("world") |
| 557 | |
| 558 | err1dec := network(err1) |
| 559 | err2dec := network(err2) |
| 560 | err3dec := network(err3) |
| 561 | err1decOther := network(err1) |
| 562 | err2decOther := network(err2) |
| 563 | err3decOther := network(err3) |
| 564 | |
| 565 | // Equivalence is preserved across the network. |
| 566 | tt.Check(markers.Is(err1dec, err1decOther) && |
| 567 | markers.Is(err2dec, err2decOther) && |
| 568 | markers.Is(err3dec, err3decOther)) |
| 569 | tt.Check(markers.Is(err1dec, err2decOther)) |
| 570 | |
| 571 | // Non-equivalence is preserved across the network. |
| 572 | tt.Check(!markers.Is(err1dec, err3decOther) && !markers.Is(err2dec, err3dec)) |
| 573 | |
| 574 | // "m" makes err1w and err3w equivalent. |
| 575 | m := errors.New("mark") |
| 576 | err1w := markers.Mark(err1, m) |
| 577 | err3w := markers.Mark(err3, m) |
| 578 | // "m2" makes err1w and err2w non-equivalent even though err2 and err1 are. |
| 579 | m2 := errors.New("m2") |
| 580 | err2w := markers.Mark(err2, m2) |
| 581 | |
| 582 | err1decw := network(err1w) |
| 583 | err2decw := network(err2w) |
| 584 | err3decw := network(err3w) |
| 585 | err1decwOther := network(err1w) |
| 586 | err2decwOther := network(err2w) |
| 587 | err3decwOther := network(err3w) |
| 588 | |
| 589 | // Equivalence is preserved across the network. |
| 590 | tt.Check(markers.Is(err1decw, err1decwOther) && markers.Is(err1decwOther, err1decw)) |
| 591 | tt.Check(markers.Is(err2decw, err2decwOther) && markers.Is(err2decwOther, err2decw)) |
| 592 | tt.Check(markers.Is(err3decw, err3decwOther) && markers.Is(err3decwOther, err3decw)) |
| 593 | |
| 594 | tt.Check(markers.Is(err1decw, err3decwOther) && markers.Is(err3decw, err1decwOther)) |
| 595 | |
| 596 | // Non-equivalence is preserved across the network. |
| 597 | tt.Check(!markers.Is(err1decw, err2decwOther) && !markers.Is(err2decw, err1decwOther)) |
| 598 | } |
| 599 | |
| 600 | // This test demonstrates why it is important to use all the types of the |
| 601 | // causes and not just the type of the first layer of wrapper. |