Skip to content

Commit

Permalink
fix tests + go mod
Browse files Browse the repository at this point in the history
  • Loading branch information
petar committed Jul 24, 2020
1 parent 063a8bb commit 9c72c65
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 41 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module github.com/ipfs/go-ipfs

// replace github.com/ipfs/interface-go-ipfs-core => /Users/petar/src/github.com/ipfs/interface-go-ipfs-core

require (
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
Expand Down
88 changes: 49 additions & 39 deletions test/sharness/t0100-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ test_name_with_self() {
test_expect_success "ipfs init (variant self $SELF_ALG)" '
export IPFS_PATH="$(pwd)/.ipfs" &&
case $SELF_ALG in
default)
ipfs init --profile=test > /dev/null
;;
rsa)
ipfs init --profile=test -a=rsa > /dev/null
;;
Expand Down Expand Up @@ -48,10 +51,10 @@ test_name_with_self() {
# test publishing with -Q option

test_expect_success "'ipfs name publish --quieter' succeeds" '
ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out
ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out
'

test_expect_success "pubrmlish --quieter output looks good" '
test_expect_success "publish --quieter output looks good" '
echo "${PEERID}" >expected1 &&
test_cmp expected1 publish_out
'
Expand Down Expand Up @@ -103,7 +106,37 @@ test_name_with_self() {
test_cmp expected_node_id_publish actual_node_id_publish
'

# test publishing with B36CID and B58MH resolve to the same B36CID

test_expect_success "generate and verify a new key" '
B58MH_ID=`ipfs key list -f=b58mh -l | grep self | cut -d " " -f1` &&
B36CID_ID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
test_check_peerid "${B58MH_ID}" &&
test_check_peerid "${B36CID_ID}"
'

test_expect_success "'ipfs name publish --allow-offline --key=<peer-id> <hash>' succeeds" '
ipfs name publish --allow-offline --key=${B58MH_ID} "/ipfs/$HASH_WELCOME_DOCS" >b58mh_published_id &&
ipfs name publish --allow-offline --key=${B36CID_ID} "/ipfs/$HASH_WELCOME_DOCS" >b36cid_published_id
'

test_expect_success "publish an explicit node ID as two key in B58MH and B36CID, name looks good" '
echo "Published to ${B36CID_ID}: /ipfs/$HASH_WELCOME_DOCS" >expected_published_id &&
test_cmp expected_published_id b58mh_published_id &&
test_cmp expected_published_id b36cid_published_id
'

test_expect_success "'ipfs name resolve' succeeds" '
ipfs name resolve "$B36CID_ID" >output
'

test_expect_success "resolve output looks good" '
printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 &&
test_cmp expected2 output
'

# test IPNS + IPLD

test_expect_success "'ipfs dag put' succeeds" '
HELLO_HASH="$(echo "\"hello world\"" | ipfs dag put)" &&
OBJECT_HASH="$(echo "{\"thing\": {\"/\": \"${HELLO_HASH}\" }}" | ipfs dag put)"
Expand All @@ -120,7 +153,7 @@ test_name_with_self() {
test_expect_success "'ipfs name resolve' succeeds" '
ipfs name resolve "$PEERID" >output
'
test_expect_success "resolve output looks good" '
test_expect_success "resolve output looks good (IPNS + IPLD)" '
printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 &&
test_cmp expected4 output
'
Expand Down Expand Up @@ -152,15 +185,15 @@ test_name_with_self() {
test_expect_success "'ipfs name resolve --offline' succeeds" '
ipfs name resolve --offline "$PEERID" >output
'
test_expect_success "resolve output looks good" '
test_expect_success "resolve output looks good (offline resolve)" '
printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 &&
test_cmp expected4 output
'

test_expect_success "'ipfs name resolve --offline -n' succeeds" '
ipfs name resolve --offline -n "$PEERID" >output
'
test_expect_success "resolve output looks good" '
test_expect_success "resolve output looks good (offline resolve, -n)" '
printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 &&
test_cmp expected4 output
'
Expand All @@ -170,15 +203,15 @@ test_name_with_self() {
test_expect_success "'ipfs name resolve --offline' succeeds" '
ipfs name resolve --offline "$PEERID" >output
'
test_expect_success "resolve output looks good" '
test_expect_success "resolve output looks good (with daemon)" '
printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 &&
test_cmp expected4 output
'

test_expect_success "'ipfs name resolve --offline -n' succeeds" '
ipfs name resolve --offline -n "$PEERID" >output
'
test_expect_success "resolve output looks good" '
test_expect_success "resolve output looks good (with daemon, -n)" '
printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 &&
test_cmp expected4 output
'
Expand All @@ -203,6 +236,7 @@ test_name_with_self() {
rm -rf "$IPFS_PATH"
'
}
test_name_with_self 'default'
test_name_with_self 'rsa'
test_name_with_self 'ed25519'

Expand All @@ -220,46 +254,21 @@ test_name_with_key() {
export KEY=`ipfs key gen -f=b58mh --type=rsa --size=2048 key` &&
export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
;;
ed25519)
ed25519_b58)
export KEY=`ipfs key gen -f=b58mh --type=ed25519 key`
export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
;;
ed25519_b36)
export KEY=`ipfs key gen -f=b36cid --type=ed25519 key`
export KEY_B36CID=$KEY
;;
esac &&
test_check_peerid "${KEY}"
'

# test publishing with B36CID and B58MH resolve to the same B36CID

test_expect_success "generate and verify a new key" '
B58MH_ID=`ipfs key list -f=b58mh -l | grep self | cut -d " " -f1` &&
B36CID_ID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
test_check_peerid "${B58MH_ID}" &&
test_check_peerid "${B36CID_ID}"
'

test_expect_success "'ipfs name publis --allow-offline --key=<peer-id> <hash>' succeeds" '
ipfs name publish --allow-offline --key=${B58MH_ID} "/ipfs/$HASH_WELCOME_DOCS" >b58mh_published_id &&
ipfs name publish --allow-offline --key=${B36CID_ID} "/ipfs/$HASH_WELCOME_DOCS" >b36cid_published_id
'

test_expect_success "publish an explicit node ID as two key in B58MH and B36CID, name looks good" '
echo "Published to ${B36CID_ID}: /ipfs/$HASH_WELCOME_DOCS" >expected_published_id &&
test_cmp expected_published_id b58mh_published_id &&
test_cmp expected_published_id b36cid_published_id
'

test_expect_success "'ipfs name resolve' succeeds" '
ipfs name resolve "$B36CID_ID" >output
'

test_expect_success "resolve output looks good" '
printf "/ipfs/%s\n" "$HASH_WELCOME_DOCS" >expected2 &&
test_cmp expected2 output
'

# publish with an explicit node ID as key name

test_expect_success "'ipfs name publis --allow-offline --key=<peer-id> <hash>' succeeds" '
test_expect_success "'ipfs name publish --allow-offline --key=<peer-id> <hash>' succeeds" '
ipfs name publish --allow-offline --key=${KEY} "/ipfs/$HASH_WELCOME_DOCS" >actual_node_id_publish
'

Expand All @@ -274,6 +283,7 @@ test_name_with_key() {
'
}
test_name_with_key 'rsa'
test_name_with_key 'ed25519'
test_name_with_key 'ed25519_b58'
test_name_with_key 'ed25519_b36'

test_done

0 comments on commit 9c72c65

Please sign in to comment.