1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +08:00

update tests, and ensure 'default' blocks are pinned

This commit is contained in:
Jeromy
2015-01-22 00:16:30 +00:00
parent 8e7d984751
commit 1244fd251d
3 changed files with 37 additions and 9 deletions

View File

@ -42,6 +42,16 @@ func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error {
return err
}
err = n.Pinning.Pin(emptyDir, false)
if err != nil {
return err
}
err = n.Pinning.Flush()
if err != nil {
return err
}
pub := nsys.NewRoutingPublisher(n.Routing)
err = pub.Publish(key, k.B58String())
if err != nil {

View File

@ -200,6 +200,10 @@ func BuildDagFromReader(r io.Reader, ds dag.DAGService, mp pin.ManualPinner, spl
if mp != nil {
mp.PinWithMode(rootkey, pin.Recursive)
err := mp.Flush()
if err != nil {
return nil, err
}
}
return root.getDagNode()

View File

@ -21,10 +21,16 @@ test_expect_success "added file was pinned" '
ipfs pin ls -type=recursive | grep $HASH
'
test_expect_success "'ipfs repo gc' doesnt remove file" '
echo -n "" > empty
test_expect_success "'ipfs repo gc' succeeds" '
ipfs repo gc > gc_out_actual
'
test_expect_success "'ipfs repo gc' looks good (empty)" '
echo -n "" > empty
test_cmp empty gc_out_actual
'
test_expect_success "'ipfs repo gc' doesnt remove file" '
ipfs cat $HASH > out
test_cmp out afile
'
@ -36,8 +42,10 @@ test_expect_success "'ipfs pin rm' succeeds" '
'
test_expect_success "file no longer pinned" '
# we expect the welcome file to show up here
echo QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB > expected2
ipfs pin ls -type=recursive > actual2
test_cmp empty actual2
test_cmp expected2 actual2
'
test_expect_success "recursively pin afile" '
@ -76,8 +84,10 @@ test_expect_success "'ipfs repo gc' removes file" '
'
test_expect_success "'ipfs refs local' no longer shows file" '
echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn > expected8
echo QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB >> expected8
ipfs refs local > actual8
test_cmp empty actual8
test_cmp expected8 actual8
'
test_expect_success "adding multiblock random file succeeds" '
@ -104,15 +114,19 @@ test_expect_success "pin something directly" '
'
test_expect_success "'ipfs pin ls -type=direct' is correct" '
echo $DIRECTPIN > directpinhash
ipfs pin ls -type=direct > directpinout
test_cmp directpinhash directpinout
echo $DIRECTPIN > directpinexpected
echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >> directpinexpected
cat directpinexpected | sort > dp_exp_sorted
ipfs pin ls -type=direct | sort > directpinout
test_cmp dp_exp_sorted directpinout
'
test_expect_success "'ipfs pin ls -type=recursive' is correct" '
echo $MBLOCKHASH > rp_expected
ipfs pin ls -type=recursive > rp_actual
test_cmp rp_expected rp_actual
echo QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB >> rp_expected
cat rp_expected | sort > rp_exp_sorted
ipfs pin ls -type=recursive | sort > rp_actual
test_cmp rp_exp_sorted rp_actual
'
test_expect_success "'ipfs pin ls -type=all' is correct" '