Skip to content

Commit 2ca5637

Browse files
authored
Replace go-random with random-data from go-test package (#10731)
* Replace go-random with random-data from go-test package
1 parent 96215c5 commit 2ca5637

22 files changed

+174
-180
lines changed

docs/examples/kubo-as-a-library/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fG
388388
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
389389
github.com/ipfs/go-peertaskqueue v0.8.2 h1:PaHFRaVFdxQk1Qo3OKiHPYjmmusQy7gKQUaL8JDszAU=
390390
github.com/ipfs/go-peertaskqueue v0.8.2/go.mod h1:L6QPvou0346c2qPJNiJa6BvOibxDfaiPlqHInmzg0FA=
391-
github.com/ipfs/go-test v0.2.0 h1:tKJ722lo/c8+04Qm67BZ1XsI2UfTtF2hsfmxqkuBnHs=
392-
github.com/ipfs/go-test v0.2.0/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
391+
github.com/ipfs/go-test v0.2.1 h1:/D/a8xZ2JzkYqcVcV/7HYlCnc7bv/pKHQiX5TdClkPE=
392+
github.com/ipfs/go-test v0.2.1/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
393393
github.com/ipfs/go-unixfsnode v1.9.2 h1:0A12BYs4XOtDPJTMlwmNPlllDfqcc4yie4e919hcUXk=
394394
github.com/ipfs/go-unixfsnode v1.9.2/go.mod h1:v1nuMFHf4QTIhFUdPMvg1nQu7AqDLvIdwyvJ531Ot1U=
395395
github.com/ipfs/go-verifcid v0.0.3 h1:gmRKccqhWDocCRkC+a59g5QW7uJw5bpX9HWBevXa0zs=

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ require (
4343
github.com/ipfs/go-log/v2 v2.5.1
4444
github.com/ipfs/go-metrics-interface v0.0.1
4545
github.com/ipfs/go-metrics-prometheus v0.0.3
46-
github.com/ipfs/go-test v0.2.0
46+
github.com/ipfs/go-test v0.2.1
4747
github.com/ipfs/go-unixfsnode v1.9.2
4848
github.com/ipld/go-car v0.6.2
4949
github.com/ipld/go-car/v2 v2.14.2

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ github.com/ipfs/go-metrics-prometheus v0.0.3 h1:MVgBw30nE9eKC598ZQg+LIIbgIcx46NG
456456
github.com/ipfs/go-metrics-prometheus v0.0.3/go.mod h1:qjWVLyK+ZJrQuiyTqfgoECgKfd4b4lEtpQemAWomWc8=
457457
github.com/ipfs/go-peertaskqueue v0.8.2 h1:PaHFRaVFdxQk1Qo3OKiHPYjmmusQy7gKQUaL8JDszAU=
458458
github.com/ipfs/go-peertaskqueue v0.8.2/go.mod h1:L6QPvou0346c2qPJNiJa6BvOibxDfaiPlqHInmzg0FA=
459-
github.com/ipfs/go-test v0.2.0 h1:tKJ722lo/c8+04Qm67BZ1XsI2UfTtF2hsfmxqkuBnHs=
460-
github.com/ipfs/go-test v0.2.0/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
459+
github.com/ipfs/go-test v0.2.1 h1:/D/a8xZ2JzkYqcVcV/7HYlCnc7bv/pKHQiX5TdClkPE=
460+
github.com/ipfs/go-test v0.2.1/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
461461
github.com/ipfs/go-unixfsnode v1.9.2 h1:0A12BYs4XOtDPJTMlwmNPlllDfqcc4yie4e919hcUXk=
462462
github.com/ipfs/go-unixfsnode v1.9.2/go.mod h1:v1nuMFHf4QTIhFUdPMvg1nQu7AqDLvIdwyvJ531Ot1U=
463463
github.com/ipfs/go-verifcid v0.0.3 h1:gmRKccqhWDocCRkC+a59g5QW7uJw5bpX9HWBevXa0zs=

test/bin/Rules.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ $(d)/cid-fmt: github.com/ipfs/go-cidutil/cid-fmt
5858
$(go-build-testdep)
5959
TGTS_$(d) += $(d)/cid-fmt
6060

61-
.PHONY: github.com/jbenet/go-random/random
62-
$(d)/random: github.com/jbenet/go-random/random
61+
.PHONY: github.com/ipfs/go-test/cli/random-data
62+
$(d)/random-data: github.com/ipfs/go-test/cli/random-data
6363
$(go-build-testdep)
64-
TGTS_$(d) += $(d)/random
64+
TGTS_$(d) += $(d)/random-data
6565

6666
.PHONY: github.com/ipfs/go-test/cli/random-files
6767
$(d)/random-files: github.com/ipfs/go-test/cli/random-files

test/dependencies/dependencies.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
_ "github.com/Kubuxu/gocovmerge"
88
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
99
_ "github.com/ipfs/go-cidutil/cid-fmt"
10+
_ "github.com/ipfs/go-test/cli/random-data"
1011
_ "github.com/ipfs/go-test/cli/random-files"
1112
_ "github.com/ipfs/hang-fds"
12-
_ "github.com/jbenet/go-random/random"
1313
_ "github.com/multiformats/go-multihash/multihash"
1414
_ "gotest.tools/gotestsum"
1515
)

test/dependencies/go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ require (
99
github.com/golangci/golangci-lint v1.60.2
1010
github.com/ipfs/go-cidutil v0.1.0
1111
github.com/ipfs/go-log/v2 v2.5.1
12-
github.com/ipfs/go-test v0.2.0
12+
github.com/ipfs/go-test v0.2.1
1313
github.com/ipfs/hang-fds v0.1.0
1414
github.com/ipfs/iptb v1.4.1
1515
github.com/ipfs/iptb-plugins v0.5.1
16-
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
1716
github.com/multiformats/go-multiaddr v0.14.0
1817
github.com/multiformats/go-multihash v0.2.3
1918
gotest.tools/gotestsum v1.12.0
@@ -65,7 +64,6 @@ require (
6564
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
6665
github.com/denis-tingaikin/go-header v0.5.0 // indirect
6766
github.com/dnephin/pflag v1.0.7 // indirect
68-
github.com/dustin/go-humanize v1.0.1 // indirect
6967
github.com/ettle/strcase v0.2.0 // indirect
7068
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
7169
github.com/fatih/color v1.17.0 // indirect

test/dependencies/go.sum

+2-6
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Z
130130
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
131131
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
132132
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
133-
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
134-
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
135133
github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/uo=
136134
github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
137135
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -351,8 +349,8 @@ github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fG
351349
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
352350
github.com/ipfs/go-peertaskqueue v0.8.2 h1:PaHFRaVFdxQk1Qo3OKiHPYjmmusQy7gKQUaL8JDszAU=
353351
github.com/ipfs/go-peertaskqueue v0.8.2/go.mod h1:L6QPvou0346c2qPJNiJa6BvOibxDfaiPlqHInmzg0FA=
354-
github.com/ipfs/go-test v0.2.0 h1:tKJ722lo/c8+04Qm67BZ1XsI2UfTtF2hsfmxqkuBnHs=
355-
github.com/ipfs/go-test v0.2.0/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
352+
github.com/ipfs/go-test v0.2.1 h1:/D/a8xZ2JzkYqcVcV/7HYlCnc7bv/pKHQiX5TdClkPE=
353+
github.com/ipfs/go-test v0.2.1/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
356354
github.com/ipfs/hang-fds v0.1.0 h1:deBiFlWHsVGzJ0ZMaqscEqRM1r2O1rFZ59UiQXb1Xko=
357355
github.com/ipfs/hang-fds v0.1.0/go.mod h1:29VLWOn3ftAgNNgXg/al7b11UzuQ+w7AwtCGcTaWkbM=
358356
github.com/ipfs/iptb v1.4.1 h1:faXd3TKGPswbHyZecqqg6UfbES7RDjTKQb+6VFPKDUo=
@@ -368,8 +366,6 @@ github.com/ipshipyard/p2p-forge v0.3.0/go.mod h1:L0TJMzniMEDjX8G+RB201U2woHvASwb
368366
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
369367
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
370368
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
371-
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c h1:uUx61FiAa1GI6ZmVd2wf2vULeQZIKG66eybjNXKYCz4=
372-
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c/go.mod h1:sdx1xVM9UuLw1tXnhJWN3piypTUO3vCIHYmG15KE/dU=
373369
github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk=
374370
github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk=
375371
github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o=

test/sharness/Rules.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ SHARNESS_$(d) = $(d)/lib/sharness/sharness.sh
44

55
T_$(d) = $(sort $(wildcard $(d)/t[0-9][0-9][0-9][0-9]-*.sh))
66

7-
DEPS_$(d) := test/bin/random test/bin/multihash test/bin/pollEndpoint \
8-
test/bin/iptb test/bin/go-sleep test/bin/random-files \
7+
DEPS_$(d) := test/bin/multihash test/bin/pollEndpoint test/bin/iptb \
8+
test/bin/go-sleep test/bin/random-data test/bin/random-files \
99
test/bin/go-timeout test/bin/hang-fds test/bin/ma-pipe-unidir \
1010
test/bin/cid-fmt
1111
DEPS_$(d) += cmd/ipfs/ipfs

test/sharness/t0040-add-and-cat.sh

+18-18
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,12 @@ test_add_cat_5MB() {
484484
ADD_FLAGS="$1"
485485
EXP_HASH="$2"
486486

487-
test_expect_success "generate 5MB file using go-random" '
488-
random 5242880 41 >mountdir/bigfile
487+
test_expect_success "generate 5MB file using random-data" '
488+
random-data -size=5242880 -seed=41 >mountdir/bigfile
489489
'
490490

491491
test_expect_success "sha1 of the file looks ok" '
492-
echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
492+
echo "11145b8c4bc8f87ea2fcfc3d55708b8cac2aadf12862" >sha1_expected &&
493493
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
494494
test_cmp sha1_expected sha1_actual
495495
'
@@ -594,12 +594,12 @@ test_add_cat_expensive() {
594594
ADD_FLAGS="$1"
595595
HASH="$2"
596596

597-
test_expect_success EXPENSIVE "generate 100MB file using go-random" '
598-
random 104857600 42 >mountdir/bigfile
597+
test_expect_success EXPENSIVE "generate 100MB file using random-data" '
598+
random-data -size=104857600 -seed=42 >mountdir/bigfile
599599
'
600600

601601
test_expect_success EXPENSIVE "sha1 of the file looks ok" '
602-
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
602+
echo "11141e8c04d7cd019cc0acf0311a8ca6cf2c18413c96" >sha1_expected &&
603603
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
604604
test_cmp sha1_expected sha1_actual
605605
'
@@ -623,7 +623,7 @@ test_add_cat_expensive() {
623623
'
624624

625625
test_expect_success EXPENSIVE "ipfs cat output hashed looks good" '
626-
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
626+
echo "11141e8c04d7cd019cc0acf0311a8ca6cf2c18413c96" >sha1_expected &&
627627
test_cmp sha1_expected sha1_actual
628628
'
629629

@@ -902,42 +902,42 @@ test_expect_success "'ipfs add -rn' output looks good" '
902902
test_cmp expected actual
903903
'
904904

905-
test_expect_success "go-random is installed" '
906-
type random
905+
test_expect_success "random-data is installed" '
906+
type random-data
907907
'
908908

909-
test_add_cat_5MB "" "QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb"
909+
test_add_cat_5MB "" "QmapAfmzmeWYTNztMQEhUXFcSGrsax22WRG7YN9xLdMeQq"
910910

911-
test_add_cat_5MB --raw-leaves "QmbdLHCmdi48eM8T7D67oXjA1S2Puo8eMfngdHhdPukFd6"
911+
test_add_cat_5MB --raw-leaves "QmabWSFaPusmiZaaVZLhEUtHcj8CCvVeUfkBpKqAkKVMiS"
912912

913913
# note: the specified hash implies that internal nodes are stored
914914
# using CidV1 and leaves are stored using raw blocks
915-
test_add_cat_5MB --cid-version=1 "bafybeigfnx3tka2rf5ovv2slb7ymrt4zbwa3ryeqibe6fipyt5vgsrli3u"
915+
test_add_cat_5MB --cid-version=1 "bafybeifwdkm32fmukqwh3jofm6ma76bcqvn6opxstsnzmya7utboi4cb2m"
916916

917917
# note: the specified hash implies that internal nodes are stored
918918
# using CidV1 and leaves are stored using CidV1 but using the legacy
919919
# format (i.e. not raw)
920-
test_add_cat_5MB '--cid-version=1 --raw-leaves=false' "bafybeieyifrgpjn3yengthr7qaj72ozm2aq3wm53srgeprc43w67qpvfqa"
920+
test_add_cat_5MB '--cid-version=1 --raw-leaves=false' "bafybeifq4unep5w4agr3nlynxidj2rymf6dzu6bf4ieqqildkboe5mdmne"
921921

922922
# note: --hash=blake2b-256 implies --cid-version=1 which implies --raw-leaves=true
923923
# the specified hash represents the leaf nodes stored as raw leaves and
924924
# encoded with the blake2b-256 hash function
925-
test_add_cat_5MB '--hash=blake2b-256' "bafykbzacebnmjcl4sn37b3ehtibvf263oun2w6idghenrvlpehq5w5jqyvhjo"
925+
test_add_cat_5MB '--hash=blake2b-256' "bafykbzacebxcnlql4oc3mtscqn32aumqkqxxv3wt7dkyrphgh6lc2gckiq6bw"
926926

927927
# the specified hash represents the leaf nodes stored as protoful nodes and
928928
# encoded with the blake2b-256 hash function
929-
test_add_cat_5MB '--hash=blake2b-256 --raw-leaves=false' "bafykbzaceaxiiykzgpbhnzlecffqm3zbuvhujyvxe5scltksyafagkyw4rjn2"
929+
test_add_cat_5MB '--hash=blake2b-256 --raw-leaves=false' "bafykbzacearibnoamkfmcagpfgk2sbgx65qftnsrh4ttd3g7ghooasfnyavme"
930930

931-
test_add_cat_expensive "" "QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3"
931+
test_add_cat_expensive "" "Qma1WZKC3jad7e3F7GEDvkFdhPLyMEhKszBF4nBUCBGh6c"
932932

933933
# note: the specified hash implies that internal nodes are stored
934934
# using CidV1 and leaves are stored using raw blocks
935-
test_add_cat_expensive "--cid-version=1" "bafybeidkj5ecbhrqmzrcee2rw7qwsx24z3364qya3fnp2ktkg2tnsrewhi"
935+
test_add_cat_expensive "--cid-version=1" "bafybeibdfw7nsmb3erhej2k6v4eopaswsf5yfv2ikweqa3qsc5no4jywqu"
936936

937937
# note: --hash=blake2b-256 implies --cid-version=1 which implies --raw-leaves=true
938938
# the specified hash represents the leaf nodes stored as raw leaves and
939939
# encoded with the blake2b-256 hash function
940-
test_add_cat_expensive '--hash=blake2b-256' "bafykbzaceb26fnq5hz5iopzamcb4yqykya5x6a4nvzdmcyuu4rj2akzs3z7r6"
940+
test_add_cat_expensive '--hash=blake2b-256' "bafykbzaceduy3thhmcf6ptfqzxberlvj7sgo4uokrvd6qwrhim6r3rgcb26qi"
941941

942942
test_add_named_pipe
943943

test/sharness/t0043-add-w.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ add_w_r='QmUerh2irM8cngqJHLGKCn4AGBSyHYAUi8i8zyVzXKNYyb'
5353

5454
test_add_w() {
5555

56-
test_expect_success "go-random-files is installed" '
56+
test_expect_success "random-files is installed" '
5757
type random-files
5858
'
5959

0 commit comments

Comments
 (0)