light: fix provider error plumbing (#7610)

The custom error types in the provider package did not propagate their wrapped
underlying reasons, making it difficult for the test to check that the correct
error was observed.

- Fix the custom errors to have a true underlying error (not just a string).
- Add Unwrap methods to support inspection by errors.Is.
- Update usage in a few places.
- Fix the test to check for acceptable variation.

Fixes #7609.
This commit is contained in:
M. J. Fromberger
2022-01-16 13:48:21 -08:00
committed by GitHub
parent c24f003b55
commit 679b6a65b8
4 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ func (p *BlockProvider) LightBlock(ctx context.Context, height int64) (*types.Li
case errPeerAlreadyBusy:
return nil, provider.ErrLightBlockNotFound
default:
return nil, provider.ErrUnreliableProvider{Reason: err.Error()}
return nil, provider.ErrUnreliableProvider{Reason: err}
}
// check that the height requested is the same one returned