diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 4232cc262db4..0e5323683fa7 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -28,6 +28,7 @@ const ( algorithmDefault = options.Ed25519Key algorithmOptionName = "algorithm" bitsOptionName = "bits" + emptyRepoDefault = true emptyRepoOptionName = "empty-repo" profileOptionName = "profile" ) @@ -61,7 +62,7 @@ environment variable: Options: []cmds.Option{ cmds.StringOption(algorithmOptionName, "a", "Cryptographic algorithm to use for key generation.").WithDefault(algorithmDefault), cmds.IntOption(bitsOptionName, "b", "Number of bits to use in the generated RSA private key."), - cmds.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage."), + cmds.BoolOption(emptyRepoOptionName, "e", "Don't add and pin help files to the local storage.").WithDefault(emptyRepoDefault), cmds.StringOption(profileOptionName, "p", "Apply profile settings to config. Multiple profiles can be separated by ','"), // TODO need to decide whether to expose the override as a file or a diff --git a/test/cli/init_test.go b/test/cli/init_test.go index 359856e6baea..a45ef05d5b35 100644 --- a/test/cli/init_test.go +++ b/test/cli/init_test.go @@ -33,9 +33,7 @@ func testInitAlgo(t *testing.T, initFlags []string, expOutputName string, expPee lines := []string{ fmt.Sprintf("generating %s keypair...done", expOutputName), fmt.Sprintf("peer identity: %s", node.PeerID().String()), - fmt.Sprintf("initializing IPFS node at %s", node.Dir), - "to get started, enter:", - fmt.Sprintf("\n\tipfs cat /ipfs/%s/readme\n\n", CIDWelcomeDocs), + fmt.Sprintf("initializing IPFS node at %s\n", node.Dir), } expectedInitOutput := strings.Join(lines, "\n") assert.Equal(t, expectedInitOutput, initRes.Stdout.String()) @@ -54,26 +52,28 @@ func testInitAlgo(t *testing.T, initFlags []string, expOutputName string, expPee res := node.IPFS("config", "Mounts.IPFS") assert.Equal(t, "/ipfs", res.Stdout.Trimmed()) - node.IPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs)) + catRes := node.RunIPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs)) + assert.NotEqual(t, 0, catRes.ExitErr.ExitCode(), "welcome readme doesn't exist") }) - t.Run("init empty repo", func(t *testing.T) { + t.Run("init without empty repo", func(t *testing.T) { t.Parallel() node := harness.NewT(t).NewNode() - initRes := node.IPFS(StrCat("init", "--empty-repo", initFlags)...) + initRes := node.IPFS(StrCat("init", "--empty-repo=false", initFlags)...) validatePeerID(t, node.PeerID(), expPeerIDPubKeyErr, expPeerIDPubKeyType) lines := []string{ fmt.Sprintf("generating %s keypair...done", expOutputName), fmt.Sprintf("peer identity: %s", node.PeerID().String()), - fmt.Sprintf("initializing IPFS node at %s\n", node.Dir), + fmt.Sprintf("initializing IPFS node at %s", node.Dir), + "to get started, enter:", + fmt.Sprintf("\n\tipfs cat /ipfs/%s/readme\n\n", CIDWelcomeDocs), } expectedEmptyInitOutput := strings.Join(lines, "\n") assert.Equal(t, expectedEmptyInitOutput, initRes.Stdout.String()) - catRes := node.RunIPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs)) - assert.NotEqual(t, 0, catRes.ExitErr.ExitCode(), "welcome readme doesn't exist") + node.IPFS("cat", fmt.Sprintf("/ipfs/%s/readme", CIDWelcomeDocs)) idRes := node.IPFS("id", "-f", "") version := node.IPFS("version", "-n").Stdout.Trimmed() diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 1f1491f9ebf6..f135cdd7940e 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -194,7 +194,7 @@ test_config_set() { } test_init_ipfs() { - + args=("$@") # we set the Addresses.API config variable. # the cli client knows to use it, so only need to set. @@ -202,7 +202,7 @@ test_init_ipfs() { test_expect_success "ipfs init succeeds" ' export IPFS_PATH="$(pwd)/.ipfs" && - ipfs init --profile=test > /dev/null + ipfs init "${args[@]}" --profile=test > /dev/null ' test_expect_success "prepare config -- mounting" ' diff --git a/test/sharness/t0025-datastores.sh b/test/sharness/t0025-datastores.sh index ec99accb5e7e..f0ddd4e2e8fe 100755 --- a/test/sharness/t0025-datastores.sh +++ b/test/sharness/t0025-datastores.sh @@ -4,9 +4,9 @@ test_description="Test non-standard datastores" . lib/test-lib.sh -test_expect_success "'ipfs init --profile=badgerds' succeeds" ' +test_expect_success "'ipfs init --empty-repo=false --profile=badgerds' succeeds" ' BITS="2048" && - ipfs init --profile=badgerds + ipfs init --empty-repo=false --profile=badgerds ' test_expect_success "'ipfs pin ls' works" ' diff --git a/test/sharness/t0054-dag-car-import-export.sh b/test/sharness/t0054-dag-car-import-export.sh index f378e9128e56..fe6f11476912 100755 --- a/test/sharness/t0054-dag-car-import-export.sh +++ b/test/sharness/t0054-dag-car-import-export.sh @@ -171,7 +171,7 @@ test_expect_success "shut down nodes" ' # We want to just init the repo, without using a daemon for stuff below -test_init_ipfs +test_init_ipfs --empty-repo=false test_expect_success "basic offline export of 'getting started' dag works" ' diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index 7bd84b276a7e..3f33a5f440b5 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -8,7 +8,7 @@ test_description="Test ipfs repo operations" . lib/test-lib.sh -test_init_ipfs +test_init_ipfs --empty-repo=false test_launch_ipfs_daemon_without_network test_expect_success "'ipfs repo gc' succeeds" ' diff --git a/test/sharness/t0100-name.sh b/test/sharness/t0100-name.sh index 34f33ea4d89b..f49df341754e 100755 --- a/test/sharness/t0100-name.sh +++ b/test/sharness/t0100-name.sh @@ -15,13 +15,13 @@ test_name_with_self() { export IPFS_PATH="$(pwd)/.ipfs" && case $SELF_ALG in default) - ipfs init --profile=test > /dev/null + ipfs init --empty-repo=false --profile=test > /dev/null ;; rsa) - ipfs init --profile=test -a=rsa > /dev/null + ipfs init --empty-repo=false --profile=test -a=rsa > /dev/null ;; ed25519) - ipfs init --profile=test -a=ed25519 > /dev/null + ipfs init --empty-repo=false --profile=test -a=ed25519 > /dev/null ;; esac && export PEERID=`ipfs key list --ipns-base=base36 -l | grep self | cut -d " " -f1` && @@ -273,7 +273,7 @@ test_name_with_key() { test_expect_success "ipfs init (key variant $GEN_ALG)" ' export IPFS_PATH="$(pwd)/.ipfs" && - ipfs init --profile=test > /dev/null + ipfs init --empty-repo=false --profile=test > /dev/null ' test_expect_success "'prepare keys" ' @@ -317,7 +317,7 @@ test_name_with_key 'ed25519_b36' # `ipfs name inspect --verify` using the wrong RSA key should not succeed -test_init_ipfs +test_init_ipfs --empty-repo=false test_launch_ipfs_daemon test_expect_success "prepare RSA keys" ' diff --git a/test/sharness/t0600-issues-and-regressions-online.sh b/test/sharness/t0600-issues-and-regressions-online.sh index 3468f23d6533..56384c0d02e5 100755 --- a/test/sharness/t0600-issues-and-regressions-online.sh +++ b/test/sharness/t0600-issues-and-regressions-online.sh @@ -4,7 +4,7 @@ test_description="Tests for various fixed issues and regressions." . lib/test-lib.sh -test_init_ipfs +test_init_ipfs --empty-repo=false test_launch_ipfs_daemon