swarm: network rewrite merge
This commit is contained in:
@ -17,8 +17,11 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/swarm/storage"
|
||||
)
|
||||
|
||||
func TestParseURI(t *testing.T) {
|
||||
@ -32,6 +35,8 @@ func TestParseURI(t *testing.T) {
|
||||
expectHash bool
|
||||
expectDeprecatedRaw bool
|
||||
expectDeprecatedImmutable bool
|
||||
expectValidKey bool
|
||||
expectAddr storage.Address
|
||||
}
|
||||
tests := []test{
|
||||
{
|
||||
@ -120,24 +125,17 @@ func TestParseURI(t *testing.T) {
|
||||
expectList: true,
|
||||
},
|
||||
{
|
||||
uri: "bzzr:",
|
||||
expectURI: &URI{Scheme: "bzzr"},
|
||||
expectDeprecatedRaw: true,
|
||||
},
|
||||
{
|
||||
uri: "bzzr:/",
|
||||
expectURI: &URI{Scheme: "bzzr"},
|
||||
expectDeprecatedRaw: true,
|
||||
},
|
||||
{
|
||||
uri: "bzzi:",
|
||||
expectURI: &URI{Scheme: "bzzi"},
|
||||
expectDeprecatedImmutable: true,
|
||||
},
|
||||
{
|
||||
uri: "bzzi:/",
|
||||
expectURI: &URI{Scheme: "bzzi"},
|
||||
expectDeprecatedImmutable: true,
|
||||
uri: "bzz-raw://4378d19c26590f1a818ed7d6a62c3809e149b0999cab5ce5f26233b3b423bf8c",
|
||||
expectURI: &URI{Scheme: "bzz-raw",
|
||||
Addr: "4378d19c26590f1a818ed7d6a62c3809e149b0999cab5ce5f26233b3b423bf8c",
|
||||
},
|
||||
expectValidKey: true,
|
||||
expectRaw: true,
|
||||
expectAddr: storage.Address{67, 120, 209, 156, 38, 89, 15, 26,
|
||||
129, 142, 215, 214, 166, 44, 56, 9,
|
||||
225, 73, 176, 153, 156, 171, 92, 229,
|
||||
242, 98, 51, 179, 180, 35, 191, 140,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, x := range tests {
|
||||
@ -166,11 +164,14 @@ func TestParseURI(t *testing.T) {
|
||||
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())
|
||||
}
|
||||
if actual.DeprecatedImmutable() != x.expectDeprecatedImmutable {
|
||||
t.Fatalf("expected %s deprecated immutable to be %t, got %t", x.uri, x.expectDeprecatedImmutable, actual.DeprecatedImmutable())
|
||||
if x.expectValidKey {
|
||||
if actual.Address() == nil {
|
||||
t.Fatalf("expected %s to return a valid key, got nil", x.uri)
|
||||
} else {
|
||||
if !bytes.Equal(x.expectAddr, actual.Address()) {
|
||||
t.Fatalf("expected %s to be decoded to %v", x.expectURI.Addr, x.expectAddr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user