Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
beee7a52
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
beee7a52
编写于
9月 04, 2018
作者:
E
Elad
提交者:
Balint Gabor
9月 04, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmd/swarm: added scaling test for ACT manifests (#17496)
上级
661aa4dc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
6 deletion
+37
-6
cmd/swarm/access_test.go
cmd/swarm/access_test.go
+37
-6
未找到文件。
cmd/swarm/access_test.go
浏览文件 @
beee7a52
...
...
@@ -34,12 +34,15 @@ import (
"time"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/ecies"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/api"
swarm
"github.com/ethereum/go-ethereum/swarm/api/client"
)
var
DefaultCurve
=
crypto
.
S256
()
// TestAccessPassword tests for the correct creation of an ACT manifest protected by a password.
// The test creates bogus content, uploads it encrypted, then creates the wrapping manifest with the Access entry
// The parties participating - node (publisher), uploads to second node then disappears. Content which was uploaded
...
...
@@ -359,11 +362,22 @@ func TestAccessPK(t *testing.T) {
}
}
// TestAccessACT tests the creation of the ACT manifest end-to-end, without any bogus entries (i.e. default scenario = 3 nodes 1 unauthorized)
func
TestAccessACT
(
t
*
testing
.
T
)
{
testAccessACT
(
t
,
0
)
}
// TestAccessACTScale tests the creation of the ACT manifest end-to-end, with 1000 bogus entries (i.e. 1000 EC keys + default scenario = 3 nodes 1 unauthorized = 1003 keys in the ACT manifest)
func
TestAccessACTScale
(
t
*
testing
.
T
)
{
testAccessACT
(
t
,
1000
)
}
// TestAccessACT tests the e2e creation, uploading and downloading of an ACT type access control
// the test fires up a 3 node cluster, then randomly picks 2 nodes which will be acting as grantees to the data
// set. the third node should fail decoding the reference as it will not be granted access. the publisher uploads through
// one of the nodes then disappears.
func
TestAccessACT
(
t
*
testing
.
T
)
{
// one of the nodes then disappears. If `bogusEntries` is bigger than 0, the test will generate the number of bogus act entries
// to test what happens at scale
func
testAccessACT
(
t
*
testing
.
T
,
bogusEntries
int
)
{
// Setup Swarm and upload a test file to it
cluster
:=
newTestCluster
(
t
,
3
)
defer
cluster
.
Shutdown
()
...
...
@@ -415,19 +429,36 @@ func TestAccessACT(t *testing.T) {
grantees
=
append
(
grantees
,
hex
.
EncodeToString
(
granteePubKey
))
}
granteesPubkeyListFile
,
err
:=
ioutil
.
TempFile
(
""
,
"grantees-pubkey-list.csv"
)
if
bogusEntries
>
0
{
bogusGrantees
:=
[]
string
{}
for
i
:=
0
;
i
<
bogusEntries
;
i
++
{
prv
,
err
:=
ecies
.
GenerateKey
(
rand
.
Reader
,
DefaultCurve
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
bogusGrantees
=
append
(
bogusGrantees
,
hex
.
EncodeToString
(
crypto
.
CompressPubkey
(
&
prv
.
ExportECDSA
()
.
PublicKey
)))
}
r2
:=
gorand
.
New
(
gorand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
for
i
:=
0
;
i
<
len
(
grantees
);
i
++
{
insertAtIdx
:=
r2
.
Intn
(
len
(
bogusGrantees
))
bogusGrantees
=
append
(
bogusGrantees
[
:
insertAtIdx
],
append
([]
string
{
grantees
[
i
]},
bogusGrantees
[
insertAtIdx
:
]
...
)
...
)
}
grantees
=
bogusGrantees
}
granteesPubkeyListFile
,
err
:=
ioutil
.
TempFile
(
""
,
"grantees-pubkey-list"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
granteesPubkeyListFile
.
Close
()
defer
os
.
Remove
(
granteesPubkeyListFile
.
Name
())
_
,
err
=
granteesPubkeyListFile
.
WriteString
(
strings
.
Join
(
grantees
,
"
\n
"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
granteesPubkeyListFile
.
Close
()
defer
os
.
Remove
(
granteesPubkeyListFile
.
Name
())
publisherDir
,
err
:=
ioutil
.
TempDir
(
""
,
"swarm-account-dir-temp"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录