(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestUnknownWrapperTraversalWithMessageOverride(t *testing.T) { |
| 28 | // Simulating scenario where the new field on the opaque wrapper is dropped |
| 29 | // in the middle of the chain by a node running an older version. |
| 30 | |
| 31 | origErr := fmt.Errorf("this is a wrapped err %w with a non-prefix wrap msg", errors.New("hello")) |
| 32 | t.Logf("start err: %# v", pretty.Formatter(origErr)) |
| 33 | |
| 34 | // Encode the error, this will use the encoder. |
| 35 | enc := EncodeError(context.Background(), origErr) |
| 36 | t.Logf("encoded: %# v", pretty.Formatter(enc)) |
| 37 | |
| 38 | newErr := DecodeError(context.Background(), enc) |
| 39 | t.Logf("decoded: %# v", pretty.Formatter(newErr)) |
| 40 | |
| 41 | // simulate node not knowing about `messageType` field |
| 42 | newErr.(*opaqueWrapper).messageType = Prefix |
| 43 | |
| 44 | // Encode it again, to simulate the error passed on to another system. |
| 45 | enc2 := EncodeError(context.Background(), newErr) |
| 46 | t.Logf("encoded2: %# v", pretty.Formatter(enc)) |
| 47 | |
| 48 | // Then decode again. |
| 49 | newErr2 := DecodeError(context.Background(), enc2) |
| 50 | t.Logf("decoded: %# v", pretty.Formatter(newErr2)) |
| 51 | |
| 52 | tt := testutils.T{T: t} |
| 53 | |
| 54 | // We expect to see an erroneous `: hello` because our |
| 55 | // error passes through a node which drops the new protobuf |
| 56 | // field. |
| 57 | tt.CheckEqual(newErr2.Error(), origErr.Error()+": hello") |
| 58 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…