mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
cmd/swarm: Smoke test for MRU
This commit is contained in:
parent
6a6affdfc7
commit
3d2842b291
2 changed files with 21 additions and 2 deletions
|
|
@ -89,6 +89,12 @@ func main() {
|
||||||
Usage: "upload and sync",
|
Usage: "upload and sync",
|
||||||
Action: cliUploadAndSync,
|
Action: cliUploadAndSync,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "resource_sync",
|
||||||
|
Aliases: []string{"r"},
|
||||||
|
Usage: "resource update generate, upload and sync",
|
||||||
|
Action: cliResourceUploadAndSync,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(cli.FlagsByName(app.Flags))
|
sort.Sort(cli.FlagsByName(app.Flags))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/rand"
|
crand "crypto/rand"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
@ -166,6 +167,18 @@ func digest(r io.Reader) ([]byte, error) {
|
||||||
return h.Sum(nil), nil
|
return h.Sum(nil), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generates random data in heap buffer
|
||||||
|
func generateRandomData(datasize int) ([]byte, error) {
|
||||||
|
b := make([]byte, datasize)
|
||||||
|
c, err := crand.Read(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if c != datasize {
|
||||||
|
return nil, errors.New("short read")
|
||||||
|
}
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
|
||||||
// generateRandomFile is creating a temporary file with the requested byte size
|
// generateRandomFile is creating a temporary file with the requested byte size
|
||||||
func generateRandomFile(size int) (f *os.File, teardown func()) {
|
func generateRandomFile(size int) (f *os.File, teardown func()) {
|
||||||
// create a tmp file
|
// create a tmp file
|
||||||
|
|
@ -181,7 +194,7 @@ func generateRandomFile(size int) (f *os.File, teardown func()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size)
|
||||||
_, err = rand.Read(buf)
|
_, err = crand.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue