mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 17:03:46 +00:00
swarm/api: add tests for bzzh get path
This commit is contained in:
parent
6928ca2324
commit
745e593028
1 changed files with 32 additions and 1 deletions
|
|
@ -33,7 +33,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/swarm/testutil"
|
||||
)
|
||||
|
||||
func TestBzzrGetPath(t *testing.T) {
|
||||
func TestBzzGetPath(t *testing.T) {
|
||||
|
||||
var err error
|
||||
|
||||
|
|
@ -104,16 +104,47 @@ func TestBzzrGetPath(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
for k, v := range testrequests {
|
||||
var resp *http.Response
|
||||
var respbody []byte
|
||||
|
||||
url := srv.URL + "/bzzh:/"
|
||||
if k[:] != "" {
|
||||
url += common.ToHex(key[0])[2:] + "/" + k[1:]
|
||||
}
|
||||
resp, err = http.Get(url)
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
respbody, err = ioutil.ReadAll(resp.Body)
|
||||
|
||||
if string(respbody) != key[v].String() {
|
||||
isexpectedfailrequest := false
|
||||
|
||||
for _, r := range expectedfailrequests {
|
||||
if k[:] == r {
|
||||
isexpectedfailrequest = true
|
||||
}
|
||||
}
|
||||
if !isexpectedfailrequest {
|
||||
t.Fatalf("Response body does not match, expected: %v, got %v", key[v], string(respbody))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nonhashtests := []string{
|
||||
srv.URL + "/bzz:/name",
|
||||
srv.URL + "/bzzi:/nonhash",
|
||||
srv.URL + "/bzzr:/nonhash",
|
||||
srv.URL + "/bzzh:/nonhash",
|
||||
}
|
||||
|
||||
nonhashresponses := []string{
|
||||
"error resolving name: no DNS to resolve name: "name"",
|
||||
"error resolving nonhash: immutable address not a content hash: "nonhash"",
|
||||
"error resolving nonhash: no DNS to resolve name: "nonhash"",
|
||||
"error resolving nonhash: no DNS to resolve name: "nonhash"",
|
||||
}
|
||||
|
||||
for i, url := range nonhashtests {
|
||||
|
|
|
|||
Loading…
Reference in a new issue