Skip to content

Commit

Permalink
chore: feedback review and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jun 20, 2023
1 parent 49112b6 commit 29f81e0
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 24 deletions.
26 changes: 13 additions & 13 deletions core/commands/name/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ type IpnsInspectEntry struct {
}

type IpnsInspectResult struct {
Entry IpnsInspectEntry
Version string
HexDump string
Validation *IpnsInspectValidation
Entry IpnsInspectEntry
SignatureType string
HexDump string
Validation *IpnsInspectValidation
}

var IpnsInspectCmd = &cmds.Command{
Expand Down Expand Up @@ -181,16 +181,12 @@ Passing --verify will verify signature against provided public key.
if err != nil {
return err
}
if pbRecord.SignatureV1 != nil || pbRecord.Value != nil {
if pbRecord.Data != nil {
result.Version = "V1+V2"
} else {
result.Version = "V2"
}
if len(pbRecord.SignatureV1) != 0 || len(pbRecord.Value) != 0 {
result.SignatureType = "V1+V2"
} else if pbRecord.Data != nil {
result.Version = "V2"
result.SignatureType = "V2"
} else {
result.Version = "Unknown"
result.SignatureType = "Unknown"
}

if verify, ok := req.Options["verify"].(string); ok {
Expand Down Expand Up @@ -232,7 +228,7 @@ Passing --verify will verify signature against provided public key.
}

if out.Entry.Validity != nil {
fmt.Fprintf(tw, "Validity:\t%q\n", out.Entry.Validity.Format(time.RFC3339))
fmt.Fprintf(tw, "Validity:\t%q\n", out.Entry.Validity.Format(time.RFC3339Nano))
}

if out.Entry.Sequence != nil {
Expand All @@ -243,6 +239,10 @@ Passing --verify will verify signature against provided public key.
fmt.Fprintf(tw, "TTL:\t%s\n", out.Entry.TTL.String())
}

if out.SignatureType != "" {
fmt.Fprintf(tw, "Signature Type:\t%s\n", out.SignatureType)
}

if out.Validation == nil {
tw.Flush()
fmt.Fprintf(w, "\nThis record was not validated.\n")
Expand Down
2 changes: 1 addition & 1 deletion docs/changelogs/v0.22.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ by passing `--v1compat=false`. By default, we still create V1+V2 records, such
that there is the highest chance of backwards compatibility. The goal is to move
to V2 only in the future.

**TODO**: add links to IPIP.
**TODO**: add links to IPIP https://github.com/ipfs/specs/issues/376

### 📝 Changelog

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/kubo-as-a-library/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go 1.18
replace github.com/ipfs/kubo => ./../../..

require (
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
github.com/libp2p/go-libp2p v0.27.6
github.com/multiformats/go-multiaddr v0.9.0
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/kubo-as-a-library/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c h1:NR2QQiIBc1DfWpybfxkuWV2hS8TTIZp+1tpOBytR0kA=
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c/go.mod h1:IwBbXi5P7fA0HzLhsw/FtAj9RAMacODuOCPPsBcvqcE=
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f h1:/CGX/6s9D0c+32FyjuWuzF+WKnSJj7W/ZNYMGfY+aHM=
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f/go.mod h1:OGMmq97krQBiKx8LRGyf5DgWHeu+PDdIHNN2YnQlWjs=
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/fsnotify/fsnotify v1.6.0
github.com/google/uuid v1.3.0
github.com/hashicorp/go-multierror v1.1.1
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f
github.com/ipfs/go-block-format v0.1.2
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-cidutil v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c h1:NR2QQiIBc1DfWpybfxkuWV2hS8TTIZp+1tpOBytR0kA=
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c/go.mod h1:IwBbXi5P7fA0HzLhsw/FtAj9RAMacODuOCPPsBcvqcE=
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f h1:/CGX/6s9D0c+32FyjuWuzF+WKnSJj7W/ZNYMGfY+aHM=
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f/go.mod h1:OGMmq97krQBiKx8LRGyf5DgWHeu+PDdIHNN2YnQlWjs=
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
Expand Down
4 changes: 3 additions & 1 deletion test/cli/name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestName(t *testing.T) {
require.Equal(t, publishPath+"\n", res.Stdout.String())
})

t.Run("Publishing a CID+Path", func(t *testing.T) {
t.Run("Publishing a CID+subpath", func(t *testing.T) {
publishPath := "/ipfs/" + fixtureCid + "/hello"

res := node.IPFS("name", "publish", "--allow-offline", publishPath)
Expand Down Expand Up @@ -180,6 +180,7 @@ func TestName(t *testing.T) {
res = node.PipeToIPFS(bytes.NewReader(record), "name", "inspect", "--verify="+ipnsPath)
out = res.Stdout.String()
require.Contains(t, out, "Valid: true")
require.Contains(t, out, "Signature Type: V2")
})

t.Run("Publish with TTL and inspect record", func(t *testing.T) {
Expand All @@ -200,6 +201,7 @@ func TestName(t *testing.T) {
require.Contains(t, out, "This record was not validated.")
require.Contains(t, out, publishPath)
require.Contains(t, out, "30m")
require.Contains(t, out, "Signature Type: V1+V2")
})

t.Run("Inspect record shows valid with correct name", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/dependencies/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ replace github.com/ipfs/kubo => ../../
require (
github.com/Kubuxu/gocovmerge v0.0.0-20161216165753-7ecaa51963cd
github.com/golangci/golangci-lint v1.49.0
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-cidutil v0.1.0
github.com/ipfs/go-datastore v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions test/dependencies/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c h1:NR2QQiIBc1DfWpybfxkuWV2hS8TTIZp+1tpOBytR0kA=
github.com/ipfs/boxo v0.10.1-0.20230616070024-54043d34916c/go.mod h1:IwBbXi5P7fA0HzLhsw/FtAj9RAMacODuOCPPsBcvqcE=
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f h1:/CGX/6s9D0c+32FyjuWuzF+WKnSJj7W/ZNYMGfY+aHM=
github.com/ipfs/boxo v0.10.2-0.20230620114258-35733f51853f/go.mod h1:OGMmq97krQBiKx8LRGyf5DgWHeu+PDdIHNN2YnQlWjs=
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo=
Expand Down

0 comments on commit 29f81e0

Please sign in to comment.