mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
swarm/api: Amend @gbalint comments PR 204 + args dep test loglvl
This commit is contained in:
parent
edacd4b7c3
commit
690522b09d
4 changed files with 25 additions and 10 deletions
|
|
@ -389,8 +389,11 @@ func (self *Api) ResourceLookup(name string, period uint32, version uint32) (sto
|
|||
|
||||
func (self *Api) ResourceCreate(name string, frequency uint64) (storage.Key, error) {
|
||||
rsrc, err := self.resource.NewResource(name, frequency)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
h := rsrc.NameHash()
|
||||
return storage.Key(h[:]), err
|
||||
return storage.Key(h[:]), nil
|
||||
}
|
||||
|
||||
func (self *Api) ResourceUpdate(name string, data []byte) (storage.Key, uint32, uint32, error) {
|
||||
|
|
|
|||
|
|
@ -64,13 +64,15 @@ func TestBzzResource(t *testing.T) {
|
|||
resp, err := http.Post(url, "application/octet-stream", bytes.NewReader(databytes))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("err %s", resp.Status)
|
||||
}
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !bytes.Equal(b, []byte(keybyteshash)) {
|
||||
}
|
||||
if !bytes.Equal(b, []byte(keybyteshash)) {
|
||||
t.Fatalf("resource update hash mismatch, expected '%s' got '%s'", keybyteshash, b)
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
|
@ -80,13 +82,15 @@ func TestBzzResource(t *testing.T) {
|
|||
resp, err = http.Get(url)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("err %s", resp.Status)
|
||||
}
|
||||
b, err = ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !bytes.Equal(databytes, b) {
|
||||
}
|
||||
if !bytes.Equal(databytes, b) {
|
||||
t.Fatalf("Expected body '%x', got '%x'", databytes, b)
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
|
@ -97,7 +101,8 @@ func TestBzzResource(t *testing.T) {
|
|||
resp, err = http.Post(url, "application/octet-stream", bytes.NewReader(data))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("Update returned %d", resp.Status)
|
||||
}
|
||||
|
||||
|
|
@ -106,13 +111,15 @@ func TestBzzResource(t *testing.T) {
|
|||
resp, err = http.Get(url)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("err %s", resp.Status)
|
||||
}
|
||||
b, err = ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !bytes.Equal(data, b) {
|
||||
}
|
||||
if !bytes.Equal(data, b) {
|
||||
t.Fatalf("Expected body '%x', got '%x'", data, b)
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
|
|
|||
|
|
@ -703,7 +703,7 @@ func newUpdateChunk(key Key, signature *Signature, period uint32, version uint32
|
|||
datalength := len(data)
|
||||
|
||||
chunk := NewChunk(key, nil)
|
||||
chunk.SData = make([]byte, 4+signaturelength+headerlength+datalength)
|
||||
chunk.SData = make([]byte, 4+signaturelength+headerlength+datalength) // initial 4 are uint16 length descriptors for headerlength and datalength
|
||||
|
||||
// data header length does NOT include the header length prefix bytes themselves
|
||||
cursor := 0
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"crypto/ecdsa"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
|
|
@ -37,7 +38,11 @@ var (
|
|||
|
||||
func init() {
|
||||
var err error
|
||||
verbose := flag.Bool("v", false, "verbose")
|
||||
flag.Parse()
|
||||
if *verbose {
|
||||
log.Root().SetHandler(log.CallerFileHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))))
|
||||
}
|
||||
safeName, err = ToSafeName(domainName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue