aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/uri_test.go
diff options
context:
space:
mode:
authorJanoš Guljaš <janos@users.noreply.github.com>2017-12-21 20:47:10 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-12-21 20:47:10 +0800
commit542d51895f54b9f869379cf4ad5549c82e525711 (patch)
tree4f485778b2c28de2d7c4ab446407e7f01eab9b20 /swarm/api/uri_test.go
parent5258785c81959109138ebeca613f12c277188abc (diff)
downloadgo-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar.gz
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.tar.zst
go-tangerine-542d51895f54b9f869379cf4ad5549c82e525711.zip
swarm/api: url scheme bzz-hash to get hashes of swarm content (#15238) (#15715)
* swarm/api: url scheme bzz-hash to get hashes of swarm content (#15238) Update URI to support bzz-hash scheme and handle such HTTP requests by responding with hash of the content as a text/plain response. * swarm/api: return hash of the content for bzz-hash:// requests * swarm/api: revert "return hash of the content for bzz-hash:// requests" Return hashes of the content that would be returned by bzz-raw request. * swarm/api/http: handle error in TestBzzGetPath * swarm/api: remove extra blank line in comment
Diffstat (limited to 'swarm/api/uri_test.go')
-rw-r--r--swarm/api/uri_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/swarm/api/uri_test.go b/swarm/api/uri_test.go
index babb2834e..137b4505d 100644
--- a/swarm/api/uri_test.go
+++ b/swarm/api/uri_test.go
@@ -29,6 +29,7 @@ func TestParseURI(t *testing.T) {
expectRaw bool
expectImmutable bool
expectList bool
+ expectHash bool
expectDeprecatedRaw bool
expectDeprecatedImmutable bool
}
@@ -99,6 +100,16 @@ func TestParseURI(t *testing.T) {
expectURI: &URI{Scheme: "bzz", Addr: "abc123", Path: "path/to/entry"},
},
{
+ uri: "bzz-hash:",
+ expectURI: &URI{Scheme: "bzz-hash"},
+ expectHash: true,
+ },
+ {
+ uri: "bzz-hash:/",
+ expectURI: &URI{Scheme: "bzz-hash"},
+ expectHash: true,
+ },
+ {
uri: "bzz-list:",
expectURI: &URI{Scheme: "bzz-list"},
expectList: true,
@@ -152,6 +163,9 @@ func TestParseURI(t *testing.T) {
if actual.List() != x.expectList {
t.Fatalf("expected %s list to be %t, got %t", x.uri, x.expectList, actual.List())
}
+ if actual.Hash() != x.expectHash {
+ t.Fatalf("expected %s hash to be %t, got %t", x.uri, x.expectHash, actual.Hash())
+ }
if actual.DeprecatedRaw() != x.expectDeprecatedRaw {
t.Fatalf("expected %s deprecated raw to be %t, got %t", x.uri, x.expectDeprecatedRaw, actual.DeprecatedRaw())
}