Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce min bucket depth #4331

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading