fix tests that use invalid peer IDs
Our code now better validates peer IDs. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Jan 25, 2018 at 14:32 UTC
8899e986703ad4f597c637564e2d59d3c2bb8645
4 files changed
+10
-6
core/coreapi/key_test.go
+1
-1
@@ -31,7 +31,7 @@ func TestListSelf(t *testing.T) {
31
t.Errorf("expected the key to be called 'self', got '%s'", keys[0].Name())
32
}
33
34
- if keys[0].Path().String() != "/ipns/Qmfoo" {
34
+ if keys[0].Path().String() != "/ipns/"+testPeerID {
35
t.Errorf("expected the key to have path '/ipns/Qmfoo', got '%s'", keys[0].Path().String())
36
}
37
}
core/coreapi/unixfs_test.go
+3
-1
@@ -25,6 +25,8 @@ import (
25
ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto"
26
)
27
28
+const testPeerID = "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe"
29
+
30
// `echo -n 'hello, world!' | ipfs add`
31
var hello = coreapi.ResolvedPath("/ipfs/QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk", nil, nil)
32
var helloStr = "hello, world!"
@@ -59,7 +61,7 @@ func makeAPIIdent(ctx context.Context, fullIdentity bool) (*core.IpfsNode, corei
61
}
62
} else {
63
ident = config.Identity{
62
- PeerID: "Qmfoo",
64
+ PeerID: testPeerID,
65
}
66
}
67
core/corehttp/gateway_test.go
+1
-1
@@ -55,7 +55,7 @@ func (m mockNamesys) GetResolver(subs string) (namesys.Resolver, bool) {
55
func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) {
56
c := config.Config{
57
Identity: config.Identity{
58
- PeerID: "Qmfoo", // required by offline node
58
+ PeerID: "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe", // required by offline node
59
},
60
}
61
r := &repo.Mock{
core/coreunix/add_test.go
+5
-3
@@ -25,11 +25,13 @@ import (
25
"gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
26
)
27
28
+const testPeerID = "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe"
29
+
30
func TestAddRecursive(t *testing.T) {
31
r := &repo.Mock{
32
C: config.Config{
33
Identity: config.Identity{
32
- PeerID: "Qmfoo", // required by offline node
34
+ PeerID: testPeerID, // required by offline node
35
},
36
},
37
D: ds2.ThreadSafeCloserMapDatastore(),
@@ -49,7 +51,7 @@ func TestAddGCLive(t *testing.T) {
51
r := &repo.Mock{
52
C: config.Config{
53
Identity: config.Identity{
52
- PeerID: "Qmfoo", // required by offline node
54
+ PeerID: testPeerID, // required by offline node
55
},
56
},
57
D: ds2.ThreadSafeCloserMapDatastore(),
@@ -158,7 +160,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) {
160
r := &repo.Mock{
161
C: config.Config{
162
Identity: config.Identity{
161
- PeerID: "Qmfoo", // required by offline node
163
+ PeerID: testPeerID, // required by offline node
164
},
165
},
166
D: ds2.ThreadSafeCloserMapDatastore(),