mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
cmd/swarm: renamed tests
This commit is contained in:
parent
9bc6923a85
commit
3722447fae
3 changed files with 49 additions and 61 deletions
|
|
@ -57,10 +57,10 @@ func TestACT(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
f func(t *testing.T)
|
f func(t *testing.T)
|
||||||
}{
|
}{
|
||||||
{"PK", tTestAccessPK},
|
{"Password", testPassword},
|
||||||
{"ACT", tTestAccessACT},
|
{"PK", testPK},
|
||||||
{"ACTScale", tTestAccessACTScale},
|
{"ACTWithoutBogus", testACTWithoutBogus},
|
||||||
{"Password", tTestAccessPassword},
|
{"ACTWithBogus", testACTWithBogus},
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster = newTestCluster(t, clusterSize)
|
cluster = newTestCluster(t, clusterSize)
|
||||||
|
|
@ -71,12 +71,12 @@ func TestACT(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestAccessPassword tests for the correct creation of an ACT manifest protected by a password.
|
// testPassword 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
|
||||||
// is then fetched through 2nd node. since the tested code is not key-aware - we can just
|
// is then fetched through 2nd node. since the tested code is not key-aware - we can just
|
||||||
// fetch from the 2nd node using HTTP BasicAuth
|
// fetch from the 2nd node using HTTP BasicAuth
|
||||||
func tTestAccessPassword(t *testing.T) {
|
func testPassword(t *testing.T) {
|
||||||
dataFilename := testutil.TempFileWithContent(t, data)
|
dataFilename := testutil.TempFileWithContent(t, data)
|
||||||
defer os.RemoveAll(dataFilename)
|
defer os.RemoveAll(dataFilename)
|
||||||
|
|
||||||
|
|
@ -223,12 +223,12 @@ func tTestAccessPassword(t *testing.T) {
|
||||||
up.ExpectExit()
|
up.ExpectExit()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestAccessPK tests for the correct creation of an ACT manifest between two parties (publisher and grantee).
|
// testPK tests for the correct creation of an ACT manifest between two parties (publisher and grantee).
|
||||||
// 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 (which is also the grantee) then disappears.
|
// The parties participating - node (publisher), uploads to second node (which is also the grantee) then disappears.
|
||||||
// Content which was uploaded is then fetched through the grantee's http proxy. Since the tested code is private-key aware,
|
// Content which was uploaded is then fetched through the grantee's http proxy. Since the tested code is private-key aware,
|
||||||
// the test will fail if the proxy's given private key is not granted on the ACT.
|
// the test will fail if the proxy's given private key is not granted on the ACT.
|
||||||
func tTestAccessPK(t *testing.T) {
|
func testPK(t *testing.T) {
|
||||||
dataFilename := testutil.TempFileWithContent(t, data)
|
dataFilename := testutil.TempFileWithContent(t, data)
|
||||||
defer os.RemoveAll(dataFilename)
|
defer os.RemoveAll(dataFilename)
|
||||||
|
|
||||||
|
|
@ -360,22 +360,22 @@ func tTestAccessPK(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)
|
// testACTWithoutBogus tests the creation of the ACT manifest end-to-end, without any bogus entries (i.e. default scenario = 3 nodes 1 unauthorized)
|
||||||
func tTestAccessACT(t *testing.T) {
|
func testACTWithoutBogus(t *testing.T) {
|
||||||
testAccessACT(t, 0)
|
testACT(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)
|
// testACTWithBogus tests the creation of the ACT manifest end-to-end, with 100 bogus entries (i.e. 100 EC keys + default scenario = 3 nodes 1 unauthorized = 103 keys in the ACT manifest)
|
||||||
func tTestAccessACTScale(t *testing.T) {
|
func testACTWithBogus(t *testing.T) {
|
||||||
testAccessACT(t, 1000)
|
testACT(t, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestAccessACT tests the e2e creation, uploading and downloading of an ACT access control with both EC keys AND password protection
|
// testACT tests the e2e creation, uploading and downloading of an ACT access control with both EC keys AND password protection
|
||||||
// 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 and also protects the ACT with a password. the third node should fail decoding the reference as it will not be granted access.
|
// set and also protects the ACT with a password. the third node should fail decoding the reference as it will not be granted access.
|
||||||
// the third node then then tries to download using a correct password (and succeeds) then uses a wrong password and fails.
|
// the third node then then tries to download using a correct password (and succeeds) then uses a wrong password and fails.
|
||||||
// the publisher uploads through one of the nodes then disappears.
|
// the publisher uploads through one of the nodes then disappears.
|
||||||
func testAccessACT(t *testing.T, bogusEntries int) {
|
func testACT(t *testing.T, bogusEntries int) {
|
||||||
var uploadThroughNode = cluster.Nodes[0]
|
var uploadThroughNode = cluster.Nodes[0]
|
||||||
client := swarmapi.NewClient(uploadThroughNode.URL)
|
client := swarmapi.NewClient(uploadThroughNode.URL)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCLIFeedUpdate(t *testing.T) {
|
func TestCLIFeedUpdate(t *testing.T) {
|
||||||
|
|
||||||
srv := swarmhttp.NewTestSwarmServer(t, func(api *api.API) swarmhttp.TestServer {
|
srv := swarmhttp.NewTestSwarmServer(t, func(api *api.API) swarmhttp.TestServer {
|
||||||
return swarmhttp.NewServer(api, "")
|
return swarmhttp.NewServer(api, "")
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
@ -44,7 +43,6 @@ func TestCLIFeedUpdate(t *testing.T) {
|
||||||
defer srv.Close()
|
defer srv.Close()
|
||||||
|
|
||||||
// create a private key file for signing
|
// create a private key file for signing
|
||||||
|
|
||||||
privkeyHex := "0000000000000000000000000000000000000000000000000000000000001979"
|
privkeyHex := "0000000000000000000000000000000000000000000000000000000000001979"
|
||||||
privKey, _ := crypto.HexToECDSA(privkeyHex)
|
privKey, _ := crypto.HexToECDSA(privkeyHex)
|
||||||
address := crypto.PubkeyToAddress(privKey.PublicKey)
|
address := crypto.PubkeyToAddress(privKey.PublicKey)
|
||||||
|
|
|
||||||
|
|
@ -41,16 +41,20 @@ func init() {
|
||||||
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true))))
|
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCLI(t *testing.T) {
|
func TestSwarmUp(t *testing.T) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
t.Skip()
|
||||||
|
}
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
f func(t *testing.T)
|
f func(t *testing.T)
|
||||||
}{
|
}{
|
||||||
{"SwarmUp", tTestCLISwarmUp},
|
{"NoEncryption", testNoEncryption},
|
||||||
{"SwarmUpEncrypted", tTestCLISwarmUpEncrypted},
|
{"Encrypted", testEncrypted},
|
||||||
{"SwarmUpRecursive", tTestCLISwarmUpRecursive},
|
{"RecursiveNoEncryption", testRecursiveNoEncryption},
|
||||||
{"SwarmUpEncryptedRecursive", tTestCLISwarmUpEncryptedRecursive},
|
{"RecursiveEncrypted", testRecursiveEncrypted},
|
||||||
{"SwarmUpDefaultPath", tTestCLISwarmUpDefaultPath},
|
{"DefaultPathAll", testDefaultPathAll},
|
||||||
}
|
}
|
||||||
|
|
||||||
cluster = newTestCluster(t, clusterSize)
|
cluster = newTestCluster(t, clusterSize)
|
||||||
|
|
@ -61,38 +65,27 @@ func TestCLI(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCLISwarmUp tests that running 'swarm up' makes the resulting file
|
// testNoEncryption tests that running 'swarm up' makes the resulting file
|
||||||
// available from all nodes via the HTTP API
|
// available from all nodes via the HTTP API
|
||||||
func tTestCLISwarmUp(t *testing.T) {
|
func testNoEncryption(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
testDefault(false, t)
|
||||||
t.Skip()
|
|
||||||
}
|
|
||||||
|
|
||||||
testCLISwarmUp(false, t)
|
|
||||||
}
|
|
||||||
func tTestCLISwarmUpRecursive(t *testing.T) {
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip()
|
|
||||||
}
|
|
||||||
testCLISwarmUpRecursive(false, t)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCLISwarmUpEncrypted tests that running 'swarm encrypted-up' makes the resulting file
|
// testEncrypted tests that running 'swarm up --encrypted' makes the resulting file
|
||||||
// available from all nodes via the HTTP API
|
// available from all nodes via the HTTP API
|
||||||
func tTestCLISwarmUpEncrypted(t *testing.T) {
|
func testEncrypted(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
testDefault(true, t)
|
||||||
t.Skip()
|
|
||||||
}
|
|
||||||
testCLISwarmUp(true, t)
|
|
||||||
}
|
|
||||||
func tTestCLISwarmUpEncryptedRecursive(t *testing.T) {
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
t.Skip()
|
|
||||||
}
|
|
||||||
testCLISwarmUpRecursive(true, t)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCLISwarmUp(toEncrypt bool, t *testing.T) {
|
func testRecursiveNoEncryption(t *testing.T) {
|
||||||
|
testRecursive(false, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRecursiveEncrypted(t *testing.T) {
|
||||||
|
testRecursive(true, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDefault(toEncrypt bool, t *testing.T) {
|
||||||
tmpFileName := testutil.TempFileWithContent(t, data)
|
tmpFileName := testutil.TempFileWithContent(t, data)
|
||||||
defer os.Remove(tmpFileName)
|
defer os.Remove(tmpFileName)
|
||||||
|
|
||||||
|
|
@ -197,7 +190,7 @@ func testCLISwarmUp(toEncrypt bool, t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCLISwarmUpRecursive(toEncrypt bool, t *testing.T) {
|
func testRecursive(toEncrypt bool, t *testing.T) {
|
||||||
tmpUploadDir, err := ioutil.TempDir("", "swarm-test")
|
tmpUploadDir, err := ioutil.TempDir("", "swarm-test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
@ -285,19 +278,16 @@ func testCLISwarmUpRecursive(toEncrypt bool, t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCLISwarmUpDefaultPath tests swarm recursive upload with relative and absolute
|
// testDefaultPathAll tests swarm recursive upload with relative and absolute
|
||||||
// default paths and with encryption.
|
// default paths and with encryption.
|
||||||
func tTestCLISwarmUpDefaultPath(t *testing.T) {
|
func testDefaultPathAll(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
testDefaultPath(false, false, t)
|
||||||
t.Skip()
|
testDefaultPath(false, true, t)
|
||||||
}
|
testDefaultPath(true, false, t)
|
||||||
testCLISwarmUpDefaultPath(false, false, t)
|
testDefaultPath(true, true, t)
|
||||||
testCLISwarmUpDefaultPath(false, true, t)
|
|
||||||
testCLISwarmUpDefaultPath(true, false, t)
|
|
||||||
testCLISwarmUpDefaultPath(true, true, t)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCLISwarmUpDefaultPath(toEncrypt bool, absDefaultPath bool, t *testing.T) {
|
func testDefaultPath(toEncrypt bool, absDefaultPath bool, t *testing.T) {
|
||||||
tmp, err := ioutil.TempDir("", "swarm-defaultpath-test")
|
tmp, err := ioutil.TempDir("", "swarm-defaultpath-test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue