Skip to content

Commit 9622b6f

Browse files
authored
Merge pull request #104 from ipfs/fix/migration-quic
fix: correctly check for existing quic addresses
2 parents 74e57a5 + f344916 commit 9622b6f

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

ipfs-9-to-10/migration/config_conv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ func ver9to10Addresses(swarm, announce, noAnnounce []string) ([]string, []string
153153
// If the old configuration already has a quic address in it, assume
154154
// the user has already set up their addresses for quic and leave
155155
// things as they are
156-
if strings.Contains(addr, "/udp/quic") {
156+
if strings.HasSuffix(addr, "/quic") {
157157
return swarm, announce, noAnnounce
158158
}
159159
}
160160

161161
return addQuic(swarm), addQuic(announce), addQuic(noAnnounce)
162162
}
163163

164-
var tcpRegexp = regexp.MustCompile(`/tcp/([0-9]+)`)
164+
var tcpRegexp = regexp.MustCompile(`/tcp/([0-9]+)$`)
165165

166166
func addQuic(addrs []string) []string {
167167
res := make([]string, 0, len(addrs)*2)

sharness/t0130-migration-9-to-10.sh

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,34 @@ mkdir -p gopath/bin
1313
export PATH="$(pwd)/../bin:$GOPATH/bin:$PATH"
1414
echo $IPFS_PATH
1515

16+
sort > expected_swarm_addresses <<EOF
17+
/ip4/0.0.0.0/tcp/4001
18+
/ip4/0.0.0.0/udp/4001/quic
19+
/ip4/1.2.3.4/udp/4004/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ/p2p-circuit
20+
/ip6/::/tcp/4002
21+
/ip6/::/tcp/4003/ws
22+
/ip6/::/udp/4002/quic
23+
EOF
24+
25+
get_swarm_addresses() {
26+
ipfs config Addresses.Swarm | sed -n -e 's/^ *"\(.*\)",\?$/\1/p' | sort
27+
}
28+
29+
check_results() {
30+
test_expect_success "get new swarm addresses" '
31+
get_swarm_addresses > actual_swarm_addresses
32+
'
33+
34+
35+
test_expect_success "migration added quic bootstrapper" '
36+
test "$(ipfs config Bootstrap | grep -c "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ")" -eq 1
37+
'
38+
39+
test_expect_success "get new swarm config" '
40+
test_cmp expected_swarm_addresses actual_swarm_addresses
41+
'
42+
}
43+
1644
test_install_ipfs_nd "v0.5.1"
1745

1846
test_init_ipfs_nd
@@ -28,8 +56,13 @@ test_expect_success "add bootstrap addresses" '
2856
]"
2957
'
3058

31-
test_expect_success "remember old swarm config" '
32-
ipfs config Addresses.Swarm | sort > swarm_old
59+
test_expect_success "configure listen addresses" '
60+
test_config_set --json Addresses.Swarm "[
61+
\"/ip4/0.0.0.0/tcp/4001\",
62+
\"/ip6/::/tcp/4002\",
63+
\"/ip6/::/tcp/4003/ws\",
64+
\"/ip4/1.2.3.4/udp/4004/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ/p2p-circuit\"
65+
]"
3366
'
3467

3568
# no need to launch daemon as this works offline
@@ -41,22 +74,24 @@ test_expect_success "run migration 9 to 10" '
4174

4275
test_install_ipfs_nd "v0.6.0-dev"
4376

44-
test_expect_success "migration added quic bootstrapper" '
45-
ipfs config Bootstrap | grep "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
46-
'
77+
check_results
4778

48-
test_expect_success "migration added quic listener" '
49-
ipfs config Addresses.Swarm | grep "quic"
79+
test_expect_success "re-run migration 9 to 10" '
80+
echo 9 > "$IPFS_PATH/version" &&
81+
echo $IPFS_PATH &&
82+
ipfs-9-to-10 -verbose -path="$IPFS_PATH"
5083
'
5184

85+
# Shouldn't do anything this time, now that we have an address.
86+
check_results
87+
5288
test_expect_success "revert migration 10 to 9 succeeds" '
5389
ipfs-9-to-10 -revert -verbose -path="$IPFS_PATH"
5490
'
5591

5692
test_install_ipfs_nd "v0.5.1"
5793

58-
test_expect_success "does not revert bootstrap address" '
59-
ipfs config Bootstrap | grep "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
60-
'
94+
# Should leave everything alone.
95+
check_results
6196

6297
test_done

0 commit comments

Comments
 (0)