From 4a0bf28985fec9f681a44af8ebb10492115e4212 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 9 Feb 2018 16:14:42 +0100 Subject: [PATCH] swarm/api: block api.Put with wait --- swarm/api/api_test.go | 3 ++- swarm/api/storage.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/swarm/api/api_test.go b/swarm/api/api_test.go index da1d8bcf23..1f1178549e 100644 --- a/swarm/api/api_test.go +++ b/swarm/api/api_test.go @@ -109,10 +109,11 @@ func TestApiPut(t *testing.T) { content := "hello" exp := expResponse(content, "text/plain", 0) // exp := expResponse([]byte(content), "text/plain", 0) - key, _, err := api.Put(content, exp.MimeType) + key, wait, err := api.Put(content, exp.MimeType) if err != nil { t.Fatalf("unexpected error: %v", err) } + wait() resp := testGet(t, api, key.Hex(), "") checkResponse(t, resp, exp) }) diff --git a/swarm/api/storage.go b/swarm/api/storage.go index 4679fabad3..8876967792 100644 --- a/swarm/api/storage.go +++ b/swarm/api/storage.go @@ -42,10 +42,11 @@ func NewStorage(api *Api) *Storage { // // DEPRECATED: Use the HTTP API instead func (self *Storage) Put(content, contentType string) (string, error) { - key, _, err := self.api.Put(content, contentType) + key, wait, err := self.api.Put(content, contentType) if err != nil { return "", err } + wait() return key.Hex(), err }