Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
beee7a52
Commit
beee7a52
authored
Sep 04, 2018
by
Elad
Committed by
Balint Gabor
Sep 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/swarm: added scaling test for ACT manifests (#17496)
parent
661aa4dc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
6 deletions
+37
-6
access_test.go
cmd/swarm/access_test.go
+37
-6
No files found.
cmd/swarm/access_test.go
View file @
beee7a52
...
@@ -34,12 +34,15 @@ import (
...
@@ -34,12 +34,15 @@ import (
"time"
"time"
"github.com/ethereum/go-ethereum/crypto"
"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/crypto/sha3"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/api"
"github.com/ethereum/go-ethereum/swarm/api"
swarm
"github.com/ethereum/go-ethereum/swarm/api/client"
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.
// 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 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
// The parties participating - node (publisher), uploads to second node then disappears. Content which was uploaded
...
@@ -359,11 +362,22 @@ func TestAccessPK(t *testing.T) {
...
@@ -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
// 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
// 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
// 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.
// one of the nodes then disappears. If `bogusEntries` is bigger than 0, the test will generate the number of bogus act entries
func
TestAccessACT
(
t
*
testing
.
T
)
{
// to test what happens at scale
func
testAccessACT
(
t
*
testing
.
T
,
bogusEntries
int
)
{
// Setup Swarm and upload a test file to it
// Setup Swarm and upload a test file to it
cluster
:=
newTestCluster
(
t
,
3
)
cluster
:=
newTestCluster
(
t
,
3
)
defer
cluster
.
Shutdown
()
defer
cluster
.
Shutdown
()
...
@@ -415,19 +429,36 @@ func TestAccessACT(t *testing.T) {
...
@@ -415,19 +429,36 @@ func TestAccessACT(t *testing.T) {
grantees
=
append
(
grantees
,
hex
.
EncodeToString
(
granteePubKey
))
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
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
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
}
_
,
err
=
granteesPubkeyListFile
.
WriteString
(
strings
.
Join
(
grantees
,
"
\n
"
)
)
granteesPubkeyListFile
,
err
:=
ioutil
.
TempFile
(
""
,
"grantees-pubkey-list"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
granteesPubkeyListFile
.
Close
()
defer
granteesPubkeyListFile
.
Close
()
defer
os
.
Remove
(
granteesPubkeyListFile
.
Name
())
defer
os
.
Remove
(
granteesPubkeyListFile
.
Name
())
_
,
err
=
granteesPubkeyListFile
.
WriteString
(
strings
.
Join
(
grantees
,
"
\n
"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
publisherDir
,
err
:=
ioutil
.
TempDir
(
""
,
"swarm-account-dir-temp"
)
publisherDir
,
err
:=
ioutil
.
TempDir
(
""
,
"swarm-account-dir-temp"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment