Skip to content

Commit a6f446a

Browse files
authored
test: deterministic ipns fixtures during sharness gateway tests (#9667)
1 parent f606b97 commit a6f446a

23 files changed

+225
-102
lines changed

core/commands/routing.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010

1111
cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"
1212

13+
iface "github.com/ipfs/boxo/coreiface"
14+
"github.com/ipfs/boxo/coreiface/options"
1315
dag "github.com/ipfs/boxo/ipld/merkledag"
1416
path "github.com/ipfs/boxo/path"
1517
cid "github.com/ipfs/go-cid"
@@ -19,6 +21,16 @@ import (
1921
routing "github.com/libp2p/go-libp2p/core/routing"
2022
)
2123

24+
var (
25+
errAllowOffline = errors.New("can't put while offline: pass `--allow-offline` to override")
26+
)
27+
28+
const (
29+
dhtVerboseOptionName = "verbose"
30+
numProvidersOptionName = "num-providers"
31+
allowOfflineOptionName = "allow-offline"
32+
)
33+
2234
var RoutingCmd = &cmds.Command{
2335
Helptext: cmds.HelpText{
2436
Tagline: "Issue routing commands.",
@@ -34,14 +46,6 @@ var RoutingCmd = &cmds.Command{
3446
},
3547
}
3648

37-
const (
38-
dhtVerboseOptionName = "verbose"
39-
)
40-
41-
const (
42-
numProvidersOptionName = "num-providers"
43-
)
44-
4549
var findProvidersRoutingCmd = &cmds.Command{
4650
Helptext: cmds.HelpText{
4751
Tagline: "Find peers that can provide a specific value, given a key.",
@@ -420,6 +424,9 @@ identified by QmFoo.
420424
cmds.StringArg("key", true, false, "The key to store the value at."),
421425
cmds.FileArg("value-file", true, false, "A path to a file containing the value to store.").EnableStdin(),
422426
},
427+
Options: []cmds.Option{
428+
cmds.BoolOption(allowOfflineOptionName, "When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing."),
429+
},
423430
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
424431
api, err := cmdenv.GetApi(env, req)
425432
if err != nil {
@@ -437,13 +444,22 @@ identified by QmFoo.
437444
return err
438445
}
439446

440-
err = api.Routing().Put(req.Context, req.Arguments[0], data)
447+
allowOffline, _ := req.Options[allowOfflineOptionName].(bool)
448+
449+
opts := []options.RoutingPutOption{
450+
options.Put.AllowOffline(allowOffline),
451+
}
452+
453+
err = api.Routing().Put(req.Context, req.Arguments[0], data, opts...)
441454
if err != nil {
442455
return err
443456
}
444457

445458
id, err := api.Key().Self(req.Context)
446459
if err != nil {
460+
if err == iface.ErrOffline {
461+
err = errAllowOffline
462+
}
447463
return err
448464
}
449465

core/coreapi/routing.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66

77
coreiface "github.com/ipfs/boxo/coreiface"
8+
caopts "github.com/ipfs/boxo/coreiface/options"
89
"github.com/ipfs/boxo/path"
910
peer "github.com/libp2p/go-libp2p/core/peer"
1011
)
@@ -24,9 +25,15 @@ func (r *RoutingAPI) Get(ctx context.Context, key string) ([]byte, error) {
2425
return r.routing.GetValue(ctx, dhtKey)
2526
}
2627

27-
func (r *RoutingAPI) Put(ctx context.Context, key string, value []byte) error {
28-
if !r.nd.IsOnline {
29-
return coreiface.ErrOffline
28+
func (r *RoutingAPI) Put(ctx context.Context, key string, value []byte, opts ...caopts.RoutingPutOption) error {
29+
options, err := caopts.RoutingPutOptions(opts...)
30+
if err != nil {
31+
return err
32+
}
33+
34+
err = r.checkOnline(options.AllowOffline)
35+
if err != nil {
36+
return err
3037
}
3138

3239
dhtKey, err := normalizeKey(key)

core/coreapi/test/api_test.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const testPeerID = "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe"
3131

3232
type NodeProvider struct{}
3333

34-
func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) ([]coreiface.CoreAPI, error) {
34+
func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, online bool, n int) ([]coreiface.CoreAPI, error) {
3535
mn := mocknet.New()
3636

3737
nodes := make([]*core.IpfsNode, n)
@@ -82,7 +82,7 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
8282
Routing: libp2p.DHTServerOption,
8383
Repo: r,
8484
Host: mock.MockHostOption(mn),
85-
Online: fullIdentity,
85+
Online: online,
8686
ExtraOpts: map[string]bool{
8787
"pubsub": true,
8888
},
@@ -102,15 +102,17 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
102102
return nil, err
103103
}
104104

105-
bsinf := bootstrap.BootstrapConfigWithPeers(
106-
[]peer.AddrInfo{
107-
nodes[0].Peerstore.PeerInfo(nodes[0].Identity),
108-
},
109-
)
105+
if online {
106+
bsinf := bootstrap.BootstrapConfigWithPeers(
107+
[]peer.AddrInfo{
108+
nodes[0].Peerstore.PeerInfo(nodes[0].Identity),
109+
},
110+
)
110111

111-
for _, n := range nodes[1:] {
112-
if err := n.Bootstrap(bsinf); err != nil {
113-
return nil, err
112+
for _, n := range nodes[1:] {
113+
if err := n.Bootstrap(bsinf); err != nil {
114+
return nil, err
115+
}
114116
}
115117
}
116118

core/coreapi/test/path_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestPathUnixFSHAMTPartial(t *testing.T) {
1919
defer cancel()
2020

2121
// Create a node
22-
apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, 1)
22+
apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, true, 1)
2323
if err != nil {
2424
t.Fatal(err)
2525
}

docs/examples/kubo-as-a-library/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go 1.18
77
replace github.com/ipfs/kubo => ./../../..
88

99
require (
10-
github.com/ipfs/boxo v0.8.1
10+
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866
1111
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
1212
github.com/libp2p/go-libp2p v0.27.1
1313
github.com/multiformats/go-multiaddr v0.9.0

docs/examples/kubo-as-a-library/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
321321
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
322322
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
323323
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
324-
github.com/ipfs/boxo v0.8.1 h1:3DkKBCK+3rdEB5t77WDShUXXhktYwH99mkAsgajsKrU=
325-
github.com/ipfs/boxo v0.8.1/go.mod h1:xJ2hVb4La5WyD7GvKYE0lq2g1rmQZoCD2K4WNrV6aZI=
324+
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 h1:ThRTXD/EyoLb/jz+YW+ZlOLbjX9FyaxP0dEpgUp3cCE=
325+
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866/go.mod h1:bORAHrH6hUtDZjbzTEaLrSpTdyhHKDIpjDRT+A14B7w=
326326
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
327327
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
328328
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/gogo/protobuf v1.3.2
1717
github.com/google/uuid v1.3.0
1818
github.com/hashicorp/go-multierror v1.1.1
19-
github.com/ipfs/boxo v0.8.1
19+
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866
2020
github.com/ipfs/go-block-format v0.1.2
2121
github.com/ipfs/go-cid v0.4.1
2222
github.com/ipfs/go-cidutil v0.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
356356
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
357357
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
358358
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
359-
github.com/ipfs/boxo v0.8.1 h1:3DkKBCK+3rdEB5t77WDShUXXhktYwH99mkAsgajsKrU=
360-
github.com/ipfs/boxo v0.8.1/go.mod h1:xJ2hVb4La5WyD7GvKYE0lq2g1rmQZoCD2K4WNrV6aZI=
359+
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 h1:ThRTXD/EyoLb/jz+YW+ZlOLbjX9FyaxP0dEpgUp3cCE=
360+
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866/go.mod h1:bORAHrH6hUtDZjbzTEaLrSpTdyhHKDIpjDRT+A14B7w=
361361
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
362362
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
363363
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=

test/sharness/t0114-gateway-subdomains.sh

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -93,40 +93,29 @@ test_launch_ipfs_daemon_without_network
9393

9494
# Import test case
9595
# See the static fixtures in ./t0114-gateway-subdomains/
96-
test_expect_success "Add the test fixtures" '
97-
ipfs dag import ../t0114-gateway-subdomains/fixtures.car
98-
'
99-
CID_VAL="hello"
96+
CID_VAL=hello
10097
CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
10198
CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
102-
# CIDv0to1 is necessary because raw-leaves are enabled by default during
103-
# "ipfs add" with CIDv1 and disabled with CIDv0
10499
CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4
105100
CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs
106-
DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting
107-
108-
test_expect_success "Publish test text file to IPNS using RSA keys" '
109-
RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n")
110-
RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0)
111-
RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --mc libp2p-key -b base36)
112-
RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36)
113-
test_check_peerid "${RSA_KEY}" &&
114-
ipfs name publish --key test_key_rsa --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out &&
115-
ipfs name resolve "$RSA_KEY" > output &&
116-
printf "/ipfs/%s\n" "$CIDv1" > expected2 &&
117-
test_cmp expected2 output
118-
'
101+
DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe
102+
103+
RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
104+
RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
105+
RSA_IPNS_IDv1=k2k4r8m7xvggw5pxxk3abrkwyer625hg01hfyggrai7lk1m63fuihi7w
106+
RSA_IPNS_IDv1_DAGPB=k2jmtxu61bnhrtj301lw7zizknztocdbeqhxgv76l2q9t36fn9jbzipo
119107

120-
test_expect_success "Publish test text file to IPNS using ED25519 keys" '
121-
ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n")
122-
ED25519_IPNS_IDv0=$ED25519_KEY
123-
ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=base36 | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n")
124-
ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --mc dag-pb)
125-
test_check_peerid "${ED25519_KEY}" &&
126-
ipfs name publish --key test_key_ed25519 --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out &&
127-
ipfs name resolve "$ED25519_KEY" > output &&
128-
printf "/ipfs/%s\n" "$CIDv1" > expected2 &&
129-
test_cmp expected2 output
108+
ED25519_KEY=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
109+
ED25519_IPNS_IDv0=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
110+
ED25519_IPNS_IDv1=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
111+
ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jey4fqg6wafvqprktgbkpgkqdg27tpqje6iimzxewnhvtin9hhq
112+
IPNS_ED25519_B58MH=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
113+
IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
114+
115+
test_expect_success "Add the test fixtures" '
116+
ipfs dag import ../t0114-gateway-subdomains/fixtures.car &&
117+
ipfs routing put --allow-offline /ipns/${RSA_KEY} ../t0114-gateway-subdomains/${RSA_KEY}.ipns-record &&
118+
ipfs routing put --allow-offline /ipns/${ED25519_KEY} ../t0114-gateway-subdomains/${ED25519_KEY}.ipns-record
130119
'
131120

132121
# ensure we start with empty Gateway.PublicGateways
@@ -588,11 +577,6 @@ test_expect_success \
588577
## https://github.com/ipfs/go-ipfs/issues/7318
589578
## ============================================================================
590579

591-
# ed25519 fits under 63 char limit when represented in base36
592-
IPNS_KEY="test_key_ed25519"
593-
IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n")
594-
IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n")
595-
596580
# local: *.localhost
597581
test_localhost_gateway_response_should_contain \
598582
"request for a ED25519 libp2p-key at localhost/ipns/{b58mh} returns Location HTTP header for DNS-safe subdomain redirect in browsers" \

test/sharness/t0114-gateway-subdomains/README.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
- fixtures.car
44
- raw CARv1
55

6-
generated with:
6+
- QmUKd....ipns-record
7+
- ipns record, encoded with protocol buffer
8+
9+
- 12D3K....ipns-record
10+
- ipns record, encoded with protocol buffer
11+
12+
Generated with:
713

814
```sh
9-
# using ipfs version 0.18.1
15+
# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
1016

1117
# CIDv0to1 is necessary because raw-leaves are enabled by default during
1218
# "ipfs add" with CIDv1 and disabled with CIDv0
@@ -17,6 +23,7 @@ CIDv0to1=$(echo "$CIDv0" | ipfs cid base32)
1723
# sha512 will be over 63char limit, even when represented in Base36
1824
CIDv1_TOO_LONG=$(echo $CID_VAL | ipfs add --cid-version 1 --hash sha2-512 -Q)
1925

26+
echo CID_VAL=${CID_VAL}
2027
echo CIDv1=${CIDv1}
2128
echo CIDv0=${CIDv0}
2229
echo CIDv0to1=${CIDv0to1}
@@ -32,7 +39,7 @@ echo "I am a txt file" > testdirlisting/api/file.txt &&
3239
echo "I am a txt file" > testdirlisting/ipfs/file.txt &&
3340
DIR_CID=$(ipfs add -Qr --cid-version 1 testdirlisting)
3441

35-
echo DIR_CID=${DIR_CID}
42+
echo DIR_CID=${DIR_CID} # ./testdirlisting
3643

3744
ipfs files mkdir /t0114/
3845
ipfs files cp /ipfs/${CIDv1} /t0114/
@@ -45,10 +52,60 @@ ROOT=`ipfs files stat /t0114/ --hash`
4552

4653
ipfs dag export ${ROOT} > ./fixtures.car
4754

48-
# CID_VAL="hello"
55+
# Then the keys
56+
57+
KEY_NAME=test_key_rsa_$RANDOM
58+
RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 ${KEY_NAME} | head -n1 | tr -d "\n")
59+
RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0)
60+
RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --mc libp2p-key -b base36)
61+
RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36)
62+
63+
# publish a record valid for a 100 years
64+
ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$CIDv1"
65+
ipfs routing get /ipns/${RSA_KEY} > ${RSA_KEY}.ipns-record
66+
67+
echo RSA_KEY=${RSA_KEY}
68+
echo RSA_IPNS_IDv0=${RSA_IPNS_IDv0}
69+
echo RSA_IPNS_IDv1=${RSA_IPNS_IDv1}
70+
echo RSA_IPNS_IDv1_DAGPB=${RSA_IPNS_IDv1_DAGPB}
71+
72+
KEY_NAME=test_key_ed25519_$RANDOM
73+
ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 ${KEY_NAME} | head -n1 | tr -d "\n")
74+
ED25519_IPNS_IDv0=$ED25519_KEY
75+
ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=base36 | grep ${KEY_NAME} | cut -d " " -f1 | tr -d "\n")
76+
ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --mc dag-pb)
77+
78+
# ed25519 fits under 63 char limit when represented in base36
79+
IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $KEY_NAME | cut -d" " -f1 | tr -d "\n")
80+
IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $KEY_NAME | cut -d" " -f1 | tr -d "\n")
81+
82+
# publish a record valid for a 100 years
83+
ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$CIDv1"
84+
ipfs routing get /ipns/${ED25519_KEY} > ${ED25519_KEY}.ipns-record
85+
86+
echo ED25519_KEY=${ED25519_KEY}
87+
echo ED25519_IPNS_IDv0=${ED25519_IPNS_IDv0}
88+
echo ED25519_IPNS_IDv1=${ED25519_IPNS_IDv1}
89+
echo ED25519_IPNS_IDv1_DAGPB=${ED25519_IPNS_IDv1_DAGPB}
90+
echo IPNS_ED25519_B58MH=${IPNS_ED25519_B58MH}
91+
echo IPNS_ED25519_B36CID=${IPNS_ED25519_B36CID}
92+
93+
# CID_VAL=hello
4994
# CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
5095
# CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
5196
# CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4
5297
# CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs
5398
# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting
99+
100+
# RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
101+
# RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
102+
# RSA_IPNS_IDv1=k2k4r8m7xvggw5pxxk3abrkwyer625hg01hfyggrai7lk1m63fuihi7w
103+
# RSA_IPNS_IDv1_DAGPB=k2jmtxu61bnhrtj301lw7zizknztocdbeqhxgv76l2q9t36fn9jbzipo
104+
105+
# ED25519_KEY=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
106+
# ED25519_IPNS_IDv0=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
107+
# ED25519_IPNS_IDv1=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
108+
# ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jey4fqg6wafvqprktgbkpgkqdg27tpqje6iimzxewnhvtin9hhq
109+
# IPNS_ED25519_B58MH=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
110+
# IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
54111
```

test/sharness/t0116-gateway-cache.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,18 @@ test_launch_ipfs_daemon_without_network
2525
# Caching of things like raw blocks, CARs, dag-json and dag-cbor
2626
# is tested in their respective suites.
2727

28-
# Import test case
29-
# See the static fixtures in ./t0116-gateway-cache/
30-
test_expect_success "Add the test directory" '
31-
ipfs dag import ../t0116-gateway-cache/fixtures.car
32-
'
3328
ROOT1_CID=bafybeib3ffl2teiqdncv3mkz4r23b5ctrwkzrrhctdbne6iboayxuxk5ui # ./
3429
ROOT2_CID=bafybeih2w7hjocxjg6g2ku25hvmd53zj7og4txpby3vsusfefw5rrg5sii # ./root2
3530
ROOT3_CID=bafybeiawdvhmjcz65x5egzx4iukxc72hg4woks6v6fvgyupiyt3oczk5ja # ./root2/root3
3631
ROOT4_CID=bafybeifq2rzpqnqrsdupncmkmhs3ckxxjhuvdcbvydkgvch3ms24k5lo7q # ./root2/root3/root4
3732
FILE_CID=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # ./root2/root3/root4/index.html
33+
TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe
3834

39-
test_expect_success "Prepare IPNS unixfs content path for testing" '
40-
TEST_IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 cache_test_key | head -n1 | tr -d "\n")
41-
ipfs name publish --key cache_test_key --allow-offline -Q "/ipfs/$ROOT1_CID" > name_publish_out &&
42-
test_check_peerid "${TEST_IPNS_ID}" &&
43-
ipfs name resolve "${TEST_IPNS_ID}" > output &&
44-
printf "/ipfs/%s\n" "$ROOT1_CID" > expected &&
45-
test_cmp expected output
35+
# Import test case
36+
# See the static fixtures in ./t0116-gateway-cache/
37+
test_expect_success "Add the test directory" '
38+
ipfs dag import ../t0116-gateway-cache/fixtures.car
39+
ipfs routing put --allow-offline /ipns/${TEST_IPNS_ID} ../t0116-gateway-cache/${TEST_IPNS_ID}.ipns-record
4640
'
4741

4842
# GET /ipfs/

0 commit comments

Comments
 (0)