diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 399b2c0345f..90f1e341f5d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -33,18 +33,6 @@ "ImportPath": "github.com/jbenet/go-detect-race", "Rev": "3463798d9574bd0b7eca275dccc530804ff5216f" }, - { - "ImportPath": "github.com/jbenet/go-os-rename", - "Rev": "3ac97f61ef67a6b87b95c1282f6c317ed0e693c2" - }, - { - "ImportPath": "github.com/jbenet/go-random", - "Rev": "cd535bd25356746b9b1e824871dda7da932460e2" - }, - { - "ImportPath": "github.com/jbenet/go-random-files", - "Rev": "737479700b40b4b50e914e963ce8d9d44603e3c8" - }, { "ImportPath": "github.com/mitchellh/go-homedir", "Rev": "1f6da4a72e57d4e7edd4a7295a585e0a3999a2d4" diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/LICENSE b/Godeps/_workspace/src/github.com/jbenet/go-random-files/LICENSE deleted file mode 100644 index c7386b3c940..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Juan Batiz-Benet - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/Makefile b/Godeps/_workspace/src/github.com/jbenet/go-random-files/Makefile deleted file mode 100644 index 5a72abe1fa3..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -build: - cd random-files && go build - -install: - cd random-files && go install diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/README.md b/Godeps/_workspace/src/github.com/jbenet/go-random-files/README.md deleted file mode 100644 index f2fb4b9b47e..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/README.md +++ /dev/null @@ -1,108 +0,0 @@ -# go-random-files - create random fs hierarchies - -Useful for testing filesystems. - - -``` -# library -go get -u github.com/jbenet/go-random-files - -# binary -go get -u github.com/jbenet/go-random-files/random-files -``` - -### Library godoc: https://godoc.org/github.com/jbenet/go-random-files - -# random-files - create random fs hierarchies - -See more about the binary at: github.com/jbenet/go-random-files/tree/master/random-files - -Useful for testing filesystems. - -## Install - -``` -go get -u github.com/jbenet/go-random-files/random-files -``` - -## Usage - -```sh -> random-files --help -usage: random-files [options] ... -Write a random filesystem hierarchy to each - -Options: - -alphabet="easy": alphabet for filenames {easy, hard} - -depth=2: fanout depth - how deep the hierarchy goes - -dirs=5: fanout dirs - number of dirs per dir (or max) - -files=10: fanout files - number of files per dir (or max - -filesize=4096: filesize - how big to make each file (or max) - -q=false: quiet output - -random-crypto=false: use cryptographic randomness for files - -random-fanout=false: randomize fanout numbers - -random-size=true: randomize filesize - -seed=0: random seed - 0 for current time -``` - -### Examples - -```sh -> random-files --depth=2 --files=3 foo -foo/h20uo3jrpihb -foo/x6tef1 -foo/jh0c2vdci -foo/fden012m368 -foo/fden012m368/p6n0chy4kg -foo/fden012m368/h92_ -foo/fden012m368/kvjiya98p3 -foo/e_i6hwav1tb -foo/e_i6hwav1tb/oj0-a -foo/e_i6hwav1tb/1-pfgvim -foo/e_i6hwav1tb/s_unf -foo/bgvy8x-_hsm -foo/bgvy8x-_hsm/98zcoz-9ng -foo/bgvy8x-_hsm/j0see3qv -foo/bgvy8x-_hsm/qntuf0r -foo/6zjkw3ejm2awwt -foo/6zjkw3ejm2awwt/iba52dh1lhnewh -foo/6zjkw3ejm2awwt/n1bwcv5zpe -foo/6zjkw3ejm2awwt/o8k89cc -foo/efp_6 -foo/efp_6/qfap2 -foo/efp_6/v_kl_wlefsaa -foo/efp_6/r7sdbph -``` - -It made: - -``` -> tree foo -foo -├── 6zjkw3ejm2awwt -│   ├── iba52dh1lhnewh -│   ├── n1bwcv5zpe -│   └── o8k89cc -├── bgvy8x-_hsm -│   ├── 98zcoz-9ng -│   ├── j0see3qv -│   └── qntuf0r -├── e_i6hwav1tb -│   ├── 1-pfgvim -│   ├── oj0-a -│   └── s_unf -├── efp_6 -│   ├── qfap2 -│   ├── r7sdbph -│   └── v_kl_wlefsaa -├── fden012m368 -│   ├── h92_ -│   ├── kvjiya98p3 -│   └── p6n0chy4kg -├── h20uo3jrpihb -├── jh0c2vdci -└── x6tef1 - -5 directories, 18 files -``` - diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/lib.go b/Godeps/_workspace/src/github.com/jbenet/go-random-files/lib.go deleted file mode 100644 index e49ad68e235..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/lib.go +++ /dev/null @@ -1,110 +0,0 @@ -package randomfiles - -import ( - "fmt" - "io" - "math/rand" - "os" - "path" -) - -type Options struct { - Out io.Writer // output progress - Source io.Reader // randomness source - - FileSize int // the size per file. - Alphabet []rune // for filenames - - FanoutDepth int // how deep the hierarchy goes - FanoutFiles int // how many files per dir - FanoutDirs int // how many dirs per dir - - RandomSeed int64 // use a random seed. if 0, use a random seed - RandomSize bool // randomize file sizes - RandomFanout bool // randomize fanout numbers -} - -func WriteRandomFiles(root string, depth int, opts *Options) error { - - numfiles := opts.FanoutFiles - if opts.RandomFanout { - numfiles = rand.Intn(numfiles) + 1 - } - - for i := 0; i < numfiles; i++ { - if err := WriteRandomFile(root, opts); err != nil { - return err - } - } - - if depth+1 <= opts.FanoutDepth { - numdirs := opts.FanoutDirs - if opts.RandomFanout { - numdirs = rand.Intn(numdirs) + 1 - } - - for i := 0; i < numdirs; i++ { - if err := WriteRandomDir(root, depth+1, opts); err != nil { - return err - } - } - } - - return nil -} - -var FilenameSize = 16 -var RunesEasy = []rune("abcdefghijklmnopqrstuvwxyz01234567890-_") -var RunesHard = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890!@#$%^&*()-_+= ;.,<>'\"[]{}() ") - -func RandomFilename(length int, alphabet []rune) string { - b := make([]rune, length) - for i := range b { - b[i] = alphabet[rand.Intn(len(alphabet))] - } - return string(b) -} - -func WriteRandomFile(root string, opts *Options) error { - filesize := int64(opts.FileSize) - if opts.RandomSize { - filesize = rand.Int63n(filesize) + 1 - } - - n := rand.Intn(FilenameSize-4) + 4 - name := RandomFilename(n, opts.Alphabet) - filepath := path.Join(root, name) - f, err := os.Create(filepath) - if err != nil { - return err - } - - if _, err := io.CopyN(f, opts.Source, filesize); err != nil { - return err - } - - if opts.Out != nil { - fmt.Fprintln(opts.Out, filepath) - } - - return f.Close() -} - -func WriteRandomDir(root string, depth int, opts *Options) error { - if depth > opts.FanoutDepth { - return nil - } - - n := rand.Intn(FilenameSize-4) + 4 - name := RandomFilename(n, opts.Alphabet) - root = path.Join(root, name) - if err := os.MkdirAll(root, 0755); err != nil { - return err - } - - if opts.Out != nil { - fmt.Fprintln(opts.Out, root) - } - - return WriteRandomFiles(root, depth, opts) -} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/.gitignore b/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/.gitignore deleted file mode 100644 index 03d7e701f05..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/.gitignore +++ /dev/null @@ -1 +0,0 @@ -random-files diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/README.md b/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/README.md deleted file mode 100644 index acb230e7628..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/README.md +++ /dev/null @@ -1,90 +0,0 @@ -# random-files - create random fs hierarchies - -random-files creates random fs hierarchies. Useful for testing filesystems. - -## Install - -``` -go get -u github.com/jbenet/go-random-files/random-files -``` - -## Usage - -```sh -> random-files --help -usage: random-files [options] ... -Write a random filesystem hierarchy to each - -Options: - -alphabet="easy": alphabet for filenames {easy, hard} - -depth=2: fanout depth - how deep the hierarchy goes - -dirs=5: fanout dirs - number of dirs per dir (or max) - -files=10: fanout files - number of files per dir (or max - -filesize=4096: filesize - how big to make each file (or max) - -q=false: quiet output - -random-crypto=false: use cryptographic randomness for files - -random-fanout=false: randomize fanout numbers - -random-size=true: randomize filesize - -seed=0: random seed - 0 for current time -``` - -## Examples - -```sh -> random-files --depth=2 --files=3 foo -foo/h20uo3jrpihb -foo/x6tef1 -foo/jh0c2vdci -foo/fden012m368 -foo/fden012m368/p6n0chy4kg -foo/fden012m368/h92_ -foo/fden012m368/kvjiya98p3 -foo/e_i6hwav1tb -foo/e_i6hwav1tb/oj0-a -foo/e_i6hwav1tb/1-pfgvim -foo/e_i6hwav1tb/s_unf -foo/bgvy8x-_hsm -foo/bgvy8x-_hsm/98zcoz-9ng -foo/bgvy8x-_hsm/j0see3qv -foo/bgvy8x-_hsm/qntuf0r -foo/6zjkw3ejm2awwt -foo/6zjkw3ejm2awwt/iba52dh1lhnewh -foo/6zjkw3ejm2awwt/n1bwcv5zpe -foo/6zjkw3ejm2awwt/o8k89cc -foo/efp_6 -foo/efp_6/qfap2 -foo/efp_6/v_kl_wlefsaa -foo/efp_6/r7sdbph -``` - -It made: - -``` -> tree foo -foo -├── 6zjkw3ejm2awwt -│   ├── iba52dh1lhnewh -│   ├── n1bwcv5zpe -│   └── o8k89cc -├── bgvy8x-_hsm -│   ├── 98zcoz-9ng -│   ├── j0see3qv -│   └── qntuf0r -├── e_i6hwav1tb -│   ├── 1-pfgvim -│   ├── oj0-a -│   └── s_unf -├── efp_6 -│   ├── qfap2 -│   ├── r7sdbph -│   └── v_kl_wlefsaa -├── fden012m368 -│   ├── h92_ -│   ├── kvjiya98p3 -│   └── p6n0chy4kg -├── h20uo3jrpihb -├── jh0c2vdci -└── x6tef1 - -5 directories, 18 files -``` diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/main.go b/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/main.go deleted file mode 100644 index b466916a1e9..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files/main.go +++ /dev/null @@ -1,119 +0,0 @@ -package main - -import ( - crand "crypto/rand" - "errors" - "flag" - "fmt" - "math/rand" - "os" - "time" - - randomfiles "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random-files" - ringreader "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random-files/ringreader" -) - -var usage = `usage: %s [options] ... -Write a random filesystem hierarchy to each - -Options: -` - -// flags -var opts randomfiles.Options -var quiet bool -var alphabet string -var paths []string -var cryptorand bool - -func init() { - flag.Usage = func() { - fmt.Fprintf(os.Stderr, usage, os.Args[0]) - flag.PrintDefaults() - } - - flag.BoolVar(&quiet, "q", false, "quiet output") - flag.BoolVar(&cryptorand, "random-crypto", false, "use cryptographic randomness for files") - flag.StringVar(&alphabet, "alphabet", "easy", "alphabet for filenames {easy, hard}") - flag.IntVar(&opts.FileSize, "filesize", 4096, "filesize - how big to make each file (or max)") - - flag.IntVar(&opts.FanoutDepth, "depth", 2, "fanout depth - how deep the hierarchy goes") - flag.IntVar(&opts.FanoutDirs, "dirs", 5, "fanout dirs - number of dirs per dir (or max)") - flag.IntVar(&opts.FanoutFiles, "files", 10, "fanout files - number of files per dir (or max") - - flag.Int64Var(&opts.RandomSeed, "seed", 0, "random seed - 0 for current time") - flag.BoolVar(&opts.RandomFanout, "random-fanout", false, "randomize fanout numbers") - flag.BoolVar(&opts.RandomSize, "random-size", true, "randomize filesize") -} - -func parseArgs() error { - flag.Parse() - - switch alphabet { - case "easy": - opts.Alphabet = randomfiles.RunesEasy - case "hard": - opts.Alphabet = randomfiles.RunesHard - default: - return errors.New("alphabet must be one of: easy, hard") - } - - paths = flag.Args() - if len(paths) < 1 { - flag.Usage() - os.Exit(0) - } - - if !quiet { - opts.Out = os.Stdout - } - - switch opts.RandomSeed { - case 0: - rand.Seed(time.Now().UnixNano()) - default: - rand.Seed(opts.RandomSeed) - } - - // prepare randomn source. - if cryptorand { - opts.Source = crand.Reader - } else { - // if not crypto, we don't need a lot of random - // data. we just need to sample from a sequence. - s := 16777216 // 16MB - r, err := ringreader.NewReader(s) - if err != nil { - return err - } - opts.Source = r - } - - return nil -} - -func run() error { - if err := parseArgs(); err != nil { - return err - } - - for _, root := range paths { - if err := os.MkdirAll(root, 0755); err != nil { - return err - } - - err := randomfiles.WriteRandomFiles(root, 1, &opts) - if err != nil { - return err - } - } - - return nil -} - -func main() { - if err := run(); err != nil { - fmt.Fprintln(os.Stderr, "error:", err) - os.Exit(1) - } -} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/ringreader/ringreader.go b/Godeps/_workspace/src/github.com/jbenet/go-random-files/ringreader/ringreader.go deleted file mode 100644 index c40dbb4249c..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/ringreader/ringreader.go +++ /dev/null @@ -1,40 +0,0 @@ -package ringreader - -import ( - "bytes" - "fmt" - "math/rand" - - random "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" -) - -type Reader struct { - Buf []byte -} - -func NewReader(bufsize int) (*Reader, error) { - buf := bytes.NewBuffer(nil) - err := random.WritePseudoRandomBytes(int64(bufsize), buf, rand.Int63()) - return &Reader{Buf: buf.Bytes()}, err -} - -func (r *Reader) Read(buf []byte) (n int, err error) { - ibufl := len(r.Buf) - left := len(buf) - copied := 0 - - for copied < left { - pos1 := rand.Intn(len(r.Buf)) - pos2 := pos1 + left - if pos2 > ibufl { - pos2 = ibufl - } - copied += copy(buf[copied:], r.Buf[pos1:pos2]) - } - - if copied != left { - err := fmt.Errorf("copied a different ammount: %d != %d", copied, left) - panic(err.Error()) - } - return copied, nil -} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random-files/ringreader/ringreader_test.go b/Godeps/_workspace/src/github.com/jbenet/go-random-files/ringreader/ringreader_test.go deleted file mode 100644 index 791aa070ecb..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random-files/ringreader/ringreader_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package ringreader - -import ( - "testing" -) - -func TestRingReader(t *testing.T) { - r, _ := NewReader(256) - t.Log("buffer:", r.Buf) - - for i := 1; i < 1048576; i = i * 2 { - buf := make([]byte, i) - n, err := r.Read(buf) - if err != nil { - t.Error(err) - } - if n != len(buf) { - t.Error("did not read %d bytes", n) - } - t.Log("read:", buf) - } -} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random/.travis.yml b/Godeps/_workspace/src/github.com/jbenet/go-random/.travis.yml deleted file mode 100644 index 381b4392682..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: go - -go: - - 1.3 - - release - - tip - -script: - - go test -race -cpu=5 -v ./... - - cd random && go build - -env: TEST_VERBOSE=1 diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random/LICENSE b/Godeps/_workspace/src/github.com/jbenet/go-random/LICENSE deleted file mode 100644 index c7386b3c940..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Juan Batiz-Benet - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random/README.md b/Godeps/_workspace/src/github.com/jbenet/go-random/README.md deleted file mode 100644 index 3b0b20ccbab..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# go-random outputs randomness - -This is a unix util that outputs randomness. -It is a thin wrapper around `crypto/rand`. -It aims to be portable (though it may not yet be). - -### Install - -```sh -go install github.com/jbenet/go-random/random -``` - -(The extra /random is there because go get is stupidly too proscriptive about -package/repository names and I don't yet know how to change the default binary -output name) - -### Usage: - -``` -> random -Usage: random -Print random bytes (from Go's crypto/rand) -> random 6 -2q���# -``` - -### License - -MIT diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random/lib.go b/Godeps/_workspace/src/github.com/jbenet/go-random/lib.go deleted file mode 100644 index 48aa3716d2b..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random/lib.go +++ /dev/null @@ -1,47 +0,0 @@ -package random - -import ( - "bytes" - randcrypto "crypto/rand" - "io" - randmath "math/rand" -) - -func WriteRandomBytes(count int64, w io.Writer) error { - r := &io.LimitedReader{R: randcrypto.Reader, N: count} - _, err := io.Copy(w, r) - return err -} - -func WritePseudoRandomBytes(count int64, w io.Writer, seed int64) error { - randmath.Seed(seed) - - // Configurable buffer size - bufsize := int64(1024 * 1024 * 4) - b := make([]byte, bufsize) - - for count > 0 { - if bufsize > count { - bufsize = count - b = b[:bufsize] - } - - var n uint32 - for i := int64(0); i < bufsize; { - n = randmath.Uint32() - for j := 0; j < 4 && i < bufsize; j++ { - b[i] = byte(n & 0xff) - n >>= 8 - i++ - } - } - count = count - bufsize - - r := bytes.NewReader(b) - _, err := io.Copy(w, r) - if err != nil { - return err - } - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random/random/.gitignore b/Godeps/_workspace/src/github.com/jbenet/go-random/random/.gitignore deleted file mode 100644 index a1e4bc59a50..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random/random/.gitignore +++ /dev/null @@ -1 +0,0 @@ -random diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random/random/random.go b/Godeps/_workspace/src/github.com/jbenet/go-random/random/random.go deleted file mode 100644 index cdf79b64fe6..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random/random/random.go +++ /dev/null @@ -1,49 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strconv" - - random "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" - "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" -) - -func main() { - l := len(os.Args) - if l != 2 && l != 3 { - usageError() - } - - countuint64, err := humanize.ParseBytes(os.Args[1]) - if err != nil { - usageError() - } - count := int64(countuint64) - - if l == 2 { - err = random.WriteRandomBytes(count, os.Stdout) - } else { - seed, err2 := strconv.ParseInt(os.Args[2], 10, 64) - if err2 != nil { - usageError() - } - err = random.WritePseudoRandomBytes(count, os.Stdout, seed) - } - - if err != nil { - die(err) - } -} - -func usageError() { - fmt.Fprintf(os.Stderr, "Usage: %s []\n", os.Args[0]) - fmt.Fprintf(os.Stderr, "If is given, output pseudo random bytes made from (from Go's math/rand)\n") - fmt.Fprintf(os.Stderr, "Otherwise, output random bytes (from Go's crypto/rand)\n") - os.Exit(-1) -} - -func die(err error) { - fmt.Fprintf(os.Stderr, "Error: %v", err) - os.Exit(-1) -} diff --git a/Godeps/_workspace/src/github.com/jbenet/go-random/random_test.go b/Godeps/_workspace/src/github.com/jbenet/go-random/random_test.go deleted file mode 100644 index f121ecd55a3..00000000000 --- a/Godeps/_workspace/src/github.com/jbenet/go-random/random_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package random - -import ( - "bytes" - "io/ioutil" - "testing" - "time" -) - -func TestPseudoRandom(t *testing.T) { - - var testCases = []int{ - 1024, - 187654, - 1048576, - 4932132, - } - - for _, size := range testCases { - var buf bytes.Buffer - err := WritePseudoRandomBytes(int64(size), &buf, int64(time.Now().UnixNano())) - if err != nil { - t.Fatal(err) - } - - if buf.Len() != size { - t.Fatal("buffer not of the right size: %d != %d", buf.Len(), size) - } - } -} - -func TestPseudoRandomSeed(t *testing.T) { - - var first []byte - var size = int64(1024 * 4) - seed := time.Now().UnixNano() - - for i := 0; i < 100; i++ { - var bufs bytes.Buffer - var bufr bytes.Buffer - - if err := WritePseudoRandomBytes(size, &bufs, seed); err != nil { - t.Fatal(err) - } - - if err := WritePseudoRandomBytes(size, &bufr, time.Now().UnixNano()); err != nil { - t.Fatal(err) - } - - if bufs.Len() != int(size) { - t.Fatal("buffer not of the right size: %d != %d", bufs.Len(), size) - } - if bufr.Len() != int(size) { - t.Fatal("buffer not of the right size: %d != %d", bufr.Len(), size) - } - - if first == nil { - first = bufs.Bytes() - } else if !bytes.Equal(first, bufs.Bytes()) { - t.Fatal("seeded constructed different bytes") - } - - if bytes.Equal(first, bufr.Bytes()) { - t.Fatal("non-seeded constructed same bytes") - } - } -} - -func TestCryptoRandom(t *testing.T) { - - var testCases = []int{ - 1024, - 187654, - 1048576, - } - - for _, size := range testCases { - var buf bytes.Buffer - err := WriteRandomBytes(int64(size), &buf) - if err != nil { - t.Fatal(err) - } - - if buf.Len() != size { - t.Fatal("buffer not of the right size: %d != %d", buf.Len(), size) - } - } -} - -func BenchmarkCryptoRandom(b *testing.B) { - WriteRandomBytes(int64(b.N), ioutil.Discard) -} - -func BenchmarkPseudoRandom(b *testing.B) { - WritePseudoRandomBytes(int64(b.N), ioutil.Discard, time.Now().UnixNano()) -} diff --git a/package.json b/package.json index e2c8ede902f..378628b12ef 100644 --- a/package.json +++ b/package.json @@ -306,6 +306,17 @@ "hash": "QmfJHywXQu98UeZtGJBQrPAR6AtmDjjbe3qjTo9piXHPnx", "name": "murmur3", "version": "0.0.0" + }, + { + "author": "jbenet", + "hash": "QmTyCJo2KTgqLxgZoSss3ZeDG637zrw9ZaXKJ1NKQmYybz", + "name": "go-random-files", + "version": "0.0.0" + }, + { + "hash": "QmbRf8gHLzTjhtVR8Qc4hBXF2c3pV7zCcaS8wSXQKx44kv", + "name": "go-random", + "version": "1.0.0" } ], "gxVersion": "0.10.0", diff --git a/test/3nodetest/Makefile b/test/3nodetest/Makefile index c4fdf18b76b..d5476620b33 100644 --- a/test/3nodetest/Makefile +++ b/test/3nodetest/Makefile @@ -1,4 +1,4 @@ -RANDOMSRC = ../../Godeps/_workspace/src/github.com/jbenet/go-random +RANDOMSRC = ${GOPATH}/src/gx/ipfs/QmbRf8gHLzTjhtVR8Qc4hBXF2c3pV7zCcaS8wSXQKx44kv/go-random IMAGE_NAME = ipfs-test-latest IPFS_ROOT = ../.. diff --git a/test/bench/bench_cli_ipfs_add/main.go b/test/bench/bench_cli_ipfs_add/main.go index ce94856b62d..0e947ce91f9 100644 --- a/test/bench/bench_cli_ipfs_add/main.go +++ b/test/bench/bench_cli_ipfs_add/main.go @@ -10,9 +10,10 @@ import ( "path" "testing" - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" "github.com/ipfs/go-ipfs/repo/config" "github.com/ipfs/go-ipfs/thirdparty/unit" + + "gx/ipfs/QmbRf8gHLzTjhtVR8Qc4hBXF2c3pV7zCcaS8wSXQKx44kv/go-random" ) var ( diff --git a/test/bench/offline_add/main.go b/test/bench/offline_add/main.go index 0df24f5c4e7..0cae88a9143 100644 --- a/test/bench/offline_add/main.go +++ b/test/bench/offline_add/main.go @@ -9,9 +9,10 @@ import ( "path" "testing" - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" "github.com/ipfs/go-ipfs/repo/config" "github.com/ipfs/go-ipfs/thirdparty/unit" + + "gx/ipfs/QmbRf8gHLzTjhtVR8Qc4hBXF2c3pV7zCcaS8wSXQKx44kv/go-random" ) func main() { diff --git a/test/bin/Rules.mk b/test/bin/Rules.mk index 08f1a295cf6..cbbf6359887 100644 --- a/test/bin/Rules.mk +++ b/test/bin/Rules.mk @@ -2,12 +2,12 @@ include mk/header.mk TGTS_$(d) := -$(d)/random: Godeps/_workspace/src/github.com/jbenet/go-random/random - $(go-build) +$(d)/random: + go build -i $(go-flags-with-tags) -o "$@" "gx/ipfs/$(shell gx deps find go-random)/go-random/random" TGTS_$(d) += $(d)/random -$(d)/random-files: Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files - $(go-build) +$(d)/random-files: + go build -i $(go-flags-with-tags) -o "$@" "gx/ipfs/$(shell gx deps find go-random-files)/go-random-files/random-files" TGTS_$(d) += $(d)/random-files $(d)/pollEndpoint: thirdparty/pollEndpoint diff --git a/test/integration/addcat_test.go b/test/integration/addcat_test.go index 70c86057c77..aa89a670c0e 100644 --- a/test/integration/addcat_test.go +++ b/test/integration/addcat_test.go @@ -11,7 +11,7 @@ import ( "time" context "context" - random "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" + random "gx/ipfs/QmbRf8gHLzTjhtVR8Qc4hBXF2c3pV7zCcaS8wSXQKx44kv/go-random" "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" diff --git a/test/sharness/lib/random-dep.go b/test/sharness/lib/random-dep.go index 94b758d7bd4..eac76832e2c 100644 --- a/test/sharness/lib/random-dep.go +++ b/test/sharness/lib/random-dep.go @@ -4,6 +4,6 @@ package randomdep import ( - _ "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" - _ "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random-files" + _ "gx/ipfs/QmTyCJo2KTgqLxgZoSss3ZeDG637zrw9ZaXKJ1NKQmYybz/go-random-files" + _ "gx/ipfs/QmbRf8gHLzTjhtVR8Qc4hBXF2c3pV7zCcaS8wSXQKx44kv/go-random" ) diff --git a/test/supernode_client/main.go b/test/supernode_client/main.go index 3bd4f77fb62..f2eb7a73645 100644 --- a/test/supernode_client/main.go +++ b/test/supernode_client/main.go @@ -12,7 +12,6 @@ import ( gopath "path" "time" - random "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random" commands "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" corehttp "github.com/ipfs/go-ipfs/core/corehttp" @@ -26,6 +25,7 @@ import ( unit "github.com/ipfs/go-ipfs/thirdparty/unit" "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore" syncds "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/sync" + random "gx/ipfs/QmbRf8gHLzTjhtVR8Qc4hBXF2c3pV7zCcaS8wSXQKx44kv/go-random" context "context" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"