core/node: prioritize announcing pin roots, and flat strategy (#10376)
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Henrique Dias committed
Apr 9, 2024 at 08:37 UTC
6f2a61e1dfb268db5e534805afd6c2204bc82d71
13 files changed
+201
-222
core/node/provider.go
+19
-5
@@ -129,11 +129,13 @@ func OnlineProviders(useStrategicProviding bool, reprovideStrategy string, repro
129
var keyProvider fx.Option
130
switch reprovideStrategy {
131
case "all", "":
132
- keyProvider = fx.Provide(provider.NewBlockstoreProvider)
132
+ keyProvider = fx.Provide(newProvidingStrategy(false, false))
133
case "roots":
134
- keyProvider = fx.Provide(pinnedProviderStrategy(true))
134
+ keyProvider = fx.Provide(newProvidingStrategy(true, true))
135
case "pinned":
136
- keyProvider = fx.Provide(pinnedProviderStrategy(false))
136
+ keyProvider = fx.Provide(newProvidingStrategy(true, false))
137
+ case "flat":
138
+ keyProvider = fx.Provide(provider.NewBlockstoreProvider)
139
default:
140
return fx.Error(fmt.Errorf("unknown reprovider strategy %q", reprovideStrategy))
141
}
@@ -149,13 +151,25 @@ func OfflineProviders() fx.Option {
151
return fx.Provide(provider.NewNoopProvider)
152
}
153
152
-func pinnedProviderStrategy(onlyRoots bool) interface{} {
154
+func newProvidingStrategy(onlyPinned, onlyRoots bool) interface{} {
155
type input struct {
156
fx.In
157
Pinner pin.Pinner
158
+ Blockstore blockstore.Blockstore
159
IPLDFetcher fetcher.Factory `name:"ipldFetcher"`
160
}
161
return func(in input) provider.KeyChanFunc {
159
- return provider.NewPinnedProvider(onlyRoots, in.Pinner, in.IPLDFetcher)
162
+ if onlyRoots {
163
+ return provider.NewPinnedProvider(true, in.Pinner, in.IPLDFetcher)
164
+ }
165
+
166
+ if onlyPinned {
167
+ return provider.NewPinnedProvider(false, in.Pinner, in.IPLDFetcher)
168
+ }
169
+
170
+ return provider.NewPrioritizedProvider(
171
+ provider.NewPinnedProvider(true, in.Pinner, in.IPLDFetcher),
172
+ provider.NewBlockstoreProvider(in.Blockstore),
173
+ )
174
}
175
}
docs/changelogs/v0.28.md
+5
@@ -10,6 +10,7 @@
10
- [Gateway: `/api/v0` is removed](#gateway-apiv0-is-removed)
11
- [Removed deprecated Object API commands](#removed-deprecated-object-api-commands)
12
- [No longer publishes loopback and private addresses on DHT](#no-longer-publishes-loopback-and-private-addresses-on-dht)
13
+ - [Pin roots are now prioritized when announcing](#pin-roots-are-now-prioritized-when-announcing)
14
- [📝 Changelog](#-changelog)
15
- [👨👩👧👦 Contributors](#-contributors)
16
@@ -35,6 +36,10 @@ Kubo no longer keeps track of loopback and private addresses on the LAN and WAN
36
37
To support testing scenarios where multiple Kubo instances run on the same machine, [`Routing.LoopbackAddressesOnLanDHT`](https://github.com/ipfs/kubo/blob/master/docs/config.md#routingloopbackaddressesonlandht) is set to `true` when the `test` profile is applied.
38
39
+#### Pin roots are now prioritized when announcing
40
+
41
+The root CIDs of pinned content are now prioritized when announcing to the Amino DHT with [`Reprovider.Strategy`](https://github.com/ipfs/kubo/blob/master/docs/config.md#reproviderstrategy) set to `all` (default) or `pinned`, making the important CIDs accessible faster.
42
+
43
### 📝 Changelog
44
45
### 👨👩👧👦 Contributors
docs/config.md
+3
@@ -1503,7 +1503,9 @@ Type: `optionalDuration` (unset for the default)
1503
Tells reprovider what should be announced. Valid strategies are:
1504
1505
- `"all"` - announce all CIDs of stored blocks
1506
+ - Order: root blocks of direct and recursive pins are announced first, then the rest of blockstore
1507
- `"pinned"` - only announce pinned CIDs recursively (both roots and child blocks)
1508
+ - Order: root blocks of direct and recursive pins are announced first, then the child blocks of recursive pins
1509
- `"roots"` - only announce the root block of explicitly pinned CIDs
1510
- **⚠️ BE CAREFUL:** node with `roots` strategy will not announce child blocks.
1511
It makes sense only for use cases where the entire DAG is fetched in full,
@@ -1512,6 +1514,7 @@ Tells reprovider what should be announced. Valid strategies are:
1514
providers for the missing block in the middle of a file, unless the peer
1515
happens to already be connected to a provider and ask for child CID over
1516
bitswap.
1517
+- `"flat"` - same as `all`, announce all CIDs of stored blocks, but without prioritizing anything
1518
1519
Default: `"all"`
1520
docs/examples/kubo-as-a-library/go.mod
+1
-1
@@ -9,7 +9,7 @@ toolchain go1.22.0
9
replace github.com/ipfs/kubo => ./../../..
10
11
require (
12
- github.com/ipfs/boxo v0.18.0
12
+ github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d
13
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
14
github.com/libp2p/go-libp2p v0.33.2
15
github.com/multiformats/go-multiaddr v0.12.3
docs/examples/kubo-as-a-library/go.sum
+2
-2
@@ -266,8 +266,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
266
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
267
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
268
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
269
-github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw=
270
-github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
269
+github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d h1:4y8xHp4ZDUgnwXK3a146K/sEYq6BSO/nA46DOLMVp5k=
270
+github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d/go.mod h1:V5gJzbIMwKEXrg3IdvAxIdF7UPgU4RsXmNGS8MQ/0D4=
271
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
272
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
273
github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk=
go.mod
+1
-1
@@ -17,7 +17,7 @@ require (
17
github.com/hashicorp/go-multierror v1.1.1
18
github.com/ipfs-shipyard/nopfs v0.0.12
19
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c
20
- github.com/ipfs/boxo v0.18.0
20
+ github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d
21
github.com/ipfs/go-block-format v0.2.0
22
github.com/ipfs/go-cid v0.4.1
23
github.com/ipfs/go-cidutil v0.1.0
go.sum
+2
-2
@@ -329,8 +329,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
329
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
330
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
331
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
332
-github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw=
333
-github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
332
+github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d h1:4y8xHp4ZDUgnwXK3a146K/sEYq6BSO/nA46DOLMVp5k=
333
+github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d/go.mod h1:V5gJzbIMwKEXrg3IdvAxIdF7UPgU4RsXmNGS8MQ/0D4=
334
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
335
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
336
github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=
test/cli/provider_test.go
new
+165
@@ -0,0 +1,165 @@
1
+package cli
2
+
3
+import (
4
+ "bytes"
5
+ "testing"
6
+ "time"
7
+
8
+ "github.com/ipfs/kubo/test/cli/harness"
9
+ "github.com/ipfs/kubo/test/cli/testutils"
10
+ "github.com/stretchr/testify/require"
11
+)
12
+
13
+func TestProvider(t *testing.T) {
14
+ t.Parallel()
15
+
16
+ initNodes := func(t *testing.T, n int, fn func(n *harness.Node)) harness.Nodes {
17
+ nodes := harness.NewT(t).NewNodes(n).Init()
18
+ nodes.ForEachPar(fn)
19
+ return nodes.StartDaemons().Connect()
20
+ }
21
+
22
+ expectNoProviders := func(t *testing.T, cid string, nodes ...*harness.Node) {
23
+ for _, node := range nodes {
24
+ res := node.IPFS("routing", "findprovs", "-n=1", cid)
25
+ require.Empty(t, res.Stdout.String())
26
+ }
27
+ }
28
+
29
+ expectProviders := func(t *testing.T, cid, expectedProvider string, nodes ...*harness.Node) {
30
+ for _, node := range nodes {
31
+ res := node.IPFS("routing", "findprovs", "-n=1", cid)
32
+ require.Equal(t, expectedProvider, res.Stdout.Trimmed())
33
+ }
34
+ }
35
+
36
+ t.Run("Basic Providing", func(t *testing.T) {
37
+ t.Parallel()
38
+
39
+ nodes := initNodes(t, 2, func(n *harness.Node) {
40
+ n.SetIPFSConfig("Experimental.StrategicProviding", false)
41
+ })
42
+ defer nodes.StopDaemons()
43
+
44
+ cid := nodes[0].IPFSAddStr(time.Now().String())
45
+ expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...)
46
+ })
47
+
48
+ t.Run("Basic Strategic Providing", func(t *testing.T) {
49
+ t.Parallel()
50
+
51
+ nodes := initNodes(t, 2, func(n *harness.Node) {
52
+ n.SetIPFSConfig("Experimental.StrategicProviding", true)
53
+ })
54
+ defer nodes.StopDaemons()
55
+
56
+ cid := nodes[0].IPFSAddStr(time.Now().String())
57
+ expectNoProviders(t, cid, nodes[1:]...)
58
+ })
59
+
60
+ t.Run("Reprovides with 'all' strategy", func(t *testing.T) {
61
+ t.Parallel()
62
+
63
+ nodes := initNodes(t, 2, func(n *harness.Node) {
64
+ n.SetIPFSConfig("Reprovider.Strategy", "all")
65
+ })
66
+ defer nodes.StopDaemons()
67
+
68
+ cid := nodes[0].IPFSAddStr(time.Now().String(), "--local")
69
+
70
+ expectNoProviders(t, cid, nodes[1:]...)
71
+
72
+ nodes[0].IPFS("bitswap", "reprovide")
73
+
74
+ expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...)
75
+ })
76
+
77
+ t.Run("Reprovides with 'flat' strategy", func(t *testing.T) {
78
+ t.Parallel()
79
+
80
+ nodes := initNodes(t, 2, func(n *harness.Node) {
81
+ n.SetIPFSConfig("Reprovider.Strategy", "flat")
82
+ })
83
+ defer nodes.StopDaemons()
84
+
85
+ cid := nodes[0].IPFSAddStr(time.Now().String(), "--local")
86
+
87
+ expectNoProviders(t, cid, nodes[1:]...)
88
+
89
+ nodes[0].IPFS("bitswap", "reprovide")
90
+
91
+ expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...)
92
+ })
93
+
94
+ t.Run("Reprovides with 'pinned' strategy", func(t *testing.T) {
95
+ t.Parallel()
96
+
97
+ foo := testutils.RandomBytes(1000)
98
+ bar := testutils.RandomBytes(1000)
99
+
100
+ nodes := initNodes(t, 2, func(n *harness.Node) {
101
+ n.SetIPFSConfig("Reprovider.Strategy", "pinned")
102
+ })
103
+ defer nodes.StopDaemons()
104
+
105
+ cidFoo := nodes[0].IPFSAdd(bytes.NewReader(foo), "--offline", "--pin=false")
106
+ cidBar := nodes[0].IPFSAdd(bytes.NewReader(bar), "--offline", "--pin=false")
107
+ cidBarDir := nodes[0].IPFSAdd(bytes.NewReader(bar), "-Q", "--offline", "-w")
108
+
109
+ expectNoProviders(t, cidFoo, nodes[1:]...)
110
+ expectNoProviders(t, cidBar, nodes[1:]...)
111
+ expectNoProviders(t, cidBarDir, nodes[1:]...)
112
+
113
+ nodes[0].IPFS("bitswap", "reprovide")
114
+
115
+ expectNoProviders(t, cidFoo, nodes[1:]...)
116
+ expectProviders(t, cidBar, nodes[0].PeerID().String(), nodes[1:]...)
117
+ expectProviders(t, cidBarDir, nodes[0].PeerID().String(), nodes[1:]...)
118
+ })
119
+
120
+ t.Run("Reprovides with 'roots' strategy", func(t *testing.T) {
121
+ t.Parallel()
122
+
123
+ foo := testutils.RandomBytes(1000)
124
+ bar := testutils.RandomBytes(1000)
125
+ baz := testutils.RandomBytes(1000)
126
+
127
+ nodes := initNodes(t, 2, func(n *harness.Node) {
128
+ n.SetIPFSConfig("Reprovider.Strategy", "roots")
129
+ })
130
+ defer nodes.StopDaemons()
131
+
132
+ cidFoo := nodes[0].IPFSAdd(bytes.NewReader(foo), "--offline", "--pin=false")
133
+ cidBar := nodes[0].IPFSAdd(bytes.NewReader(bar), "--offline", "--pin=false")
134
+ cidBaz := nodes[0].IPFSAdd(bytes.NewReader(baz), "--offline")
135
+ cidBarDir := nodes[0].IPFSAdd(bytes.NewReader(bar), "-Q", "--offline", "-w")
136
+
137
+ expectNoProviders(t, cidFoo, nodes[1:]...)
138
+ expectNoProviders(t, cidBar, nodes[1:]...)
139
+ expectNoProviders(t, cidBarDir, nodes[1:]...)
140
+
141
+ nodes[0].IPFS("bitswap", "reprovide")
142
+
143
+ expectNoProviders(t, cidFoo, nodes[1:]...)
144
+ expectNoProviders(t, cidBar, nodes[1:]...)
145
+ expectProviders(t, cidBaz, nodes[0].PeerID().String(), nodes[1:]...)
146
+ expectProviders(t, cidBarDir, nodes[0].PeerID().String(), nodes[1:]...)
147
+ })
148
+
149
+ t.Run("Providing works without ticking", func(t *testing.T) {
150
+ t.Parallel()
151
+
152
+ nodes := initNodes(t, 2, func(n *harness.Node) {
153
+ n.SetIPFSConfig("Reprovider.Interval", "0")
154
+ })
155
+ defer nodes.StopDaemons()
156
+
157
+ cid := nodes[0].IPFSAddStr(time.Now().String(), "--offline")
158
+
159
+ expectNoProviders(t, cid, nodes[1:]...)
160
+
161
+ nodes[0].IPFS("bitswap", "reprovide")
162
+
163
+ expectProviders(t, cid, nodes[0].PeerID().String(), nodes[1:]...)
164
+ })
165
+}
test/dependencies/go.mod
+1
-1
@@ -105,7 +105,7 @@ require (
105
github.com/hexops/gotextdiff v1.0.3 // indirect
106
github.com/inconshreveable/mousetrap v1.1.0 // indirect
107
github.com/ipfs/bbloom v0.0.4 // indirect
108
- github.com/ipfs/boxo v0.18.0 // indirect
108
+ github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d // indirect
109
github.com/ipfs/go-block-format v0.2.0 // indirect
110
github.com/ipfs/go-cid v0.4.1 // indirect
111
github.com/ipfs/go-datastore v0.6.0 // indirect
test/dependencies/go.sum
+2
-2
@@ -362,8 +362,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
362
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
363
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
364
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
365
-github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw=
366
-github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
365
+github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d h1:4y8xHp4ZDUgnwXK3a146K/sEYq6BSO/nA46DOLMVp5k=
366
+github.com/ipfs/boxo v0.18.1-0.20240409062800-ec207931045d/go.mod h1:V5gJzbIMwKEXrg3IdvAxIdF7UPgU4RsXmNGS8MQ/0D4=
367
github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=
368
github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
369
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
test/sharness/t0175-provider.sh
deleted
-34
@@ -1,34 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-test_description="Test reprovider"
4
-
5
-. lib/test-lib.sh
6
-
7
-NUM_NODES=2
8
-
9
-test_expect_success 'init iptb' '
10
- iptb testbed create -type localipfs -force -count $NUM_NODES -init
11
-'
12
-
13
-test_expect_success 'peer ids' '
14
- PEERID_0=$(iptb attr get 0 id) &&
15
- PEERID_1=$(iptb attr get 1 id)
16
-'
17
-
18
-test_expect_success 'use strategic providing' '
19
- iptb run -- ipfs config --json Experimental.StrategicProviding false
20
-'
21
-
22
-startup_cluster ${NUM_NODES}
23
-
24
-test_expect_success 'add test object' '
25
- HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q)
26
-'
27
-
28
-findprovs_expect '$HASH_0' '$PEERID_0'
29
-
30
-test_expect_success 'stop node 1' '
31
- iptb stop
32
-'
33
-
34
-test_done
test/sharness/t0175-reprovider.sh
deleted
-140
@@ -1,140 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-test_description="Test reprovider"
4
-
5
-. lib/test-lib.sh
6
-
7
-NUM_NODES=6
8
-
9
-init_strategy() {
10
- test_expect_success 'init iptb' '
11
- iptb testbed create -type localipfs -force -count $NUM_NODES -init
12
- '
13
-
14
- test_expect_success 'peer ids' '
15
- PEERID_0=$(iptb attr get 0 id) &&
16
- PEERID_1=$(iptb attr get 1 id)
17
- '
18
-
19
- test_expect_success 'use pinning strategy for reprovider' '
20
- ipfsi 0 config Reprovider.Strategy '$1'
21
- '
22
-
23
- startup_cluster ${NUM_NODES}
24
-}
25
-
26
-reprovide() {
27
- test_expect_success 'reprovide' '
28
- # TODO: this hangs, though only after reprovision was done
29
- ipfsi 0 bitswap reprovide
30
- '
31
-}
32
-
33
-# Test 'all' strategy
34
-init_strategy 'all'
35
-
36
-test_expect_success 'add test object' '
37
- HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q --local)
38
-'
39
-
40
-findprovs_empty '$HASH_0'
41
-reprovide
42
-findprovs_expect '$HASH_0' '$PEERID_0'
43
-
44
-test_expect_success 'Stop iptb' '
45
- iptb stop
46
-'
47
-
48
-# Test 'pinned' strategy
49
-init_strategy 'pinned'
50
-
51
-test_expect_success 'prepare test files' '
52
- date +"%FT%T.%N%z" > f1 &&
53
- date +"%FT%T.%N%z" > f2
54
-'
55
-
56
-test_expect_success 'add test objects' '
57
- HASH_FOO=$(ipfsi 0 add -q --offline --pin=false f1) &&
58
- HASH_BAR=$(ipfsi 0 add -q --offline --pin=false f2) &&
59
- HASH_BAR_DIR=$(ipfsi 0 add -q --offline -w f2)
60
-'
61
-
62
-findprovs_empty '$HASH_FOO'
63
-findprovs_empty '$HASH_BAR'
64
-findprovs_empty '$HASH_BAR_DIR'
65
-
66
-reprovide
67
-
68
-findprovs_empty '$HASH_FOO'
69
-findprovs_expect '$HASH_BAR' '$PEERID_0'
70
-findprovs_expect '$HASH_BAR_DIR' '$PEERID_0'
71
-
72
-test_expect_success 'Stop iptb' '
73
- iptb stop
74
-'
75
-
76
-# Test 'roots' strategy
77
-init_strategy 'roots'
78
-
79
-test_expect_success 'prepare test files' '
80
- date +"%FT%T.%N%z" > f1 &&
81
- date +"%FT%T.%N%z" > f2 &&
82
- date +"%FT%T.%N%z" > f3
83
-'
84
-
85
-test_expect_success 'add test objects' '
86
- HASH_FOO=$(ipfsi 0 add -q --offline --pin=false f1) &&
87
- HASH_BAR=$(ipfsi 0 add -q --offline --pin=false f2) &&
88
- HASH_BAZ=$(ipfsi 0 add -q --offline f3) &&
89
- HASH_BAR_DIR=$(ipfsi 0 add -Q --offline -w f2)
90
-'
91
-
92
-findprovs_empty '$HASH_FOO'
93
-findprovs_empty '$HASH_BAR'
94
-findprovs_empty '$HASH_BAR_DIR'
95
-
96
-reprovide
97
-
98
-findprovs_empty '$HASH_FOO'
99
-findprovs_empty '$HASH_BAR'
100
-findprovs_expect '$HASH_BAZ' '$PEERID_0'
101
-findprovs_expect '$HASH_BAR_DIR' '$PEERID_0'
102
-
103
-test_expect_success 'Stop iptb' '
104
- iptb stop
105
-'
106
-
107
-# Test reprovider working with ticking disabled
108
-test_expect_success 'init iptb' '
109
- iptb testbed create -type localipfs -force -count $NUM_NODES -init
110
-'
111
-
112
-test_expect_success 'peer ids' '
113
- PEERID_0=$(iptb attr get 0 id) &&
114
- PEERID_1=$(iptb attr get 1 id)
115
-'
116
-
117
-test_expect_success 'Disable reprovider ticking' '
118
- ipfsi 0 config Reprovider.Interval 0
119
-'
120
-
121
-startup_cluster ${NUM_NODES}
122
-
123
-test_expect_success 'add test object' '
124
- HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q --offline)
125
-'
126
-
127
-findprovs_empty '$HASH_0'
128
-reprovide
129
-findprovs_expect '$HASH_0' '$PEERID_0'
130
-
131
-test_expect_success 'resolve object $HASH_0' '
132
- HASH_WITH_PREFIX=$(ipfsi 1 resolve $HASH_0)
133
-'
134
-findprovs_expect '$HASH_WITH_PREFIX' '$PEERID_0'
135
-
136
-test_expect_success 'Stop iptb' '
137
- iptb stop
138
-'
139
-
140
-test_done
test/sharness/t0175-strategic-provider.sh
deleted
-34
@@ -1,34 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-test_description="Test reprovider"
4
-
5
-. lib/test-lib.sh
6
-
7
-NUM_NODES=2
8
-
9
-test_expect_success 'init iptb' '
10
- iptb testbed create -type localipfs -force -count $NUM_NODES -init
11
-'
12
-
13
-test_expect_success 'peer ids' '
14
- PEERID_0=$(iptb attr get 0 id) &&
15
- PEERID_1=$(iptb attr get 1 id)
16
-'
17
-
18
-test_expect_success 'use strategic providing' '
19
- iptb run -- ipfs config --json Experimental.StrategicProviding true
20
-'
21
-
22
-startup_cluster ${NUM_NODES}
23
-
24
-test_expect_success 'add test object' '
25
- HASH_0=$(date +"%FT%T.%N%z" | ipfsi 0 add -q)
26
-'
27
-
28
-findprovs_empty '$HASH_0'
29
-
30
-test_expect_success 'stop node 1' '
31
- iptb stop
32
-'
33
-
34
-test_done