Skip to content

Commit

Permalink
Replace go-random with random-data from go-test
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Feb 24, 2025
1 parent 84f665a commit 48cc54e
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 179 deletions.
4 changes: 2 additions & 2 deletions docs/examples/kubo-as-a-library/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fG
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
github.com/ipfs/go-peertaskqueue v0.8.2 h1:PaHFRaVFdxQk1Qo3OKiHPYjmmusQy7gKQUaL8JDszAU=
github.com/ipfs/go-peertaskqueue v0.8.2/go.mod h1:L6QPvou0346c2qPJNiJa6BvOibxDfaiPlqHInmzg0FA=
github.com/ipfs/go-test v0.2.0 h1:tKJ722lo/c8+04Qm67BZ1XsI2UfTtF2hsfmxqkuBnHs=
github.com/ipfs/go-test v0.2.0/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
github.com/ipfs/go-test v0.2.1 h1:/D/a8xZ2JzkYqcVcV/7HYlCnc7bv/pKHQiX5TdClkPE=
github.com/ipfs/go-test v0.2.1/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
github.com/ipfs/go-unixfsnode v1.9.2 h1:0A12BYs4XOtDPJTMlwmNPlllDfqcc4yie4e919hcUXk=
github.com/ipfs/go-unixfsnode v1.9.2/go.mod h1:v1nuMFHf4QTIhFUdPMvg1nQu7AqDLvIdwyvJ531Ot1U=
github.com/ipfs/go-verifcid v0.0.3 h1:gmRKccqhWDocCRkC+a59g5QW7uJw5bpX9HWBevXa0zs=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-metrics-interface v0.0.1
github.com/ipfs/go-metrics-prometheus v0.0.3
github.com/ipfs/go-test v0.2.0
github.com/ipfs/go-test v0.2.1
github.com/ipfs/go-unixfsnode v1.9.2
github.com/ipld/go-car v0.6.2
github.com/ipld/go-car/v2 v2.14.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ github.com/ipfs/go-metrics-prometheus v0.0.3 h1:MVgBw30nE9eKC598ZQg+LIIbgIcx46NG
github.com/ipfs/go-metrics-prometheus v0.0.3/go.mod h1:qjWVLyK+ZJrQuiyTqfgoECgKfd4b4lEtpQemAWomWc8=
github.com/ipfs/go-peertaskqueue v0.8.2 h1:PaHFRaVFdxQk1Qo3OKiHPYjmmusQy7gKQUaL8JDszAU=
github.com/ipfs/go-peertaskqueue v0.8.2/go.mod h1:L6QPvou0346c2qPJNiJa6BvOibxDfaiPlqHInmzg0FA=
github.com/ipfs/go-test v0.2.0 h1:tKJ722lo/c8+04Qm67BZ1XsI2UfTtF2hsfmxqkuBnHs=
github.com/ipfs/go-test v0.2.0/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
github.com/ipfs/go-test v0.2.1 h1:/D/a8xZ2JzkYqcVcV/7HYlCnc7bv/pKHQiX5TdClkPE=
github.com/ipfs/go-test v0.2.1/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
github.com/ipfs/go-unixfsnode v1.9.2 h1:0A12BYs4XOtDPJTMlwmNPlllDfqcc4yie4e919hcUXk=
github.com/ipfs/go-unixfsnode v1.9.2/go.mod h1:v1nuMFHf4QTIhFUdPMvg1nQu7AqDLvIdwyvJ531Ot1U=
github.com/ipfs/go-verifcid v0.0.3 h1:gmRKccqhWDocCRkC+a59g5QW7uJw5bpX9HWBevXa0zs=
Expand Down
6 changes: 3 additions & 3 deletions test/bin/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ $(d)/cid-fmt: github.com/ipfs/go-cidutil/cid-fmt
$(go-build-testdep)
TGTS_$(d) += $(d)/cid-fmt

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

