Skip to content

Commit

Permalink
feat: add sharness test to check key ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jan 3, 2023
1 parent 405f54e commit 2fa1571
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/commands/name/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ipfs/go-ipns"
ipns_pb "github.com/ipfs/go-ipns/pb"
cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"
ic "github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
)

Expand Down Expand Up @@ -114,6 +115,13 @@ var IpnsVerifyRecordCmd = &cmds.Command{
}

pub, err := id.ExtractPublicKey()
if err != nil {
// Make sure it works with all those RSA that cannot be embedded into the
// Peer ID.
if len(entry.PubKey) > 0 {
pub, err = ic.UnmarshalPublicKey(entry.PubKey)
}
}
if err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions test/sharness/t0100-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ test_name_with_self() {
grep "argument \"ipfs-path\" is required" curl_out
'

# test publishing with TTL
test_expect_success "'ipfs name publish --ttl=30m' succeeds" '
ipfs name publish --ttl=30m --allow-offline "/ipfs/$HASH_WELCOME_DOCS" &&
ipfs routing get "/ipns/$PEERID" > ipns_record &&
ipfs name verify-record $PEERID < ipns_record > verify_output &&
test_should_contain "$HASH_WELCOME_DOCS" verify_output
test_should_contain "1800000000000" verify_output
'

test_kill_ipfs_daemon

# Test daemon in offline mode
Expand Down

0 comments on commit 2fa1571

Please sign in to comment.