From f1e86ad9cf0470051b7106ee83794d27276b528d Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Sat, 29 Sep 2018 01:00:28 +0200 Subject: swarm/storage/mru: Renamed all identifiers to Feeds --- cmd/swarm/mru.go | 4 ++-- cmd/swarm/mru_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/swarm/mru.go b/cmd/swarm/mru.go index cc7f634cb..afa73820f 100644 --- a/cmd/swarm/mru.go +++ b/cmd/swarm/mru.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with go-ethereum. If not, see . -// Command resource allows the user to create and update signed mutable resource updates +// Command resource allows the user to create and update signed Swarm Feeds package main import ( @@ -66,7 +66,7 @@ func resourceCreate(ctx *cli.Context) { ) newResourceRequest := mru.NewFirstRequest(getTopic(ctx)) - newResourceRequest.View.User = resourceGetUser(ctx) + newResourceRequest.Feed.User = resourceGetUser(ctx) manifestAddress, err := client.CreateResource(newResourceRequest) if err != nil { diff --git a/cmd/swarm/mru_test.go b/cmd/swarm/mru_test.go index 142cf9cfd..c52097a6e 100644 --- a/cmd/swarm/mru_test.go +++ b/cmd/swarm/mru_test.go @@ -101,7 +101,7 @@ func TestCLIResourceUpdate(t *testing.T) { } // View configures whose updates we will be looking up. - view := mru.View{ + view := mru.Feed{ Topic: topic, User: address, } @@ -146,8 +146,8 @@ func TestCLIResourceUpdate(t *testing.T) { } // make sure the retrieved view is the same - if request.View != view { - t.Fatalf("Expected view to be: %s, got %s", view, request.View) + if request.Feed != view { + t.Fatalf("Expected view to be: %s, got %s", view, request.Feed) } // test publishing a manifest -- cgit v1.2.3 From 83705ef6aa3645a6305a400fa175e44904a929f7 Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Sun, 30 Sep 2018 09:43:10 +0200 Subject: swarm/storage/mru: Renamed rest of MRU references --- cmd/swarm/main.go | 66 +++++++++++++++++++++++++-------------------------- cmd/swarm/mru.go | 52 ++++++++++++++++++++-------------------- cmd/swarm/mru_test.go | 34 +++++++++++++------------- 3 files changed, 76 insertions(+), 76 deletions(-) (limited to 'cmd') diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index 5acf87c71..4c4dfceb7 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -207,25 +207,25 @@ var ( Name: "compressed", Usage: "Prints encryption keys in compressed form", } - SwarmResourceNameFlag = cli.StringFlag{ + SwarmFeedNameFlag = cli.StringFlag{ Name: "name", - Usage: "User-defined name for the new resource, limited to 32 characters. If combined with topic, the resource will be a subtopic with this name", + Usage: "User-defined name for the new feed, limited to 32 characters. If combined with topic, it will refer to a subtopic with this name", } - SwarmResourceTopicFlag = cli.StringFlag{ + SwarmFeedTopicFlag = cli.StringFlag{ Name: "topic", - Usage: "User-defined topic this resource is tracking, hex encoded. Limited to 64 hexadecimal characters", + Usage: "User-defined topic this feed is tracking, hex encoded. Limited to 64 hexadecimal characters", } - SwarmResourceDataOnCreateFlag = cli.StringFlag{ + SwarmFeedDataOnCreateFlag = cli.StringFlag{ Name: "data", - Usage: "Initializes the resource with the given hex-encoded data. Data must be prefixed by 0x", + Usage: "Initializes the feed with the given hex-encoded data. Data must be prefixed by 0x", } - SwarmResourceManifestFlag = cli.StringFlag{ + SwarmFeedManifestFlag = cli.StringFlag{ Name: "manifest", - Usage: "Refers to the resource through a manifest", + Usage: "Refers to the feed through a manifest", } - SwarmResourceUserFlag = cli.StringFlag{ + SwarmFeedUserFlag = cli.StringFlag{ Name: "user", - Usage: "Indicates the user who updates the resource", + Usage: "Indicates the user who updates the feed", } ) @@ -346,62 +346,62 @@ func init() { }, { CustomHelpTemplate: helpTemplate, - Name: "resource", - Usage: "(Advanced) Create and update Mutable Resources", + Name: "feed", + Usage: "(Advanced) Create and update Swarm Feeds", ArgsUsage: "", - Description: "Works with Mutable Resource Updates", + Description: "Works with Swarm Feeds", Subcommands: []cli.Command{ { - Action: resourceCreate, + Action: feedCreateManifest, CustomHelpTemplate: helpTemplate, Name: "create", - Usage: "creates and publishes a new Mutable Resource manifest", - Description: `creates and publishes a new Mutable Resource manifest pointing to a specified user's updates about a particular topic. - The resource topic can be built in the following ways: + Usage: "creates and publishes a new Feed manifest", + Description: `creates and publishes a new Feed manifest pointing to a specified user's updates about a particular topic. + The feed topic can be built in the following ways: * use --topic to set the topic to an arbitrary binary hex string. * use --name to set the topic to a human-readable name. - For example --name could be set to "profile-picture", meaning this Mutable Resource allows to get this user's current profile picture. + For example --name could be set to "profile-picture", meaning this feed allows to get this user's current profile picture. * use both --topic and --name to create named subtopics. For example, --topic could be set to an Ethereum contract address and --name could be set to "comments", meaning - the Mutable Resource tracks a discussion about that contract. + this feed tracks a discussion about that contract. The --user flag allows to have this manifest refer to a user other than yourself. If not specified, it will then default to your local account (--bzzaccount)`, - Flags: []cli.Flag{SwarmResourceNameFlag, SwarmResourceTopicFlag, SwarmResourceUserFlag}, + Flags: []cli.Flag{SwarmFeedNameFlag, SwarmFeedTopicFlag, SwarmFeedUserFlag}, }, { - Action: resourceUpdate, + Action: feedUpdate, CustomHelpTemplate: helpTemplate, Name: "update", - Usage: "updates the content of an existing Mutable Resource", + Usage: "updates the content of an existing Swarm Feed", ArgsUsage: "<0x Hex data>", Description: `publishes a new update on the specified topic - The resource topic can be built in the following ways: + The feed topic can be built in the following ways: * use --topic to set the topic to an arbitrary binary hex string. * use --name to set the topic to a human-readable name. - For example --name could be set to "profile-picture", meaning this Mutable Resource allows to get this user's current profile picture. + For example --name could be set to "profile-picture", meaning this feed allows to get this user's current profile picture. * use both --topic and --name to create named subtopics. For example, --topic could be set to an Ethereum contract address and --name could be set to "comments", meaning - the Mutable Resource tracks a discussion about that contract. + this feed tracks a discussion about that contract. - If you have a manifest, you can specify it with --manifest to refer to the resource, + If you have a manifest, you can specify it with --manifest to refer to the feed, instead of using --topic / --name `, - Flags: []cli.Flag{SwarmResourceManifestFlag, SwarmResourceNameFlag, SwarmResourceTopicFlag}, + Flags: []cli.Flag{SwarmFeedManifestFlag, SwarmFeedNameFlag, SwarmFeedTopicFlag}, }, { - Action: resourceInfo, + Action: feedInfo, CustomHelpTemplate: helpTemplate, Name: "info", - Usage: "obtains information about an existing Mutable Resource", - Description: `obtains information about an existing Mutable Resource + Usage: "obtains information about an existing Swarm Feed", + Description: `obtains information about an existing Swarm Feed The topic can be specified directly with the --topic flag as an hex string If no topic is specified, the default topic (zero) will be used The --name flag can be used to specify subtopics with a specific name. The --user flag allows to refer to a user other than yourself. If not specified, it will then default to your local account (--bzzaccount) If you have a manifest, you can specify it with --manifest instead of --topic / --name / ---user - to refer to the resource`, - Flags: []cli.Flag{SwarmResourceManifestFlag, SwarmResourceNameFlag, SwarmResourceTopicFlag, SwarmResourceUserFlag}, + to refer to the feed`, + Flags: []cli.Flag{SwarmFeedManifestFlag, SwarmFeedNameFlag, SwarmFeedTopicFlag, SwarmFeedUserFlag}, }, }, }, @@ -738,7 +738,7 @@ func getAccount(bzzaccount string, ctx *cli.Context, stack *node.Node) *ecdsa.Pr } // getPrivKey returns the private key of the specified bzzaccount -// Used only by client commands, such as `resource` +// Used only by client commands, such as `feed` func getPrivKey(ctx *cli.Context) *ecdsa.PrivateKey { // booting up the swarm node just as we do in bzzd action bzzconfig, err := buildConfig(ctx) diff --git a/cmd/swarm/mru.go b/cmd/swarm/mru.go index afa73820f..6c6d44c0a 100644 --- a/cmd/swarm/mru.go +++ b/cmd/swarm/mru.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with go-ethereum. If not, see . -// Command resource allows the user to create and update signed Swarm Feeds +// Command feed allows the user to create and update signed Swarm Feeds package main import ( @@ -36,8 +36,8 @@ func NewGenericSigner(ctx *cli.Context) mru.Signer { } func getTopic(ctx *cli.Context) (topic mru.Topic) { - var name = ctx.String(SwarmResourceNameFlag.Name) - var relatedTopic = ctx.String(SwarmResourceTopicFlag.Name) + var name = ctx.String(SwarmFeedNameFlag.Name) + var relatedTopic = ctx.String(SwarmFeedTopicFlag.Name) var relatedTopicBytes []byte var err error @@ -55,35 +55,35 @@ func getTopic(ctx *cli.Context) (topic mru.Topic) { return topic } -// swarm resource create [--name ] [--data <0x Hexdata> [--multihash=false]] -// swarm resource update <0x Hexdata> [--multihash=false] -// swarm resource info +// swarm feed create [--name ] [--data <0x Hexdata> [--multihash=false]] +// swarm feed update <0x Hexdata> [--multihash=false] +// swarm feed info -func resourceCreate(ctx *cli.Context) { +func feedCreateManifest(ctx *cli.Context) { var ( bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") client = swarm.NewClient(bzzapi) ) - newResourceRequest := mru.NewFirstRequest(getTopic(ctx)) - newResourceRequest.Feed.User = resourceGetUser(ctx) + newFeedUpdateRequest := mru.NewFirstRequest(getTopic(ctx)) + newFeedUpdateRequest.Feed.User = feedGetUser(ctx) - manifestAddress, err := client.CreateResource(newResourceRequest) + manifestAddress, err := client.CreateFeedWithManifest(newFeedUpdateRequest) if err != nil { - utils.Fatalf("Error creating resource: %s", err.Error()) + utils.Fatalf("Error creating feed manifest: %s", err.Error()) return } fmt.Println(manifestAddress) // output manifest address to the user in a single line (useful for other commands to pick up) } -func resourceUpdate(ctx *cli.Context) { +func feedUpdate(ctx *cli.Context) { args := ctx.Args() var ( bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") client = swarm.NewClient(bzzapi) - manifestAddressOrDomain = ctx.String(SwarmResourceManifestFlag.Name) + manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name) ) if len(args) < 1 { @@ -110,10 +110,10 @@ func resourceUpdate(ctx *cli.Context) { } - // Retrieve resource status and metadata out of the manifest - updateRequest, err = client.GetResourceMetadata(query, manifestAddressOrDomain) + // Retrieve feed status and metadata out of the manifest + updateRequest, err = client.GetFeedMetadata(query, manifestAddressOrDomain) if err != nil { - utils.Fatalf("Error retrieving resource status: %s", err.Error()) + utils.Fatalf("Error retrieving feed status: %s", err.Error()) } // set the new data @@ -121,34 +121,34 @@ func resourceUpdate(ctx *cli.Context) { // sign update if err = updateRequest.Sign(signer); err != nil { - utils.Fatalf("Error signing resource update: %s", err.Error()) + utils.Fatalf("Error signing feed update: %s", err.Error()) } // post update - err = client.UpdateResource(updateRequest) + err = client.UpdateFeed(updateRequest) if err != nil { - utils.Fatalf("Error updating resource: %s", err.Error()) + utils.Fatalf("Error updating feed: %s", err.Error()) return } } -func resourceInfo(ctx *cli.Context) { +func feedInfo(ctx *cli.Context) { var ( bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") client = swarm.NewClient(bzzapi) - manifestAddressOrDomain = ctx.String(SwarmResourceManifestFlag.Name) + manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name) ) var query *mru.Query if manifestAddressOrDomain == "" { query = new(mru.Query) query.Topic = getTopic(ctx) - query.User = resourceGetUser(ctx) + query.User = feedGetUser(ctx) } - metadata, err := client.GetResourceMetadata(query, manifestAddressOrDomain) + metadata, err := client.GetFeedMetadata(query, manifestAddressOrDomain) if err != nil { - utils.Fatalf("Error retrieving resource metadata: %s", err.Error()) + utils.Fatalf("Error retrieving feed metadata: %s", err.Error()) return } encodedMetadata, err := metadata.MarshalJSON() @@ -158,8 +158,8 @@ func resourceInfo(ctx *cli.Context) { fmt.Println(string(encodedMetadata)) } -func resourceGetUser(ctx *cli.Context) common.Address { - var user = ctx.String(SwarmResourceUserFlag.Name) +func feedGetUser(ctx *cli.Context) common.Address { + var user = ctx.String(SwarmFeedUserFlag.Name) if user != "" { return common.HexToAddress(user) } diff --git a/cmd/swarm/mru_test.go b/cmd/swarm/mru_test.go index c52097a6e..c0c43aca4 100644 --- a/cmd/swarm/mru_test.go +++ b/cmd/swarm/mru_test.go @@ -38,12 +38,12 @@ import ( swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http" ) -func TestCLIResourceUpdate(t *testing.T) { +func TestCLIFeedUpdate(t *testing.T) { srv := testutil.NewTestSwarmServer(t, func(api *api.API) testutil.TestServer { return swarmhttp.NewServer(api, "") }, nil) - log.Info("starting 1 node cluster") + log.Info("starting a test swarm server") defer srv.Close() // create a private key file for signing @@ -77,13 +77,13 @@ func TestCLIResourceUpdate(t *testing.T) { flags := []string{ "--bzzapi", srv.URL, "--bzzaccount", pkfile.Name(), - "resource", "update", + "feed", "update", "--topic", topic.Hex(), "--name", name, hexData} // create an update and expect an exit without errors - log.Info(fmt.Sprintf("updating a resource with 'swarm resource update'")) + log.Info(fmt.Sprintf("updating a feed with 'swarm feed update'")) cmd := runSwarm(t, flags...) cmd.ExpectExit() @@ -100,17 +100,17 @@ func TestCLIResourceUpdate(t *testing.T) { t.Fatal(err) } - // View configures whose updates we will be looking up. - view := mru.Feed{ + // Feed configures whose updates we will be looking up. + feed := mru.Feed{ Topic: topic, User: address, } // Build a query to get the latest update - query := mru.NewQueryLatest(&view, lookup.NoClue) + query := mru.NewQueryLatest(&feed, lookup.NoClue) // retrieve content! - reader, err := client.GetResource(query, "") + reader, err := client.QueryFeed(query, "") if err != nil { t.Fatal(err) } @@ -128,12 +128,12 @@ func TestCLIResourceUpdate(t *testing.T) { // Now retrieve info for the next update flags = []string{ "--bzzapi", srv.URL, - "resource", "info", + "feed", "info", "--topic", topic.Hex(), "--user", address.Hex(), } - log.Info(fmt.Sprintf("getting resource info with 'swarm resource info'")) + log.Info(fmt.Sprintf("getting feed info with 'swarm feed info'")) cmd = runSwarm(t, flags...) _, matches := cmd.ExpectRegexp(`.*`) // regex hack to extract stdout cmd.ExpectExit() @@ -145,28 +145,28 @@ func TestCLIResourceUpdate(t *testing.T) { t.Fatal(err) } - // make sure the retrieved view is the same - if request.Feed != view { - t.Fatalf("Expected view to be: %s, got %s", view, request.Feed) + // make sure the retrieved Feed is the same + if request.Feed != feed { + t.Fatalf("Expected feed to be: %s, got %s", feed, request.Feed) } // test publishing a manifest flags = []string{ "--bzzapi", srv.URL, "--bzzaccount", pkfile.Name(), - "resource", "create", + "feed", "create", "--topic", topic.Hex(), } - log.Info(fmt.Sprintf("Publishing manifest with 'swarm resource create'")) + log.Info(fmt.Sprintf("Publishing manifest with 'swarm feed create'")) cmd = runSwarm(t, flags...) _, matches = cmd.ExpectRegexp(`[a-f\d]{64}`) // regex hack to extract stdout cmd.ExpectExit() - manifestAddress := matches[0] // read the received resource manifest + manifestAddress := matches[0] // read the received feed manifest // now attempt to lookup the latest update using a manifest instead - reader, err = client.GetResource(nil, manifestAddress) + reader, err = client.QueryFeed(nil, manifestAddress) if err != nil { t.Fatal(err) } -- cgit v1.2.3 From b6ccc06cdaac80d09da17c25b2f450cd1f1b7914 Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Sun, 30 Sep 2018 09:51:11 +0200 Subject: swarm/storage/feeds: Final package rename and moved files --- cmd/swarm/feeds.go | 172 +++++++++++++++++++++++++++++++++++++++++++++ cmd/swarm/feeds_test.go | 182 ++++++++++++++++++++++++++++++++++++++++++++++++ cmd/swarm/mru.go | 172 --------------------------------------------- cmd/swarm/mru_test.go | 182 ------------------------------------------------ 4 files changed, 354 insertions(+), 354 deletions(-) create mode 100644 cmd/swarm/feeds.go create mode 100644 cmd/swarm/feeds_test.go delete mode 100644 cmd/swarm/mru.go delete mode 100644 cmd/swarm/mru_test.go (limited to 'cmd') diff --git a/cmd/swarm/feeds.go b/cmd/swarm/feeds.go new file mode 100644 index 000000000..b7b513556 --- /dev/null +++ b/cmd/swarm/feeds.go @@ -0,0 +1,172 @@ +// Copyright 2016 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with go-ethereum. If not, see . + +// Command feed allows the user to create and update signed Swarm Feeds +package main + +import ( + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/crypto" + + "github.com/ethereum/go-ethereum/cmd/utils" + swarm "github.com/ethereum/go-ethereum/swarm/api/client" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" + "gopkg.in/urfave/cli.v1" +) + +func NewGenericSigner(ctx *cli.Context) feeds.Signer { + return feeds.NewGenericSigner(getPrivKey(ctx)) +} + +func getTopic(ctx *cli.Context) (topic feeds.Topic) { + var name = ctx.String(SwarmFeedNameFlag.Name) + var relatedTopic = ctx.String(SwarmFeedTopicFlag.Name) + var relatedTopicBytes []byte + var err error + + if relatedTopic != "" { + relatedTopicBytes, err = hexutil.Decode(relatedTopic) + if err != nil { + utils.Fatalf("Error parsing topic: %s", err) + } + } + + topic, err = feeds.NewTopic(name, relatedTopicBytes) + if err != nil { + utils.Fatalf("Error parsing topic: %s", err) + } + return topic +} + +// swarm feed create [--name ] [--data <0x Hexdata> [--multihash=false]] +// swarm feed update <0x Hexdata> [--multihash=false] +// swarm feed info + +func feedCreateManifest(ctx *cli.Context) { + var ( + bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") + client = swarm.NewClient(bzzapi) + ) + + newFeedUpdateRequest := feeds.NewFirstRequest(getTopic(ctx)) + newFeedUpdateRequest.Feed.User = feedGetUser(ctx) + + manifestAddress, err := client.CreateFeedWithManifest(newFeedUpdateRequest) + if err != nil { + utils.Fatalf("Error creating feed manifest: %s", err.Error()) + return + } + fmt.Println(manifestAddress) // output manifest address to the user in a single line (useful for other commands to pick up) + +} + +func feedUpdate(ctx *cli.Context) { + args := ctx.Args() + + var ( + bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") + client = swarm.NewClient(bzzapi) + manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name) + ) + + if len(args) < 1 { + fmt.Println("Incorrect number of arguments") + cli.ShowCommandHelpAndExit(ctx, "update", 1) + return + } + + signer := NewGenericSigner(ctx) + + data, err := hexutil.Decode(args[0]) + if err != nil { + utils.Fatalf("Error parsing data: %s", err.Error()) + return + } + + var updateRequest *feeds.Request + var query *feeds.Query + + if manifestAddressOrDomain == "" { + query = new(feeds.Query) + query.User = signer.Address() + query.Topic = getTopic(ctx) + + } + + // Retrieve a feed update request + updateRequest, err = client.GetFeedRequest(query, manifestAddressOrDomain) + if err != nil { + utils.Fatalf("Error retrieving feed status: %s", err.Error()) + } + + // set the new data + updateRequest.SetData(data) + + // sign update + if err = updateRequest.Sign(signer); err != nil { + utils.Fatalf("Error signing feed update: %s", err.Error()) + } + + // post update + err = client.UpdateFeed(updateRequest) + if err != nil { + utils.Fatalf("Error updating feed: %s", err.Error()) + return + } +} + +func feedInfo(ctx *cli.Context) { + var ( + bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") + client = swarm.NewClient(bzzapi) + manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name) + ) + + var query *feeds.Query + if manifestAddressOrDomain == "" { + query = new(feeds.Query) + query.Topic = getTopic(ctx) + query.User = feedGetUser(ctx) + } + + metadata, err := client.GetFeedRequest(query, manifestAddressOrDomain) + if err != nil { + utils.Fatalf("Error retrieving feed metadata: %s", err.Error()) + return + } + encodedMetadata, err := metadata.MarshalJSON() + if err != nil { + utils.Fatalf("Error encoding metadata to JSON for display:%s", err) + } + fmt.Println(string(encodedMetadata)) +} + +func feedGetUser(ctx *cli.Context) common.Address { + var user = ctx.String(SwarmFeedUserFlag.Name) + if user != "" { + return common.HexToAddress(user) + } + pk := getPrivKey(ctx) + if pk == nil { + utils.Fatalf("Cannot read private key. Must specify --user or --bzzaccount") + } + return crypto.PubkeyToAddress(pk.PublicKey) + +} diff --git a/cmd/swarm/feeds_test.go b/cmd/swarm/feeds_test.go new file mode 100644 index 000000000..a403f8fe4 --- /dev/null +++ b/cmd/swarm/feeds_test.go @@ -0,0 +1,182 @@ +// Copyright 2017 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with go-ethereum. If not, see . + +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "testing" + + "github.com/ethereum/go-ethereum/swarm/api" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" + "github.com/ethereum/go-ethereum/swarm/testutil" + + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" + + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/log" + swarm "github.com/ethereum/go-ethereum/swarm/api/client" + swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http" +) + +func TestCLIFeedUpdate(t *testing.T) { + + srv := testutil.NewTestSwarmServer(t, func(api *api.API) testutil.TestServer { + return swarmhttp.NewServer(api, "") + }, nil) + log.Info("starting a test swarm server") + defer srv.Close() + + // create a private key file for signing + pkfile, err := ioutil.TempFile("", "swarm-test") + if err != nil { + t.Fatal(err) + } + defer pkfile.Close() + defer os.Remove(pkfile.Name()) + + privkeyHex := "0000000000000000000000000000000000000000000000000000000000001979" + privKey, _ := crypto.HexToECDSA(privkeyHex) + address := crypto.PubkeyToAddress(privKey.PublicKey) + + // save the private key to a file + _, err = io.WriteString(pkfile, privkeyHex) + if err != nil { + t.Fatal(err) + } + + // compose a topic. We'll be doing quotes about Miguel de Cervantes + var topic feeds.Topic + subject := []byte("Miguel de Cervantes") + copy(topic[:], subject[:]) + name := "quotes" + + // prepare some data for the update + data := []byte("En boca cerrada no entran moscas") + hexData := hexutil.Encode(data) + + flags := []string{ + "--bzzapi", srv.URL, + "--bzzaccount", pkfile.Name(), + "feed", "update", + "--topic", topic.Hex(), + "--name", name, + hexData} + + // create an update and expect an exit without errors + log.Info(fmt.Sprintf("updating a feed with 'swarm feed update'")) + cmd := runSwarm(t, flags...) + cmd.ExpectExit() + + // now try to get the update using the client + client := swarm.NewClient(srv.URL) + if err != nil { + t.Fatal(err) + } + + // build the same topic as before, this time + // we use NewTopic to create a topic automatically. + topic, err = feeds.NewTopic(name, subject) + if err != nil { + t.Fatal(err) + } + + // Feed configures whose updates we will be looking up. + feed := feeds.Feed{ + Topic: topic, + User: address, + } + + // Build a query to get the latest update + query := feeds.NewQueryLatest(&feed, lookup.NoClue) + + // retrieve content! + reader, err := client.QueryFeed(query, "") + if err != nil { + t.Fatal(err) + } + + retrieved, err := ioutil.ReadAll(reader) + if err != nil { + t.Fatal(err) + } + + // check we retrieved the sent information + if !bytes.Equal(data, retrieved) { + t.Fatalf("Received %s, expected %s", retrieved, data) + } + + // Now retrieve info for the next update + flags = []string{ + "--bzzapi", srv.URL, + "feed", "info", + "--topic", topic.Hex(), + "--user", address.Hex(), + } + + log.Info(fmt.Sprintf("getting feed info with 'swarm feed info'")) + cmd = runSwarm(t, flags...) + _, matches := cmd.ExpectRegexp(`.*`) // regex hack to extract stdout + cmd.ExpectExit() + + // verify we can deserialize the result as a valid JSON + var request feeds.Request + err = json.Unmarshal([]byte(matches[0]), &request) + if err != nil { + t.Fatal(err) + } + + // make sure the retrieved Feed is the same + if request.Feed != feed { + t.Fatalf("Expected feed to be: %s, got %s", feed, request.Feed) + } + + // test publishing a manifest + flags = []string{ + "--bzzapi", srv.URL, + "--bzzaccount", pkfile.Name(), + "feed", "create", + "--topic", topic.Hex(), + } + + log.Info(fmt.Sprintf("Publishing manifest with 'swarm feed create'")) + cmd = runSwarm(t, flags...) + _, matches = cmd.ExpectRegexp(`[a-f\d]{64}`) // regex hack to extract stdout + cmd.ExpectExit() + + manifestAddress := matches[0] // read the received feed manifest + + // now attempt to lookup the latest update using a manifest instead + reader, err = client.QueryFeed(nil, manifestAddress) + if err != nil { + t.Fatal(err) + } + + retrieved, err = ioutil.ReadAll(reader) + if err != nil { + t.Fatal(err) + } + + if !bytes.Equal(data, retrieved) { + t.Fatalf("Received %s, expected %s", retrieved, data) + } +} diff --git a/cmd/swarm/mru.go b/cmd/swarm/mru.go deleted file mode 100644 index 6c6d44c0a..000000000 --- a/cmd/swarm/mru.go +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of go-ethereum. -// -// go-ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// go-ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with go-ethereum. If not, see . - -// Command feed allows the user to create and update signed Swarm Feeds -package main - -import ( - "fmt" - "strings" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/crypto" - - "github.com/ethereum/go-ethereum/cmd/utils" - swarm "github.com/ethereum/go-ethereum/swarm/api/client" - "github.com/ethereum/go-ethereum/swarm/storage/mru" - "gopkg.in/urfave/cli.v1" -) - -func NewGenericSigner(ctx *cli.Context) mru.Signer { - return mru.NewGenericSigner(getPrivKey(ctx)) -} - -func getTopic(ctx *cli.Context) (topic mru.Topic) { - var name = ctx.String(SwarmFeedNameFlag.Name) - var relatedTopic = ctx.String(SwarmFeedTopicFlag.Name) - var relatedTopicBytes []byte - var err error - - if relatedTopic != "" { - relatedTopicBytes, err = hexutil.Decode(relatedTopic) - if err != nil { - utils.Fatalf("Error parsing topic: %s", err) - } - } - - topic, err = mru.NewTopic(name, relatedTopicBytes) - if err != nil { - utils.Fatalf("Error parsing topic: %s", err) - } - return topic -} - -// swarm feed create [--name ] [--data <0x Hexdata> [--multihash=false]] -// swarm feed update <0x Hexdata> [--multihash=false] -// swarm feed info - -func feedCreateManifest(ctx *cli.Context) { - var ( - bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") - client = swarm.NewClient(bzzapi) - ) - - newFeedUpdateRequest := mru.NewFirstRequest(getTopic(ctx)) - newFeedUpdateRequest.Feed.User = feedGetUser(ctx) - - manifestAddress, err := client.CreateFeedWithManifest(newFeedUpdateRequest) - if err != nil { - utils.Fatalf("Error creating feed manifest: %s", err.Error()) - return - } - fmt.Println(manifestAddress) // output manifest address to the user in a single line (useful for other commands to pick up) - -} - -func feedUpdate(ctx *cli.Context) { - args := ctx.Args() - - var ( - bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") - client = swarm.NewClient(bzzapi) - manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name) - ) - - if len(args) < 1 { - fmt.Println("Incorrect number of arguments") - cli.ShowCommandHelpAndExit(ctx, "update", 1) - return - } - - signer := NewGenericSigner(ctx) - - data, err := hexutil.Decode(args[0]) - if err != nil { - utils.Fatalf("Error parsing data: %s", err.Error()) - return - } - - var updateRequest *mru.Request - var query *mru.Query - - if manifestAddressOrDomain == "" { - query = new(mru.Query) - query.User = signer.Address() - query.Topic = getTopic(ctx) - - } - - // Retrieve feed status and metadata out of the manifest - updateRequest, err = client.GetFeedMetadata(query, manifestAddressOrDomain) - if err != nil { - utils.Fatalf("Error retrieving feed status: %s", err.Error()) - } - - // set the new data - updateRequest.SetData(data) - - // sign update - if err = updateRequest.Sign(signer); err != nil { - utils.Fatalf("Error signing feed update: %s", err.Error()) - } - - // post update - err = client.UpdateFeed(updateRequest) - if err != nil { - utils.Fatalf("Error updating feed: %s", err.Error()) - return - } -} - -func feedInfo(ctx *cli.Context) { - var ( - bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") - client = swarm.NewClient(bzzapi) - manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name) - ) - - var query *mru.Query - if manifestAddressOrDomain == "" { - query = new(mru.Query) - query.Topic = getTopic(ctx) - query.User = feedGetUser(ctx) - } - - metadata, err := client.GetFeedMetadata(query, manifestAddressOrDomain) - if err != nil { - utils.Fatalf("Error retrieving feed metadata: %s", err.Error()) - return - } - encodedMetadata, err := metadata.MarshalJSON() - if err != nil { - utils.Fatalf("Error encoding metadata to JSON for display:%s", err) - } - fmt.Println(string(encodedMetadata)) -} - -func feedGetUser(ctx *cli.Context) common.Address { - var user = ctx.String(SwarmFeedUserFlag.Name) - if user != "" { - return common.HexToAddress(user) - } - pk := getPrivKey(ctx) - if pk == nil { - utils.Fatalf("Cannot read private key. Must specify --user or --bzzaccount") - } - return crypto.PubkeyToAddress(pk.PublicKey) - -} diff --git a/cmd/swarm/mru_test.go b/cmd/swarm/mru_test.go deleted file mode 100644 index c0c43aca4..000000000 --- a/cmd/swarm/mru_test.go +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of go-ethereum. -// -// go-ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// go-ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with go-ethereum. If not, see . - -package main - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "os" - "testing" - - "github.com/ethereum/go-ethereum/swarm/api" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" - "github.com/ethereum/go-ethereum/swarm/testutil" - - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/swarm/storage/mru" - - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/log" - swarm "github.com/ethereum/go-ethereum/swarm/api/client" - swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http" -) - -func TestCLIFeedUpdate(t *testing.T) { - - srv := testutil.NewTestSwarmServer(t, func(api *api.API) testutil.TestServer { - return swarmhttp.NewServer(api, "") - }, nil) - log.Info("starting a test swarm server") - defer srv.Close() - - // create a private key file for signing - pkfile, err := ioutil.TempFile("", "swarm-test") - if err != nil { - t.Fatal(err) - } - defer pkfile.Close() - defer os.Remove(pkfile.Name()) - - privkeyHex := "0000000000000000000000000000000000000000000000000000000000001979" - privKey, _ := crypto.HexToECDSA(privkeyHex) - address := crypto.PubkeyToAddress(privKey.PublicKey) - - // save the private key to a file - _, err = io.WriteString(pkfile, privkeyHex) - if err != nil { - t.Fatal(err) - } - - // compose a topic. We'll be doing quotes about Miguel de Cervantes - var topic mru.Topic - subject := []byte("Miguel de Cervantes") - copy(topic[:], subject[:]) - name := "quotes" - - // prepare some data for the update - data := []byte("En boca cerrada no entran moscas") - hexData := hexutil.Encode(data) - - flags := []string{ - "--bzzapi", srv.URL, - "--bzzaccount", pkfile.Name(), - "feed", "update", - "--topic", topic.Hex(), - "--name", name, - hexData} - - // create an update and expect an exit without errors - log.Info(fmt.Sprintf("updating a feed with 'swarm feed update'")) - cmd := runSwarm(t, flags...) - cmd.ExpectExit() - - // now try to get the update using the client - client := swarm.NewClient(srv.URL) - if err != nil { - t.Fatal(err) - } - - // build the same topic as before, this time - // we use NewTopic to create a topic automatically. - topic, err = mru.NewTopic(name, subject) - if err != nil { - t.Fatal(err) - } - - // Feed configures whose updates we will be looking up. - feed := mru.Feed{ - Topic: topic, - User: address, - } - - // Build a query to get the latest update - query := mru.NewQueryLatest(&feed, lookup.NoClue) - - // retrieve content! - reader, err := client.QueryFeed(query, "") - if err != nil { - t.Fatal(err) - } - - retrieved, err := ioutil.ReadAll(reader) - if err != nil { - t.Fatal(err) - } - - // check we retrieved the sent information - if !bytes.Equal(data, retrieved) { - t.Fatalf("Received %s, expected %s", retrieved, data) - } - - // Now retrieve info for the next update - flags = []string{ - "--bzzapi", srv.URL, - "feed", "info", - "--topic", topic.Hex(), - "--user", address.Hex(), - } - - log.Info(fmt.Sprintf("getting feed info with 'swarm feed info'")) - cmd = runSwarm(t, flags...) - _, matches := cmd.ExpectRegexp(`.*`) // regex hack to extract stdout - cmd.ExpectExit() - - // verify we can deserialize the result as a valid JSON - var request mru.Request - err = json.Unmarshal([]byte(matches[0]), &request) - if err != nil { - t.Fatal(err) - } - - // make sure the retrieved Feed is the same - if request.Feed != feed { - t.Fatalf("Expected feed to be: %s, got %s", feed, request.Feed) - } - - // test publishing a manifest - flags = []string{ - "--bzzapi", srv.URL, - "--bzzaccount", pkfile.Name(), - "feed", "create", - "--topic", topic.Hex(), - } - - log.Info(fmt.Sprintf("Publishing manifest with 'swarm feed create'")) - cmd = runSwarm(t, flags...) - _, matches = cmd.ExpectRegexp(`[a-f\d]{64}`) // regex hack to extract stdout - cmd.ExpectExit() - - manifestAddress := matches[0] // read the received feed manifest - - // now attempt to lookup the latest update using a manifest instead - reader, err = client.QueryFeed(nil, manifestAddress) - if err != nil { - t.Fatal(err) - } - - retrieved, err = ioutil.ReadAll(reader) - if err != nil { - t.Fatal(err) - } - - if !bytes.Equal(data, retrieved) { - t.Fatalf("Received %s, expected %s", retrieved, data) - } -} -- cgit v1.2.3 From 58c0879c2fbc9f88f35ba503674088da23a8a5a7 Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Tue, 2 Oct 2018 09:32:46 +0200 Subject: swarm/storage/feeds: removed capital Feed throughout --- cmd/swarm/feeds.go | 2 +- cmd/swarm/feeds_test.go | 2 +- cmd/swarm/main.go | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/swarm/feeds.go b/cmd/swarm/feeds.go index b7b513556..4b34d6d95 100644 --- a/cmd/swarm/feeds.go +++ b/cmd/swarm/feeds.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with go-ethereum. If not, see . -// Command feed allows the user to create and update signed Swarm Feeds +// Command feed allows the user to create and update signed Swarm feeds package main import ( diff --git a/cmd/swarm/feeds_test.go b/cmd/swarm/feeds_test.go index a403f8fe4..055d0ab4c 100644 --- a/cmd/swarm/feeds_test.go +++ b/cmd/swarm/feeds_test.go @@ -145,7 +145,7 @@ func TestCLIFeedUpdate(t *testing.T) { t.Fatal(err) } - // make sure the retrieved Feed is the same + // make sure the retrieved feed is the same if request.Feed != feed { t.Fatalf("Expected feed to be: %s, got %s", feed, request.Feed) } diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index 4c4dfceb7..cdc90a994 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -355,8 +355,8 @@ func init() { Action: feedCreateManifest, CustomHelpTemplate: helpTemplate, Name: "create", - Usage: "creates and publishes a new Feed manifest", - Description: `creates and publishes a new Feed manifest pointing to a specified user's updates about a particular topic. + Usage: "creates and publishes a new feed manifest", + Description: `creates and publishes a new feed manifest pointing to a specified user's updates about a particular topic. The feed topic can be built in the following ways: * use --topic to set the topic to an arbitrary binary hex string. * use --name to set the topic to a human-readable name. @@ -392,8 +392,8 @@ func init() { Action: feedInfo, CustomHelpTemplate: helpTemplate, Name: "info", - Usage: "obtains information about an existing Swarm Feed", - Description: `obtains information about an existing Swarm Feed + Usage: "obtains information about an existing Swarm feed", + Description: `obtains information about an existing Swarm feed The topic can be specified directly with the --topic flag as an hex string If no topic is specified, the default topic (zero) will be used The --name flag can be used to specify subtopics with a specific name. -- cgit v1.2.3 From 696bc9b01ce0ed3347fa1bd64460ccc08091e90a Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Tue, 2 Oct 2018 09:36:11 +0200 Subject: swarm/storage/feeds: renamed vars that can conflict with package name --- cmd/swarm/feeds_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/swarm/feeds_test.go b/cmd/swarm/feeds_test.go index 055d0ab4c..dd0651a25 100644 --- a/cmd/swarm/feeds_test.go +++ b/cmd/swarm/feeds_test.go @@ -101,13 +101,13 @@ func TestCLIFeedUpdate(t *testing.T) { } // Feed configures whose updates we will be looking up. - feed := feeds.Feed{ + fd := feeds.Feed{ Topic: topic, User: address, } // Build a query to get the latest update - query := feeds.NewQueryLatest(&feed, lookup.NoClue) + query := feeds.NewQueryLatest(&fd, lookup.NoClue) // retrieve content! reader, err := client.QueryFeed(query, "") @@ -146,8 +146,8 @@ func TestCLIFeedUpdate(t *testing.T) { } // make sure the retrieved feed is the same - if request.Feed != feed { - t.Fatalf("Expected feed to be: %s, got %s", feed, request.Feed) + if request.Feed != fd { + t.Fatalf("Expected feed to be: %s, got %s", fd, request.Feed) } // test publishing a manifest -- cgit v1.2.3 From de01178c18766b9f744acc94fe2b96804f998e40 Mon Sep 17 00:00:00 2001 From: Javier Peletier Date: Wed, 3 Oct 2018 09:15:17 +0200 Subject: swarm/storage/feed: Renamed package --- cmd/swarm/feeds.go | 22 +++++++++++----------- cmd/swarm/feeds_test.go | 14 +++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'cmd') diff --git a/cmd/swarm/feeds.go b/cmd/swarm/feeds.go index 4b34d6d95..6806c6cf4 100644 --- a/cmd/swarm/feeds.go +++ b/cmd/swarm/feeds.go @@ -27,15 +27,15 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" swarm "github.com/ethereum/go-ethereum/swarm/api/client" - "github.com/ethereum/go-ethereum/swarm/storage/feeds" + "github.com/ethereum/go-ethereum/swarm/storage/feed" "gopkg.in/urfave/cli.v1" ) -func NewGenericSigner(ctx *cli.Context) feeds.Signer { - return feeds.NewGenericSigner(getPrivKey(ctx)) +func NewGenericSigner(ctx *cli.Context) feed.Signer { + return feed.NewGenericSigner(getPrivKey(ctx)) } -func getTopic(ctx *cli.Context) (topic feeds.Topic) { +func getTopic(ctx *cli.Context) (topic feed.Topic) { var name = ctx.String(SwarmFeedNameFlag.Name) var relatedTopic = ctx.String(SwarmFeedTopicFlag.Name) var relatedTopicBytes []byte @@ -48,7 +48,7 @@ func getTopic(ctx *cli.Context) (topic feeds.Topic) { } } - topic, err = feeds.NewTopic(name, relatedTopicBytes) + topic, err = feed.NewTopic(name, relatedTopicBytes) if err != nil { utils.Fatalf("Error parsing topic: %s", err) } @@ -65,7 +65,7 @@ func feedCreateManifest(ctx *cli.Context) { client = swarm.NewClient(bzzapi) ) - newFeedUpdateRequest := feeds.NewFirstRequest(getTopic(ctx)) + newFeedUpdateRequest := feed.NewFirstRequest(getTopic(ctx)) newFeedUpdateRequest.Feed.User = feedGetUser(ctx) manifestAddress, err := client.CreateFeedWithManifest(newFeedUpdateRequest) @@ -100,11 +100,11 @@ func feedUpdate(ctx *cli.Context) { return } - var updateRequest *feeds.Request - var query *feeds.Query + var updateRequest *feed.Request + var query *feed.Query if manifestAddressOrDomain == "" { - query = new(feeds.Query) + query = new(feed.Query) query.User = signer.Address() query.Topic = getTopic(ctx) @@ -139,9 +139,9 @@ func feedInfo(ctx *cli.Context) { manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name) ) - var query *feeds.Query + var query *feed.Query if manifestAddressOrDomain == "" { - query = new(feeds.Query) + query = new(feed.Query) query.Topic = getTopic(ctx) query.User = feedGetUser(ctx) } diff --git a/cmd/swarm/feeds_test.go b/cmd/swarm/feeds_test.go index dd0651a25..46727c21d 100644 --- a/cmd/swarm/feeds_test.go +++ b/cmd/swarm/feeds_test.go @@ -26,11 +26,11 @@ import ( "testing" "github.com/ethereum/go-ethereum/swarm/api" - "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feed/lookup" "github.com/ethereum/go-ethereum/swarm/testutil" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/swarm/storage/feeds" + "github.com/ethereum/go-ethereum/swarm/storage/feed" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" @@ -65,7 +65,7 @@ func TestCLIFeedUpdate(t *testing.T) { } // compose a topic. We'll be doing quotes about Miguel de Cervantes - var topic feeds.Topic + var topic feed.Topic subject := []byte("Miguel de Cervantes") copy(topic[:], subject[:]) name := "quotes" @@ -95,19 +95,19 @@ func TestCLIFeedUpdate(t *testing.T) { // build the same topic as before, this time // we use NewTopic to create a topic automatically. - topic, err = feeds.NewTopic(name, subject) + topic, err = feed.NewTopic(name, subject) if err != nil { t.Fatal(err) } // Feed configures whose updates we will be looking up. - fd := feeds.Feed{ + fd := feed.Feed{ Topic: topic, User: address, } // Build a query to get the latest update - query := feeds.NewQueryLatest(&fd, lookup.NoClue) + query := feed.NewQueryLatest(&fd, lookup.NoClue) // retrieve content! reader, err := client.QueryFeed(query, "") @@ -139,7 +139,7 @@ func TestCLIFeedUpdate(t *testing.T) { cmd.ExpectExit() // verify we can deserialize the result as a valid JSON - var request feeds.Request + var request feed.Request err = json.Unmarshal([]byte(matches[0]), &request) if err != nil { t.Fatal(err) -- cgit v1.2.3