swarm/api: fix error reporting in api.Resolve (#14464)

Previously, resolve errors were being swallowed and the returned error
was a generic "not a content hash" which isn't helpful.

This updates the Resolve function to fail fast rather than only
returning an error at the end, and also adds test coverage.
This commit is contained in:
Lewis Marshall
2017-05-12 17:02:25 -07:00
committed by Felix Lange
parent 90c7155ef4
commit b0d0fafd68
3 changed files with 150 additions and 23 deletions

View File

@ -106,9 +106,9 @@ func TestBzzrGetPath(t *testing.T) {
}
nonhashresponses := []string{
"error resolving name: 'name' does not resolve: no DNS to resolve name but is not a content hash\n",
"error resolving nonhash: 'nonhash' is not a content hash\n",
"error resolving nonhash: 'nonhash' does not resolve: no DNS to resolve name but is not a content hash\n",
"error resolving name: no DNS to resolve name: \"name\"\n",
"error resolving nonhash: immutable address not a content hash: \"nonhash\"\n",
"error resolving nonhash: no DNS to resolve name: \"nonhash\"\n",
}
for i, url := range nonhashtests {