@cryptotaxi247 / kubo / commits / 962e1bbc4

Add test init profile

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Jul 6, 2017 at 21:42 UTC 962e1bbc450927437d3bed41ccb97d997c73c02c
3 files changed +34
cmd/ipfs/init.go
+2
@@ -34,6 +34,8 @@ initialize it using 'server' profile.
34 Available profiles:
35 'server' - Disables local host discovery, recommended when
36 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.
39
40 ipfs uses a repository in the local file system. By default, the repo is
41 located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
repo/config/profile.go
+13
@@ -28,4 +28,17 @@ var ConfigProfiles = map[string]func(*Config) error{
28 c.Discovery.MDNS.Enabled = false
29 return nil
30 },
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 + },
44 }
test/sharness/t0020-init.sh
+19
@@ -148,6 +148,25 @@ test_expect_success "clean up ipfs dir" '
148 rm -rf "$IPFS_PATH"
149 '
150
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 +
170 test_init_ipfs
171
172 test_launch_ipfs_daemon