diff options
author | Alexey Sharov <www.pismeco@gmail.com> | 2018-11-14 16:21:14 +0800 |
---|---|---|
committer | Viktor TrĂ³n <viktor.tron@gmail.com> | 2018-11-14 16:21:14 +0800 |
commit | eb8fa3cc89ae3a3247c649486839b1c250554d2d (patch) | |
tree | c61b8ebebc739db0e5413cd214fdd0d3da2fe61e /cmd/swarm/feeds_test.go | |
parent | cff97119a713a6f790893aaf1c172a397a48bf33 (diff) | |
download | dexon-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar.gz dexon-eb8fa3cc89ae3a3247c649486839b1c250554d2d.tar.zst dexon-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/feeds_test.go')
-rw-r--r-- | cmd/swarm/feeds_test.go | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/cmd/swarm/feeds_test.go b/cmd/swarm/feeds_test.go index 46727c21d..fc3f72ab1 100644 --- a/cmd/swarm/feeds_test.go +++ b/cmd/swarm/feeds_test.go @@ -20,49 +20,37 @@ import ( "bytes" "encoding/json" "fmt" - "io" "io/ioutil" "os" "testing" - "github.com/ethereum/go-ethereum/swarm/api" - "github.com/ethereum/go-ethereum/swarm/storage/feed/lookup" - "github.com/ethereum/go-ethereum/swarm/testutil" - - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/swarm/storage/feed" - "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/swarm/api" swarm "github.com/ethereum/go-ethereum/swarm/api/client" swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http" + "github.com/ethereum/go-ethereum/swarm/storage/feed" + "github.com/ethereum/go-ethereum/swarm/storage/feed/lookup" + "github.com/ethereum/go-ethereum/swarm/testutil" ) func TestCLIFeedUpdate(t *testing.T) { - srv := testutil.NewTestSwarmServer(t, func(api *api.API) testutil.TestServer { + srv := swarmhttp.NewTestSwarmServer(t, func(api *api.API) swarmhttp.TestServer { return swarmhttp.NewServer(api, "") }, nil) log.Info("starting a test swarm server") defer srv.Close() // create a private key file for signing - pkfile, err := ioutil.TempFile("", "swarm-test") - if err != nil { - t.Fatal(err) - } - defer pkfile.Close() - defer os.Remove(pkfile.Name()) privkeyHex := "0000000000000000000000000000000000000000000000000000000000001979" privKey, _ := crypto.HexToECDSA(privkeyHex) address := crypto.PubkeyToAddress(privKey.PublicKey) - // save the private key to a file - _, err = io.WriteString(pkfile, privkeyHex) - if err != nil { - t.Fatal(err) - } + pkFileName := testutil.TempFileWithContent(t, privkeyHex) + defer os.Remove(pkFileName) // compose a topic. We'll be doing quotes about Miguel de Cervantes var topic feed.Topic @@ -76,7 +64,7 @@ func TestCLIFeedUpdate(t *testing.T) { flags := []string{ "--bzzapi", srv.URL, - "--bzzaccount", pkfile.Name(), + "--bzzaccount", pkFileName, "feed", "update", "--topic", topic.Hex(), "--name", name, @@ -89,13 +77,10 @@ func TestCLIFeedUpdate(t *testing.T) { // now try to get the update using the client client := swarm.NewClient(srv.URL) - if err != nil { - t.Fatal(err) - } // build the same topic as before, this time // we use NewTopic to create a topic automatically. - topic, err = feed.NewTopic(name, subject) + topic, err := feed.NewTopic(name, subject) if err != nil { t.Fatal(err) } @@ -153,7 +138,7 @@ func TestCLIFeedUpdate(t *testing.T) { // test publishing a manifest flags = []string{ "--bzzapi", srv.URL, - "--bzzaccount", pkfile.Name(), + "--bzzaccount", pkFileName, "feed", "create", "--topic", topic.Hex(), } |