Skip to content

Commit

Permalink
feat: introduce min bucket depth (#4331)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekucci authored Sep 22, 2023
1 parent 1f84ef4 commit 25eb233
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/patches/postage_api.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
80c80
< Depth uint8 `map:"depth" validate:"required,min=24"`
---
> Depth uint8 `map:"depth" validate:"required"`
1 change: 1 addition & 0 deletions .github/workflows/beekeeper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
run: |
# patch pkg/postage/postagecontract/contract.go .github/patches/postagecontract.patch
# patch pkg/postage/service.go .github/patches/postageservice.patch
patch pkg/api/postage.go .github/patches/postage_api.patch
make binary
mv dist/bee bee-1
- name: Apply patches and build - 2
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/postage.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *Service) postageCreateHandler(w http.ResponseWriter, r *http.Request) {

paths := struct {
Amount *big.Int `map:"amount" validate:"required"`
Depth uint8 `map:"depth" validate:"required"`
Depth uint8 `map:"depth" validate:"required,min=24"`
}{}
if response := s.mapStructure(mux.Vars(r), &paths); response != nil {
response("invalid path params", logger, w)
Expand Down
14 changes: 10 additions & 4 deletions pkg/api/postage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestPostageCreateStamp(t *testing.T) {

batchID := []byte{1, 2, 3, 4}
initialBalance := int64(1000)
depth := uint8(1)
depth := uint8(24)
label := "label"
txHash := common.HexToHash("0x1234")
createBatch := func(amount int64, depth uint8, label string) string {
Expand Down Expand Up @@ -139,7 +139,13 @@ func TestPostageCreateStamp(t *testing.T) {
jsonhttptest.Request(t, ts, http.MethodPost, "/stamps/1000/9", http.StatusBadRequest,
jsonhttptest.WithExpectedJSONResponse(&jsonhttp.StatusResponse{
Code: http.StatusBadRequest,
Message: "invalid depth",
Message: "invalid path params",
Reasons: []jsonhttp.Reason{
{
Field: "depth",
Error: "want min:24",
},
},
}),
)
})
Expand Down Expand Up @@ -793,7 +799,7 @@ func TestPostageAccessHandler(t *testing.T) {
{
name: "create batch ok",
method: http.MethodPost,
url: "/stamps/1000/17?label=test",
url: "/stamps/1000/24?label=test",
respCode: http.StatusCreated,
resp: &api.PostageCreateResponse{
BatchID: batchOk,
Expand Down Expand Up @@ -826,7 +832,7 @@ func TestPostageAccessHandler(t *testing.T) {
{
name: "create batch not ok",
method: http.MethodPost,
url: "/stamps/1000/17?label=test",
url: "/stamps/1000/24?label=test",
respCode: http.StatusTooManyRequests,
resp: &jsonhttp.StatusResponse{
Code: http.StatusTooManyRequests,
Expand Down

0 comments on commit 25eb233

Please sign in to comment.