From 755191eb47883cf8f44c4921358e46f9e91ebf32 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 11 May 2021 15:27:54 -0400 Subject: [PATCH] chore: update dep This commit was moved from ipfs/go-namesys@8af847d76a2e4ab2a1283889ee02d5f898ae3981 --- namesys/ipns_resolver_validation_test.go | 8 ++++---- namesys/publisher.go | 13 +++++-------- namesys/publisher_test.go | 2 +- namesys/resolve_test.go | 4 ++-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/namesys/ipns_resolver_validation_test.go b/namesys/ipns_resolver_validation_test.go index 5dbfabf9c..d896b9e0d 100644 --- a/namesys/ipns_resolver_validation_test.go +++ b/namesys/ipns_resolver_validation_test.go @@ -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) } @@ -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) } @@ -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 } diff --git a/namesys/publisher.go b/namesys/publisher.go index edf57375a..f67a8bf52 100644 --- a/namesys/publisher.go +++ b/namesys/publisher.go @@ -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 diff --git a/namesys/publisher_test.go b/namesys/publisher_test.go index afc9efcc2..844ed86ed 100644 --- a/namesys/publisher_test.go +++ b/namesys/publisher_test.go @@ -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) } diff --git a/namesys/resolve_test.go b/namesys/resolve_test.go index f8b243669..b654936c4 100644 --- a/namesys/resolve_test.go +++ b/namesys/resolve_test.go @@ -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) } @@ -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) }