aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm/upload_test.go
diff options
context:
space:
mode:
authorAlexey Sharov <www.pismeco@gmail.com>2018-11-14 16:21:14 +0800
committerViktor TrĂ³n <viktor.tron@gmail.com>2018-11-14 16:21:14 +0800
commiteb8fa3cc89ae3a3247c649486839b1c250554d2d (patch)
treec61b8ebebc739db0e5413cd214fdd0d3da2fe61e /cmd/swarm/upload_test.go
parentcff97119a713a6f790893aaf1c172a397a48bf33 (diff)
downloadgo-tangerine-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar
go-tangerine-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar.gz
go-tangerine-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar.bz2
go-tangerine-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar.lz
go-tangerine-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar.xz
go-tangerine-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar.zst
go-tangerine-eb8fa3cc89ae3a3247c649486839b1c250554d2d.zip
cmd/swarm, swarm/api/http, swarm/bmt, swarm/fuse, swarm/network/stream, swarm/storage, swarm/storage/encryption, swarm/testutil: use pseudo-random instead of crypto-random for test files content generation (#18083)
- Replace "crypto/rand" to "math/rand" for files content generation - Remove swarm/network_test.go.Shuffle and swarm/btm/btm_test.go.Shuffle - because go1.9 support dropped (see https://github.com/ethereum/go-ethereum/pull/17807 and comments to swarm/network_test.go.Shuffle)
Diffstat (limited to 'cmd/swarm/upload_test.go')
-rw-r--r--cmd/swarm/upload_test.go23
1 files changed, 6 insertions, 17 deletions
diff --git a/cmd/swarm/upload_test.go b/cmd/swarm/upload_test.go
index ba4463e8b..5f9844950 100644
--- a/cmd/swarm/upload_test.go
+++ b/cmd/swarm/upload_test.go
@@ -32,6 +32,7 @@ import (
"github.com/ethereum/go-ethereum/log"
swarm "github.com/ethereum/go-ethereum/swarm/api/client"
+ swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http"
"github.com/ethereum/go-ethereum/swarm/testutil"
"github.com/mattn/go-colorable"
)
@@ -77,33 +78,22 @@ func testCLISwarmUp(toEncrypt bool, t *testing.T) {
cluster := newTestCluster(t, 3)
defer cluster.Shutdown()
- // create a tmp file
- tmp, err := ioutil.TempFile("", "swarm-test")
- if err != nil {
- t.Fatal(err)
- }
- defer tmp.Close()
- defer os.Remove(tmp.Name())
+ tmpFileName := testutil.TempFileWithContent(t, data)
+ defer os.Remove(tmpFileName)
// write data to file
- data := "notsorandomdata"
- _, err = io.WriteString(tmp, data)
- if err != nil {
- t.Fatal(err)
- }
-
hashRegexp := `[a-f\d]{64}`
flags := []string{
"--bzzapi", cluster.Nodes[0].URL,
"up",
- tmp.Name()}
+ tmpFileName}
if toEncrypt {
hashRegexp = `[a-f\d]{128}`
flags = []string{
"--bzzapi", cluster.Nodes[0].URL,
"up",
"--encrypt",
- tmp.Name()}
+ tmpFileName}
}
// upload the file with 'swarm up' and expect a hash
log.Info(fmt.Sprintf("uploading file with 'swarm up'"))
@@ -203,7 +193,6 @@ func testCLISwarmUpRecursive(toEncrypt bool, t *testing.T) {
}
defer os.RemoveAll(tmpUploadDir)
// create tmp files
- data := "notsorandomdata"
for _, path := range []string{"tmp1", "tmp2"} {
if err := ioutil.WriteFile(filepath.Join(tmpUploadDir, path), bytes.NewBufferString(data).Bytes(), 0644); err != nil {
t.Fatal(err)
@@ -298,7 +287,7 @@ func TestCLISwarmUpDefaultPath(t *testing.T) {
}
func testCLISwarmUpDefaultPath(toEncrypt bool, absDefaultPath bool, t *testing.T) {
- srv := testutil.NewTestSwarmServer(t, serverFunc, nil)
+ srv := swarmhttp.NewTestSwarmServer(t, serverFunc, nil)
defer srv.Close()
tmp, err := ioutil.TempDir("", "swarm-defaultpath-test")