Skip to content

Commit 00573cb

Browse files
Merge pull request ipfs#4045 from ipfs/feat/test-profile
Add test init profile
2 parents 0b481a3 + 962e1bb commit 00573cb

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

cmd/ipfs/init.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ initialize it using 'server' profile.
3434
Available profiles:
3535
'server' - Disables local host discovery, recommended when
3636
running IPFS on machines with public IPv4 addresses.
37+
'test' - Reduces external interference of IPFS daemon, this
38+
is useful when using the daemon in test environments.
3739
3840
ipfs uses a repository in the local file system. By default, the repo is
3941
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH

repo/config/profile.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,17 @@ var ConfigProfiles = map[string]func(*Config) error{
2828
c.Discovery.MDNS.Enabled = false
2929
return nil
3030
},
31+
"test": func(c *Config) error {
32+
c.Addresses.API = "/ip4/127.0.0.1/tcp/0"
33+
c.Addresses.Gateway = "/ip4/127.0.0.1/tcp/0"
34+
35+
c.Swarm.DisableNatPortMap = true
36+
c.Addresses.Swarm = []string{
37+
"/ip4/127.0.0.1/tcp/0",
38+
}
39+
40+
c.Bootstrap = []string{}
41+
c.Discovery.MDNS.Enabled = false
42+
return nil
43+
},
3144
}

test/sharness/t0020-init.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,25 @@ test_expect_success "clean up ipfs dir" '
148148
rm -rf "$IPFS_PATH"
149149
'
150150

151+
test_expect_success "'ipfs init --profile=test' succeeds" '
152+
BITS="1024" &&
153+
ipfs init --bits="$BITS" --profile=test
154+
'
155+
156+
test_expect_success "'ipfs config Bootstrap' looks good" '
157+
ipfs config Bootstrap > actual_config &&
158+
test $(cat actual_config) = "[]"
159+
'
160+
161+
test_expect_success "'ipfs config Addresses.API' looks good" '
162+
ipfs config Addresses.API > actual_config &&
163+
test $(cat actual_config) = "/ip4/127.0.0.1/tcp/0"
164+
'
165+
166+
test_expect_success "clean up ipfs dir" '
167+
rm -rf "$IPFS_PATH"
168+
'
169+
151170
test_init_ipfs
152171

153172
test_launch_ipfs_daemon

0 commit comments

Comments
 (0)