good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
github
maticnetwork
bor
Commits
beee7a52
Commit
beee7a52
authored
6 years ago
by
Elad
Committed by
Balint Gabor
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cmd/swarm: added scaling test for ACT manifests (#17496)
parent
661aa4dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/swarm/access_test.go
+37
-6
37 additions, 6 deletions
cmd/swarm/access_test.go
with
37 additions
and
6 deletions
cmd/swarm/access_test.go
+
37
−
6
View file @
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment