-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2021 The Swarm Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package debugapi | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/ethersphere/bee/pkg/jsonhttp" | ||
) | ||
|
||
func (s *Service) reserveStateHandler(w http.ResponseWriter, r *http.Request) { | ||
jsonhttp.OK(w, s.batchStore.GetReserveState()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2021 The Swarm Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package debugapi_test | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest" | ||
"github.com/ethersphere/bee/pkg/postage" | ||
"github.com/ethersphere/bee/pkg/postage/batchstore/mock" | ||
) | ||
|
||
func TestReservestate(t *testing.T) { | ||
|
||
ts := newTestServer(t, testServerOptions{ | ||
BatchStore: mock.New(mock.WithReserveState(&postage.Reservestate{ | ||
Radius: 5, | ||
})), | ||
}) | ||
|
||
t.Run("ok", func(t *testing.T) { | ||
jsonhttptest.Request(t, ts.Client, http.MethodGet, "/reservestate", http.StatusOK, | ||
jsonhttptest.WithExpectedJSONResponse(&postage.Reservestate{ | ||
Radius: 5, | ||
}), | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2021 The Swarm Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package postage | ||
|
||
import "math/big" | ||
|
||
type Reservestate struct { | ||
Radius uint8 `json:"radius"` | ||
Available int64 `json:"available"` | ||
Outer *big.Int `json:"outer"` // lower value limit for outer layer = the further half of chunks | ||
Inner *big.Int `json:"inner"` | ||
} |