Skip to content

Commit

Permalink
Merge pull request ipfs/go-namesys#16 from ipfs/chore/update-dep
Browse files Browse the repository at this point in the history
chore: update dep

This commit was moved from ipfs/go-namesys@ab417f4
  • Loading branch information
aschmahmann authored May 12, 2021
2 parents 6867c9d + 755191e commit 1853d45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions namesys/ipns_resolver_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testResolverValidation(t *testing.T, keyType int) {
priv, id, _, ipnsDHTPath := genKeys(t, keyType)
ts := time.Now()
p := []byte("/ipfs/QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG")
entry, err := createIPNSRecordWithEmbeddedPublicKey(priv, p, 1, ts.Add(time.Hour))
entry, err := createIPNSRecordWithEmbeddedPublicKey(priv, p, 1, ts.Add(time.Hour), 0)
if err != nil {
t.Fatal(err)
}
Expand All @@ -77,7 +77,7 @@ func testResolverValidation(t *testing.T, keyType int) {
t.Fatalf("Mismatch between published path %s and resolved path %s", p, resp)
}
// Create expired entry
expiredEntry, err := createIPNSRecordWithEmbeddedPublicKey(priv, p, 1, ts.Add(-1*time.Hour))
expiredEntry, err := createIPNSRecordWithEmbeddedPublicKey(priv, p, 1, ts.Add(-1*time.Hour), 0)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -146,8 +146,8 @@ func genKeys(t *testing.T, keyType int) (ci.PrivKey, peer.ID, string, string) {
return sk, id, PkKeyForID(id), ipns.RecordKey(id)
}

func createIPNSRecordWithEmbeddedPublicKey(sk ci.PrivKey, val []byte, seq uint64, eol time.Time) (*ipns_pb.IpnsEntry, error) {
entry, err := ipns.Create(sk, val, seq, eol)
func createIPNSRecordWithEmbeddedPublicKey(sk ci.PrivKey, val []byte, seq uint64, eol time.Time, ttl time.Duration) (*ipns_pb.IpnsEntry, error) {
entry, err := ipns.Create(sk, val, seq, eol, ttl)
if err != nil {
return nil, err
}
Expand Down
13 changes: 5 additions & 8 deletions namesys/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,16 @@ func (p *IpnsPublisher) updateRecord(ctx context.Context, k ci.PrivKey, value pa
seqno++
}

// Set the TTL
// TODO: Make this less hacky.
ttl, _ := checkCtxTTL(ctx)

// Create record
entry, err := ipns.Create(k, []byte(value), seqno, eol)
entry, err := ipns.Create(k, []byte(value), seqno, eol, ttl)
if err != nil {
return nil, err
}

// Set the TTL
// TODO: Make this less hacky.
ttl, ok := checkCtxTTL(ctx)
if ok {
entry.Ttl = proto.Uint64(uint64(ttl.Nanoseconds()))
}

data, err := proto.Marshal(entry)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion namesys/publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func testNamekeyPublisher(t *testing.T, keyType int, expectedErr error, expected
serv := mockrouting.NewServer()
r := serv.ClientWithDatastore(context.Background(), &identity{p}, dstore)

entry, err := ipns.Create(privKey, value, seqnum, eol)
entry, err := ipns.Create(privKey, value, seqnum, eol, 0)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions namesys/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestPrexistingExpiredRecord(t *testing.T) {
h := path.FromString("/ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN")
eol := time.Now().Add(time.Hour * -1)

entry, err := ipns.Create(identity.PrivateKey(), []byte(h), 0, eol)
entry, err := ipns.Create(identity.PrivateKey(), []byte(h), 0, eol, 0)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestPrexistingRecord(t *testing.T) {
// Make a good record and put it in the datastore
h := path.FromString("/ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN")
eol := time.Now().Add(time.Hour)
entry, err := ipns.Create(identity.PrivateKey(), []byte(h), 0, eol)
entry, err := ipns.Create(identity.PrivateKey(), []byte(h), 0, eol, 0)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 1853d45

Please sign in to comment.