Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
0cb82d5c
提交
0cb82d5c
authored
2月 08, 2019
作者:
Łukasz Magiera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
coreapi: cleanup coredag references in interface
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
33575e03
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
56 行增加
和
51 行删除
+56
-51
dag.go
core/coreapi/interface/tests/dag.go
+27
-26
path.go
core/coreapi/interface/tests/path.go
+17
-15
pin.go
core/coreapi/interface/tests/pin.go
+12
-10
没有找到文件。
core/coreapi/interface/tests/dag.go
浏览文件 @
0cb82d5c
...
...
@@ -8,8 +8,9 @@ import (
"testing"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
coredag
"github.com/ipfs/go-ipfs/core/coredag"
ipld
"gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format"
ipldcbor
"gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor"
mh
"gx/ipfs/QmerPMzPk1mJVowm8KgmoknWa4yCYvvugMPsgWmDNUvDLW/go-multihash"
)
...
...
@@ -46,18 +47,18 @@ func (tp *provider) TestPut(t *testing.T) {
t
.
Error
(
err
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`"Hello"`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`"Hello"`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
s
[
0
]
)
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
nd
s
[
0
]
.
Cid
()
.
String
()
!=
"zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv"
{
t
.
Errorf
(
"got wrong cid: %s"
,
nd
s
[
0
]
.
Cid
()
.
String
())
if
nd
.
Cid
()
.
String
()
!=
"zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv"
{
t
.
Errorf
(
"got wrong cid: %s"
,
nd
.
Cid
()
.
String
())
}
}
...
...
@@ -69,18 +70,18 @@ func (tp *provider) TestPutWithHash(t *testing.T) {
t
.
Error
(
err
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`"Hello"`
),
mh
.
ID
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`"Hello"`
),
mh
.
ID
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
s
[
0
]
)
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
nd
s
[
0
]
.
Cid
()
.
String
()
!=
"z5hRLNd2sv4z1c"
{
t
.
Errorf
(
"got wrong cid: %s"
,
nd
s
[
0
]
.
Cid
()
.
String
())
if
nd
.
Cid
()
.
String
()
!=
"z5hRLNd2sv4z1c"
{
t
.
Errorf
(
"got wrong cid: %s"
,
nd
.
Cid
()
.
String
())
}
}
...
...
@@ -92,27 +93,27 @@ func (tp *provider) TestDagPath(t *testing.T) {
t
.
Error
(
err
)
}
snd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`"foo"`
),
math
.
MaxUint64
,
-
1
)
snd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`"foo"`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
err
=
api
.
Dag
()
.
Add
(
ctx
,
snd
s
[
0
]
)
err
=
api
.
Dag
()
.
Add
(
ctx
,
snd
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"lnk": {"/": "`
+
snds
[
0
]
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"lnk": {"/": "`
+
snd
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
s
[
0
]
)
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
p
,
err
:=
coreiface
.
ParsePath
(
path
.
Join
(
nd
s
[
0
]
.
Cid
()
.
String
(),
"lnk"
))
p
,
err
:=
coreiface
.
ParsePath
(
path
.
Join
(
nd
.
Cid
()
.
String
(),
"lnk"
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -122,13 +123,13 @@ func (tp *provider) TestDagPath(t *testing.T) {
t
.
Error
(
err
)
}
nd
,
err
:=
api
.
Dag
()
.
Get
(
ctx
,
rp
.
Cid
())
nd
d
,
err
:=
api
.
Dag
()
.
Get
(
ctx
,
rp
.
Cid
())
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
nd
.
Cid
()
.
String
()
!=
snd
s
[
0
]
.
Cid
()
.
String
()
{
t
.
Errorf
(
"got unexpected cid %s, expected %s"
,
nd
.
Cid
()
.
String
(),
snds
[
0
]
.
Cid
()
.
String
())
if
nd
.
Cid
()
.
String
()
!=
snd
.
Cid
()
.
String
()
{
t
.
Errorf
(
"got unexpected cid %s, expected %s"
,
nd
d
.
Cid
()
.
String
(),
snd
.
Cid
()
.
String
())
}
}
...
...
@@ -140,17 +141,17 @@ func (tp *provider) TestTree(t *testing.T) {
t
.
Error
(
err
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"a": 123, "b": "foo", "c": {"d": 321, "e": 111}}`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"a": 123, "b": "foo", "c": {"d": 321, "e": 111}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
s
[
0
]
)
err
=
api
.
Dag
()
.
Add
(
ctx
,
nd
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
res
,
err
:=
api
.
Dag
()
.
Get
(
ctx
,
nd
s
[
0
]
.
Cid
())
res
,
err
:=
api
.
Dag
()
.
Get
(
ctx
,
nd
.
Cid
())
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -175,25 +176,25 @@ func (tp *provider) TestBatch(t *testing.T) {
t
.
Error
(
err
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`"Hello"`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`"Hello"`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
nd
s
[
0
]
.
Cid
()
.
String
()
!=
"zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv"
{
t
.
Errorf
(
"got wrong cid: %s"
,
nd
s
[
0
]
.
Cid
()
.
String
())
if
nd
.
Cid
()
.
String
()
!=
"zdpuAqckYF3ToF3gcJNxPZXmnmGuXd3gxHCXhq81HGxBejEvv"
{
t
.
Errorf
(
"got wrong cid: %s"
,
nd
.
Cid
()
.
String
())
}
_
,
err
=
api
.
Dag
()
.
Get
(
ctx
,
nd
s
[
0
]
.
Cid
())
_
,
err
=
api
.
Dag
()
.
Get
(
ctx
,
nd
.
Cid
())
if
err
==
nil
||
!
strings
.
Contains
(
err
.
Error
(),
"not found"
)
{
t
.
Error
(
err
)
}
if
err
:=
api
.
Dag
()
.
AddMany
(
ctx
,
nds
);
err
!=
nil
{
if
err
:=
api
.
Dag
()
.
AddMany
(
ctx
,
[]
ipld
.
Node
{
nd
}
);
err
!=
nil
{
t
.
Error
(
err
)
}
_
,
err
=
api
.
Dag
()
.
Get
(
ctx
,
nd
s
[
0
]
.
Cid
())
_
,
err
=
api
.
Dag
()
.
Get
(
ctx
,
nd
.
Cid
())
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
core/coreapi/interface/tests/path.go
浏览文件 @
0cb82d5c
...
...
@@ -8,7 +8,8 @@ import (
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
"github.com/ipfs/go-ipfs/core/coredag"
ipldcbor
"gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor"
)
func
(
tp
*
provider
)
TestPath
(
t
*
testing
.
T
)
{
...
...
@@ -37,7 +38,8 @@ func (tp *provider) TestMutablePath(t *testing.T) {
t
.
Error
(
"expected /ipld path to be immutable"
)
}
// get self /ipns path
// get self /ipns path ipldcbor "gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor"
if
api
.
Key
()
==
nil
{
t
.
Fatal
(
".Key not implemented"
)
}
...
...
@@ -64,16 +66,16 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
t
.
Fatal
(
".Dag not implemented"
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
:=
api
.
Dag
()
.
Add
Many
(
ctx
,
nds
);
err
!=
nil
{
if
err
:=
api
.
Dag
()
.
Add
(
ctx
,
nd
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
p1
,
err
:=
coreiface
.
ParsePath
(
nd
s
[
0
]
.
String
()
+
"/foo/bar"
)
p1
,
err
:=
coreiface
.
ParsePath
(
nd
.
String
()
+
"/foo/bar"
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -100,16 +102,16 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
t
.
Fatal
(
".Dag not implemented"
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
:=
api
.
Dag
()
.
Add
Many
(
ctx
,
nds
);
err
!=
nil
{
if
err
:=
api
.
Dag
()
.
Add
(
ctx
,
nd
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
p1
,
err
:=
coreiface
.
ParsePath
(
nd
s
[
0
]
.
Cid
()
.
String
())
p1
,
err
:=
coreiface
.
ParsePath
(
nd
.
Cid
()
.
String
())
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -136,16 +138,16 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
t
.
Fatal
(
".Dag not implemented"
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
:=
api
.
Dag
()
.
Add
Many
(
ctx
,
nds
);
err
!=
nil
{
if
err
:=
api
.
Dag
()
.
Add
(
ctx
,
nd
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
p1
,
err
:=
coreiface
.
ParsePath
(
"/ipld/"
+
nd
s
[
0
]
.
Cid
()
.
String
()
+
"/bar/baz"
)
p1
,
err
:=
coreiface
.
ParsePath
(
"/ipld/"
+
nd
.
Cid
()
.
String
()
+
"/bar/baz"
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -177,16 +179,16 @@ func (tp *provider) TestPathRoot(t *testing.T) {
t
.
Fatal
(
".Dag not implemented"
)
}
nd
s
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"foo": {"/": "`
+
blk
.
Path
()
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
nd
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"foo": {"/": "`
+
blk
.
Path
()
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
:=
api
.
Dag
()
.
Add
Many
(
ctx
,
nds
);
err
!=
nil
{
if
err
:=
api
.
Dag
()
.
Add
(
ctx
,
nd
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
p1
,
err
:=
coreiface
.
ParsePath
(
"/ipld/"
+
nd
s
[
0
]
.
Cid
()
.
String
()
+
"/foo"
)
p1
,
err
:=
coreiface
.
ParsePath
(
"/ipld/"
+
nd
.
Cid
()
.
String
()
+
"/foo"
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -196,7 +198,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
t
.
Fatal
(
err
)
}
if
rp
.
Root
()
.
String
()
!=
nd
s
[
0
]
.
Cid
()
.
String
()
{
if
rp
.
Root
()
.
String
()
!=
nd
.
Cid
()
.
String
()
{
t
.
Error
(
"unexpected path root"
)
}
...
...
core/coreapi/interface/tests/pin.go
浏览文件 @
0cb82d5c
...
...
@@ -8,7 +8,9 @@ import (
"github.com/ipfs/go-ipfs/core/coreapi/interface"
opt
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
"github.com/ipfs/go-ipfs/core/coredag"
ipld
"gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format"
ipldcbor
"gx/ipfs/QmRZxJ7oybgnnwriuRub9JXp5YdFM9wiGSyRq38QC7swpS/go-ipld-cbor"
)
func
(
tp
*
provider
)
TestPin
(
t
*
testing
.
T
)
{
...
...
@@ -111,26 +113,26 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
t
.
Error
(
err
)
}
nd2
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"lnk": {"/": "`
+
p0
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
nd2
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"lnk": {"/": "`
+
p0
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
nd3
,
err
:=
coredag
.
ParseInputs
(
"json"
,
"dag-cbor"
,
strings
.
NewReader
(
`{"lnk": {"/": "`
+
p1
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
nd3
,
err
:=
ipldcbor
.
FromJSON
(
strings
.
NewReader
(
`{"lnk": {"/": "`
+
p1
.
Cid
()
.
String
()
+
`"}}`
),
math
.
MaxUint64
,
-
1
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
if
err
:=
api
.
Dag
()
.
AddMany
(
ctx
,
append
(
nd2
,
nd3
...
)
);
err
!=
nil
{
if
err
:=
api
.
Dag
()
.
AddMany
(
ctx
,
[]
ipld
.
Node
{
nd2
,
nd3
}
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
api
.
Pin
()
.
Add
(
ctx
,
iface
.
IpldPath
(
nd2
[
0
]
.
Cid
()))
err
=
api
.
Pin
()
.
Add
(
ctx
,
iface
.
IpldPath
(
nd2
.
Cid
()))
if
err
!=
nil
{
t
.
Error
(
err
)
}
err
=
api
.
Pin
()
.
Add
(
ctx
,
iface
.
IpldPath
(
nd3
[
0
]
.
Cid
()),
opt
.
Pin
.
Recursive
(
false
))
err
=
api
.
Pin
()
.
Add
(
ctx
,
iface
.
IpldPath
(
nd3
.
Cid
()),
opt
.
Pin
.
Recursive
(
false
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
...
...
@@ -153,8 +155,8 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
t
.
Errorf
(
"unexpected pin list len: %d"
,
len
(
list
))
}
if
list
[
0
]
.
Path
()
.
String
()
!=
iface
.
IpldPath
(
nd3
[
0
]
.
Cid
())
.
String
()
{
t
.
Errorf
(
"unexpected path, %s != %s"
,
list
[
0
]
.
Path
()
.
String
(),
iface
.
IpfsPath
(
nd2
[
0
]
.
Cid
())
.
String
())
if
list
[
0
]
.
Path
()
.
String
()
!=
iface
.
IpldPath
(
nd3
.
Cid
())
.
String
()
{
t
.
Errorf
(
"unexpected path, %s != %s"
,
list
[
0
]
.
Path
()
.
String
(),
iface
.
IpfsPath
(
nd2
.
Cid
())
.
String
())
}
list
,
err
=
api
.
Pin
()
.
Ls
(
ctx
,
opt
.
Pin
.
Type
.
Recursive
())
...
...
@@ -166,8 +168,8 @@ func (tp *provider) TestPinRecursive(t *testing.T) {
t
.
Errorf
(
"unexpected pin list len: %d"
,
len
(
list
))
}
if
list
[
0
]
.
Path
()
.
String
()
!=
iface
.
IpldPath
(
nd2
[
0
]
.
Cid
())
.
String
()
{
t
.
Errorf
(
"unexpected path, %s != %s"
,
list
[
0
]
.
Path
()
.
String
(),
iface
.
IpldPath
(
nd3
[
0
]
.
Cid
())
.
String
())
if
list
[
0
]
.
Path
()
.
String
()
!=
iface
.
IpldPath
(
nd2
.
Cid
())
.
String
()
{
t
.
Errorf
(
"unexpected path, %s != %s"
,
list
[
0
]
.
Path
()
.
String
(),
iface
.
IpldPath
(
nd3
.
Cid
())
.
String
())
}
list
,
err
=
api
.
Pin
()
.
Ls
(
ctx
,
opt
.
Pin
.
Type
.
Indirect
())
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论