Skip to content

Commit

Permalink
fix: soc chunk from data
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill committed Feb 28, 2024
1 parent 9e3426b commit 9a7c4b3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/beekeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ jobs:
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks=ci-full-connectivity; do echo "waiting for full connectivity..."; sleep .3; done'
- name: Test redundancy
id: redundancy
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-redundancy; do echo "waiting for redundancy..."; sleep .3; done'
#run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-redundancy; do echo "waiting for redundancy..."; sleep .3; done'
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-redundancy
- name: Collect debug artifacts
if: failure()
run: |
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ func (s *Service) chunkUploadHandler(w http.ResponseWriter, r *http.Request) {
jsonhttp.InternalServerError(ow, "create chunk error")
return
}

if !soc.Valid(chunk) {
logger.Debug("chunk upload: invalid soc chunk")
logger.Error(nil, "chunk upload: create chunk error")
jsonhttp.InternalServerError(ow, "create chunk error")
return
}
}

err = putter.Put(r.Context(), chunk)
Expand Down
35 changes: 35 additions & 0 deletions pkg/soc/soc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,41 @@ func TestNew(t *testing.T) {
}
}

func TestReplica(t *testing.T) {
sig, err := hex.DecodeString("5acd384febc133b7b245e5ddc62d82d2cded9182d2716126cd8844509af65a053deb418208027f548e3e88343af6f84a8772fb3cebc0a1833a0ea7ec0c1348311b")
if err != nil {
t.Fatal(err)
}

payload := []byte("foo")
ch, err := cac.New(payload)
if err != nil {
t.Fatal(err)
}

id := make([]byte, swarm.HashSize)
s, err := soc.NewSigned(id, ch, swarm.ReplicasOwner, sig)
if err != nil {
t.Fatal(err)
}

ch, err = s.Chunk()
if err != nil {
t.Fatal(err)
}
sch, err := soc.FromChunk(swarm.NewChunk(swarm.EmptyAddress, ch.Data()))
if err != nil {
t.Fatal(err)
}
ch, err = sch.Chunk()
if err != nil {
t.Fatal(err)
}
if !soc.Valid(ch) {
t.Fatal("invalid soc chunk")
}
}

func TestNewSigned(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 9a7c4b3

Please sign in to comment.