.PHONY: github.com/ipfs/go-test/cli/random-files
$(d)/random-files: github.com/ipfs/go-test/cli/random-files
Expand Down
2 changes: 1 addition & 1 deletion test/dependencies/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
_ "github.com/Kubuxu/gocovmerge"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/ipfs/go-cidutil/cid-fmt"
_ "github.com/ipfs/go-test/cli/random-data"
_ "github.com/ipfs/go-test/cli/random-files"
_ "github.com/ipfs/hang-fds"
_ "github.com/jbenet/go-random/random"
_ "github.com/multiformats/go-multihash/multihash"
_ "gotest.tools/gotestsum"
)
4 changes: 1 addition & 3 deletions test/dependencies/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ require (
github.com/golangci/golangci-lint v1.60.2
github.com/ipfs/go-cidutil v0.1.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/ipfs/go-test v0.2.0
github.com/ipfs/go-test v0.2.1
github.com/ipfs/hang-fds v0.1.0
github.com/ipfs/iptb v1.4.1
github.com/ipfs/iptb-plugins v0.5.1
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/multiformats/go-multiaddr v0.14.0
github.com/multiformats/go-multihash v0.2.3
gotest.tools/gotestsum v1.12.0
Expand Down Expand Up @@ -65,7 +64,6 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/dnephin/pflag v1.0.7 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ettle/strcase v0.2.0 // indirect
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
github.com/fatih/color v1.17.0 // indirect
Expand Down
8 changes: 2 additions & 6 deletions test/dependencies/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Z
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/uo=
github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -351,8 +349,8 @@ github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fG
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
github.com/ipfs/go-peertaskqueue v0.8.2 h1:PaHFRaVFdxQk1Qo3OKiHPYjmmusQy7gKQUaL8JDszAU=
github.com/ipfs/go-peertaskqueue v0.8.2/go.mod h1:L6QPvou0346c2qPJNiJa6BvOibxDfaiPlqHInmzg0FA=
github.com/ipfs/go-test v0.2.0 h1:tKJ722lo/c8+04Qm67BZ1XsI2UfTtF2hsfmxqkuBnHs=
github.com/ipfs/go-test v0.2.0/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
github.com/ipfs/go-test v0.2.1 h1:/D/a8xZ2JzkYqcVcV/7HYlCnc7bv/pKHQiX5TdClkPE=
github.com/ipfs/go-test v0.2.1/go.mod h1:dzu+KB9cmWjuJnXFDYJwC25T3j1GcN57byN+ixmK39M=
github.com/ipfs/hang-fds v0.1.0 h1:deBiFlWHsVGzJ0ZMaqscEqRM1r2O1rFZ59UiQXb1Xko=
github.com/ipfs/hang-fds v0.1.0/go.mod h1:29VLWOn3ftAgNNgXg/al7b11UzuQ+w7AwtCGcTaWkbM=
github.com/ipfs/iptb v1.4.1 h1:faXd3TKGPswbHyZecqqg6UfbES7RDjTKQb+6VFPKDUo=
Expand All @@ -368,8 +366,6 @@ github.com/ipshipyard/p2p-forge v0.3.0/go.mod h1:L0TJMzniMEDjX8G+RB201U2woHvASwb
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c h1:uUx61FiAa1GI6ZmVd2wf2vULeQZIKG66eybjNXKYCz4=
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c/go.mod h1:sdx1xVM9UuLw1tXnhJWN3piypTUO3vCIHYmG15KE/dU=
github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk=
github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk=
github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o=
Expand Down
4 changes: 2 additions & 2 deletions test/sharness/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ SHARNESS_$(d) = $(d)/lib/sharness/sharness.sh

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

DEPS_$(d) := test/bin/random test/bin/multihash test/bin/pollEndpoint \
test/bin/iptb test/bin/go-sleep test/bin/random-files \
DEPS_$(d) := test/bin/multihash test/bin/pollEndpoint test/bin/iptb \
test/bin/go-sleep test/bin/random-data test/bin/random-files \
test/bin/go-timeout test/bin/hang-fds test/bin/ma-pipe-unidir \
test/bin/cid-fmt
DEPS_$(d) += cmd/ipfs/ipfs
Expand Down
36 changes: 18 additions & 18 deletions test/sharness/t0040-add-and-cat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ test_add_cat_5MB() {
ADD_FLAGS="$1"
EXP_HASH="$2"

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

test_expect_success "sha1 of the file looks ok" '
echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
echo "11145b8c4bc8f87ea2fcfc3d55708b8cac2aadf12862" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'
Expand Down Expand Up @@ -594,12 +594,12 @@ test_add_cat_expensive() {
ADD_FLAGS="$1"
HASH="$2"

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

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

test_expect_success EXPENSIVE "ipfs cat output hashed looks good" '
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
echo "11144f604a7e705e4d061e35fea728e0c6cc7f5ba5d5" >sha1_expected &&
test_cmp sha1_expected sha1_actual
'

Expand Down Expand Up @@ -902,42 +902,42 @@ test_expect_success "'ipfs add -rn' output looks good" '
test_cmp expected actual
'

test_expect_success "go-random is installed" '
type random
test_expect_success "random-data is installed" '
type random-data
'

test_add_cat_5MB "" "QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb"
test_add_cat_5MB "" "QmapAfmzmeWYTNztMQEhUXFcSGrsax22WRG7YN9xLdMeQq"

test_add_cat_5MB --raw-leaves "QmbdLHCmdi48eM8T7D67oXjA1S2Puo8eMfngdHhdPukFd6"
test_add_cat_5MB --raw-leaves "QmabWSFaPusmiZaaVZLhEUtHcj8CCvVeUfkBpKqAkKVMiS"

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

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

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

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

test_add_cat_expensive "" "QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3"
test_add_cat_expensive "" "Qma1WZKC3jad7e3F7GEDvkFdhPLyMEhKszBF4nBUCBGh6c"

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

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

test_add_named_pipe

Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0043-add-w.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ add_w_r='QmUerh2irM8cngqJHLGKCn4AGBSyHYAUi8i8zyVzXKNYyb'

test_add_w() {

test_expect_success "go-random-files is installed" '
test_expect_success "random-files is installed" '
type random-files
'

Expand Down
Loading

0 comments on commit 48cc54e

Please sign in to comment.