diff options
author | Felix Lange <fjl@twurst.com> | 2016-11-11 13:13:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-11 13:13:16 +0800 |
commit | 9eb6f627fa9e08573580fc5915e23d332a36071b (patch) | |
tree | 711a6f608e074df8ab514f1e269dac457ddc1fdc /swarm | |
parent | 80ea44c485c42032aa954f2a8580e3afb4aa5339 (diff) | |
parent | 8247bccf71351812cd60179c3ef0f9d596f117c1 (diff) | |
download | dexon-9eb6f627fa9e08573580fc5915e23d332a36071b.tar dexon-9eb6f627fa9e08573580fc5915e23d332a36071b.tar.gz dexon-9eb6f627fa9e08573580fc5915e23d332a36071b.tar.bz2 dexon-9eb6f627fa9e08573580fc5915e23d332a36071b.tar.lz dexon-9eb6f627fa9e08573580fc5915e23d332a36071b.tar.xz dexon-9eb6f627fa9e08573580fc5915e23d332a36071b.tar.zst dexon-9eb6f627fa9e08573580fc5915e23d332a36071b.zip |
Merge pull request #3247 from fjl/bzzd
cmd: add swarm command line tools
Diffstat (limited to 'swarm')
-rw-r--r-- | swarm/api/config.go | 3 | ||||
-rw-r--r-- | swarm/api/config_test.go | 16 | ||||
-rw-r--r-- | swarm/api/http/server.go | 6 | ||||
-rw-r--r-- | swarm/network/syncdb_test.go | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/swarm/api/config.go b/swarm/api/config.go index 730755c43..c04a015ef 100644 --- a/swarm/api/config.go +++ b/swarm/api/config.go @@ -59,9 +59,8 @@ type Config struct { // config is agnostic to where private key is coming from // so managing accounts is outside swarm and left to wrappers func NewConfig(path string, contract common.Address, prvKey *ecdsa.PrivateKey) (self *Config, err error) { - address := crypto.PubkeyToAddress(prvKey.PublicKey) // default beneficiary address - dirpath := filepath.Join(path, common.Bytes2Hex(address.Bytes())) + dirpath := filepath.Join(path, "bzz-"+common.Bytes2Hex(address.Bytes())) err = os.MkdirAll(dirpath, os.ModePerm) if err != nil { return diff --git a/swarm/api/config_test.go b/swarm/api/config_test.go index 874701119..8fe3ddacc 100644 --- a/swarm/api/config_test.go +++ b/swarm/api/config_test.go @@ -30,14 +30,14 @@ import ( var ( hexprvkey = "65138b2aa745041b372153550584587da326ab440576b2a1191dd95cee30039c" defaultConfig = `{ - "ChunkDbPath": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e", "chunks") + `", + "ChunkDbPath": "` + filepath.Join("TMPDIR", "chunks") + `", "DbCapacity": 5000000, "CacheCapacity": 5000, "Radius": 0, "Branches": 128, "Hash": "SHA3", "CallInterval": 3000000000, - "KadDbPath": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e", "bzz-peers.json") + `", + "KadDbPath": "` + filepath.Join("TMPDIR", "bzz-peers.json") + `", "MaxProx": 8, "ProxBinSize": 2, "BucketSize": 4, @@ -59,7 +59,7 @@ var ( "Contract": "0x0000000000000000000000000000000000000000", "Beneficiary": "0x0d2f62485607cf38d9d795d93682a517661e513e" }, - "RequestDbPath": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e", "requests") + `", + "RequestDbPath": "` + filepath.Join("TMPDIR", "requests") + `", "RequestDbBatchSize": 512, "KeyBufferSize": 1024, "SyncBatchSize": 128, @@ -79,7 +79,7 @@ var ( true, false ], - "Path": "` + filepath.Join("TMPDIR", "0d2f62485607cf38d9d795d93682a517661e513e") + `", + "Path": "TMPDIR", "Port": "8500", "PublicKey": "0x045f5cfd26692e48d0017d380349bcf50982488bc11b5145f3ddf88b24924299048450542d43527fbe29a5cb32f38d62755393ac002e6bfdd71b8d7ba725ecd7a3", "BzzKey": "0xe861964402c0b78e2d44098329b8545726f215afa737d803714a4338552fcb81", @@ -99,16 +99,12 @@ func TestConfigWriteRead(t *testing.T) { if err != nil { t.Fatalf("expected no error, got %v", err) } - account := crypto.PubkeyToAddress(prvkey.PublicKey) - dirpath := filepath.Join(tmp, common.Bytes2Hex(account.Bytes())) - confpath := filepath.Join(dirpath, "config.json") - data, err := ioutil.ReadFile(confpath) + data, err := ioutil.ReadFile(filepath.Join(orig.Path, "config.json")) if err != nil { t.Fatalf("default config file cannot be read: %v", err) } - exp := strings.Replace(defaultConfig, "TMPDIR", tmp, -1) + exp := strings.Replace(defaultConfig, "TMPDIR", orig.Path, -1) exp = strings.Replace(exp, "\\", "\\\\", -1) - if string(data) != exp { t.Fatalf("default config mismatch:\nexpected: %v\ngot: %v", exp, string(data)) } diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go index a35672687..9be60ef94 100644 --- a/swarm/api/http/server.go +++ b/swarm/api/http/server.go @@ -115,7 +115,11 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) { switch { case r.Method == "POST" || r.Method == "PUT": - key, err := a.Store(r.Body, r.ContentLength, nil) + if r.Header.Get("content-length") == "" { + http.Error(w, "Missing Content-Length header in request.", http.StatusBadRequest) + return + } + key, err := a.Store(io.LimitReader(r.Body, r.ContentLength), r.ContentLength, nil) if err == nil { glog.V(logger.Debug).Infof("Content for %v stored", key.Log()) } else { diff --git a/swarm/network/syncdb_test.go b/swarm/network/syncdb_test.go index e46d32a2e..ed43fbd06 100644 --- a/swarm/network/syncdb_test.go +++ b/swarm/network/syncdb_test.go @@ -141,6 +141,8 @@ func (self *testSyncDb) expect(n int, db bool) { } func TestSyncDb(t *testing.T) { + t.Skip("fails randomly on all platforms") + priority := High bufferSize := 5 batchSize := 2 * bufferSize |