Skip to content

Commit

Permalink
chore: apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 5, 2023
1 parent c872b4a commit 8206414
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Let us know if you find any issue or if you want to contribute and add a new tut
- [Fetching a UnixFS file by CID](./unixfs-file-cid)
- [Gateway backed by a CAR file](./gateway/car)
- [Gateway backed by a remote blockstore and IPNS resolver](./gateway/proxy)
- [Delegated Routing V1 Command Line Client](./routing-v1/client/)
- [Delegated Routing V1 Command Line Client](./routing/delegated-routing-client/)
10 changes: 8 additions & 2 deletions examples/routing/delegated-routing-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,24 @@ func findIPNS(w io.Writer, ctx context.Context, client *client.Client, nameStr s
return err
}

Check warning on line 126 in examples/routing/delegated-routing-client/main.go

View check run for this annotation

Codecov / codecov/patch

examples/routing/delegated-routing-client/main.go#L125-L126

Added lines #L125 - L126 were not covered by tests

// Ask for a record. [client.GetIPNS] validates the record for us.
// Fetch an IPNS record for the given name. [client.Client.GetIPNS] verifies
// if the retrieved record is valid against the given name, and errors otherwise.
record, err := client.GetIPNS(ctx, name)
if err != nil {
return err
}

Check warning on line 133 in examples/routing/delegated-routing-client/main.go

View check run for this annotation

Codecov / codecov/patch

examples/routing/delegated-routing-client/main.go#L132-L133

Added lines #L132 - L133 were not covered by tests

fmt.Fprintf(w, "/ipns/%s\n", name)
v, err := record.Value()
if err != nil {
return err
}

Check warning on line 139 in examples/routing/delegated-routing-client/main.go

View check run for this annotation

Codecov / codecov/patch

examples/routing/delegated-routing-client/main.go#L138-L139

Added lines #L138 - L139 were not covered by tests

fmt.Fprintf(w, "/ipns/%s\n", name)
// Since [client.Client.GetIPNS] verifies if the retrieved record is valid, we
// do not need to verify it again. However, if you were not using this specific
// client, but using some other tool, you should always validate the IPNS Record
// using the [ipns.Validate] or [ipns.ValidateWithName] functions.
fmt.Fprintln(w, "\tSignature: VALID")
fmt.Fprintln(w, "\tValue:", v.String())
return nil
}
2 changes: 1 addition & 1 deletion examples/routing/delegated-routing-client/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestGetIPNS(t *testing.T) {

out := &bytes.Buffer{}
err := run(out, ts.URL, "", "", name.String(), 1)
assert.Contains(t, out.String(), fmt.Sprintf("/ipns/%s\n\tValue: /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4\n", name.String()))
assert.Contains(t, out.String(), fmt.Sprintf("/ipns/%s\n\tSignature: VALID\n\tValue: /ipfs/bafkreifjjcie6lypi6ny7amxnfftagclbuxndqonfipmb64f2km2devei4\n", name.String()))
assert.NoError(t, err)
}

Expand Down

0 comments on commit 8206414

Please sign in to comment.