Commit b5f84f47 authored by Janoš Guljaš's avatar Janoš Guljaš Committed by GitHub

Revert "Fix bzz chunk api (#262)" (#279)

This reverts commit 10ee9ab7.
parent cc2fe7be
...@@ -48,7 +48,7 @@ jobs: ...@@ -48,7 +48,7 @@ jobs:
run: ./beekeeper check fullconnectivity --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" run: ./beekeeper check fullconnectivity --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}"
- name: Test pingpong - name: Test pingpong
run: ./beekeeper check pingpong --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" run: ./beekeeper check pingpong --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}"
- name: Test pushsync (bzz API) - name: Test pushsync
run: ./beekeeper check pushsync --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node 3 run: ./beekeeper check pushsync --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node 3
- name: Test pushsync (bzz-chunk API) - name: Test pushsync (bzz-chunk API)
run: ./beekeeper check pushsync --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node 3 --bzz-chunk run: ./beekeeper check pushsync --api-scheme http --debug-api-scheme http --disable-namespace --debug-api-domain localhost --api-domain localhost --node-count "${REPLICA}" --upload-node-count "${REPLICA}" --chunks-per-node 3 --bzz-chunk
......
...@@ -6,7 +6,6 @@ package api ...@@ -6,7 +6,6 @@ package api
import ( import (
"bytes" "bytes"
"encoding/binary"
"errors" "errors"
"fmt" "fmt"
"io" "io"
...@@ -82,12 +81,8 @@ func (s *server) chunkUploadHandler(w http.ResponseWriter, r *http.Request) { ...@@ -82,12 +81,8 @@ func (s *server) chunkUploadHandler(w http.ResponseWriter, r *http.Request) {
s.Logger.Error("bzz-chunk: read chunk data error") s.Logger.Error("bzz-chunk: read chunk data error")
jsonhttp.InternalServerError(w, "cannot read chunk data") jsonhttp.InternalServerError(w, "cannot read chunk data")
return return
}
span := len(data) }
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, uint64(span))
data = append(b, data...)
seen, err := s.Storer.Put(ctx, storage.ModePutUpload, swarm.NewChunk(address, data)) seen, err := s.Storer.Put(ctx, storage.ModePutUpload, swarm.NewChunk(address, data))
if err != nil { if err != nil {
...@@ -145,5 +140,5 @@ func (s *server) chunkGetHandler(w http.ResponseWriter, r *http.Request) { ...@@ -145,5 +140,5 @@ func (s *server) chunkGetHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
w.Header().Set("Content-Type", "binary/octet-stream") w.Header().Set("Content-Type", "binary/octet-stream")
_, _ = io.Copy(w, bytes.NewReader(chunk.Data()[8:])) _, _ = io.Copy(w, bytes.NewReader(chunk.Data()))
} }
...@@ -6,7 +6,6 @@ package api_test ...@@ -6,7 +6,6 @@ package api_test
import ( import (
"bytes" "bytes"
"encoding/binary"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
...@@ -33,7 +32,7 @@ func TestChunkUploadDownload(t *testing.T) { ...@@ -33,7 +32,7 @@ func TestChunkUploadDownload(t *testing.T) {
invalidHash = swarm.MustParseHexAddress("bbccdd") invalidHash = swarm.MustParseHexAddress("bbccdd")
validContent = []byte("bbaatt") validContent = []byte("bbaatt")
invalidContent = []byte("bbaattss") invalidContent = []byte("bbaattss")
mockValidator = validator.NewMockValidator(validHash, append(newSpan(uint64(len(validContent))), validContent...)) mockValidator = validator.NewMockValidator(validHash, validContent)
tag = tags.NewTags() tag = tags.NewTags()
mockValidatingStorer = mock.NewValidatingStorer(mockValidator, tag) mockValidatingStorer = mock.NewValidatingStorer(mockValidator, tag)
client = newTestServer(t, testServerOptions{ client = newTestServer(t, testServerOptions{
...@@ -137,9 +136,3 @@ func request(t *testing.T, client *http.Client, method string, resource string, ...@@ -137,9 +136,3 @@ func request(t *testing.T, client *http.Client, method string, resource string,
} }
return resp return resp
} }
func newSpan(size uint64) []byte {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, size)
return b
}
...@@ -27,7 +27,7 @@ func TestTags(t *testing.T) { ...@@ -27,7 +27,7 @@ func TestTags(t *testing.T) {
tagResourceUUid = func(uuid uint64) string { return "/bzz-tag/uuid/" + strconv.FormatUint(uuid, 10) } tagResourceUUid = func(uuid uint64) string { return "/bzz-tag/uuid/" + strconv.FormatUint(uuid, 10) }
validHash = swarm.MustParseHexAddress("aabbcc") validHash = swarm.MustParseHexAddress("aabbcc")
validContent = []byte("bbaatt") validContent = []byte("bbaatt")
mockValidator = validator.NewMockValidator(validHash, append(newSpan(uint64(len(validContent))), validContent...)) mockValidator = validator.NewMockValidator(validHash, validContent)
tag = tags.NewTags() tag = tags.NewTags()
mockValidatingStorer = mock.NewValidatingStorer(mockValidator, tag) mockValidatingStorer = mock.NewValidatingStorer(mockValidator, tag)
mockPusher = mp.NewMockPusher(tag) mockPusher = mp.NewMockPusher(tag)
...@@ -97,7 +97,7 @@ func TestTags(t *testing.T) { ...@@ -97,7 +97,7 @@ func TestTags(t *testing.T) {
// Add asecond valid contentto validator // Add asecond valid contentto validator
secondValidHash := swarm.MustParseHexAddress("deadbeaf") secondValidHash := swarm.MustParseHexAddress("deadbeaf")
secondValidContent := []byte("123456") secondValidContent := []byte("123456")
mockValidator.AddPair(secondValidHash, append(newSpan(uint64(len(secondValidContent))), secondValidContent...)) mockValidator.AddPair(secondValidHash, secondValidContent)
sentHheaders = make(http.Header) sentHheaders = make(http.Header)
sentHheaders.Set(api.TagHeaderUid, strconv.FormatUint(uint64(ta.Uid), 10)) sentHheaders.Set(api.TagHeaderUid, strconv.FormatUint(uint64(ta.Uid), 10))
......
...@@ -6,7 +6,6 @@ package debugapi_test ...@@ -6,7 +6,6 @@ package debugapi_test
import ( import (
"bytes" "bytes"
"encoding/binary"
"net/http" "net/http"
"testing" "testing"
...@@ -27,7 +26,7 @@ func TestPinChunkHandler(t *testing.T) { ...@@ -27,7 +26,7 @@ func TestPinChunkHandler(t *testing.T) {
resource := func(addr swarm.Address) string { return "/bzz-chunk/" + addr.String() } resource := func(addr swarm.Address) string { return "/bzz-chunk/" + addr.String() }
hash := swarm.MustParseHexAddress("aabbcc") hash := swarm.MustParseHexAddress("aabbcc")
data := []byte("bbaatt") data := []byte("bbaatt")
mockValidator := validator.NewMockValidator(hash, append(newSpan(uint64(len(data))), data...)) mockValidator := validator.NewMockValidator(hash, data)
tag := tags.NewTags() tag := tags.NewTags()
mockValidatingStorer := mock.NewValidatingStorer(mockValidator, tag) mockValidatingStorer := mock.NewValidatingStorer(mockValidator, tag)
debugTestServer := newTestServer(t, testServerOptions{ debugTestServer := newTestServer(t, testServerOptions{
...@@ -149,7 +148,7 @@ func TestPinChunkHandler(t *testing.T) { ...@@ -149,7 +148,7 @@ func TestPinChunkHandler(t *testing.T) {
// post another chunk // post another chunk
hash2 := swarm.MustParseHexAddress("ddeeff") hash2 := swarm.MustParseHexAddress("ddeeff")
data2 := []byte("eagle") data2 := []byte("eagle")
mockValidator.AddPair(hash2, append(newSpan(uint64(len(data2))), data2...)) mockValidator.AddPair(hash2, data2)
jsonhttptest.ResponseDirect(t, bzzTestServer, http.MethodPost, resource(hash2), bytes.NewReader(data2), http.StatusOK, jsonhttp.StatusResponse{ jsonhttptest.ResponseDirect(t, bzzTestServer, http.MethodPost, resource(hash2), bytes.NewReader(data2), http.StatusOK, jsonhttp.StatusResponse{
Message: http.StatusText(http.StatusOK), Message: http.StatusText(http.StatusOK),
Code: http.StatusOK, Code: http.StatusOK,
...@@ -173,9 +172,3 @@ func TestPinChunkHandler(t *testing.T) { ...@@ -173,9 +172,3 @@ func TestPinChunkHandler(t *testing.T) {
}) })
}) })
} }
func newSpan(size uint64) []byte {
b := make([]byte, 8)
binary.LittleEndian.PutUint64(b, size)
return b
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment