@ -33,7 +33,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/testutil"
"github.com/ethereum/go-ethereum/swarm/testutil"
)
)
func TestBzzr GetPath ( t * testing . T ) {
func TestBzzGetPath ( t * testing . T ) {
var err error
var err error
@ -104,6 +104,38 @@ func TestBzzrGetPath(t *testing.T) {
}
}
}
}
for k , v := range testrequests {
var resp * http . Response
var respbody [ ] byte
url := srv . URL + "/bzz-hash:/"
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 err != nil {
t . Fatalf ( "Read request body: %v" , err )
}
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 ) )
}
}
}
for _ , c := range [ ] struct {
for _ , c := range [ ] struct {
path string
path string
json string
json string
@ -197,6 +229,7 @@ func TestBzzrGetPath(t *testing.T) {
srv . URL + "/bzz-immutable:/nonhash" ,
srv . URL + "/bzz-immutable:/nonhash" ,
srv . URL + "/bzz-raw:/nonhash" ,
srv . URL + "/bzz-raw:/nonhash" ,
srv . URL + "/bzz-list:/nonhash" ,
srv . URL + "/bzz-list:/nonhash" ,
srv . URL + "/bzz-hash:/nonhash" ,
}
}
nonhashresponses := [ ] string {
nonhashresponses := [ ] string {
@ -204,6 +237,7 @@ func TestBzzrGetPath(t *testing.T) {
"error resolving nonhash: immutable address not a content hash: "nonhash"" ,
"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"" ,
"error resolving nonhash: no DNS to resolve name: "nonhash"" ,
"error resolving nonhash: no DNS to resolve name: "nonhash"" ,
"error resolving nonhash: no DNS to resolve name: "nonhash"" ,
}
}
for i , url := range nonhashtests {
for i , url := range nonhashtests {