Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
1dc35eab
Unverified
Commit
1dc35eab
authored
Feb 08, 2021
by
Ralph Pichler
Committed by
GitHub
Feb 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugapi: set received / sent to 0 if no settlements (#1213)
parent
ecbb71e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
settlements.go
pkg/debugapi/settlements.go
+4
-0
settlements_test.go
pkg/debugapi/settlements_test.go
+45
-0
No files found.
pkg/debugapi/settlements.go
View file @
1dc35eab
...
@@ -107,6 +107,8 @@ func (s *server) peerSettlementsHandler(w http.ResponseWriter, r *http.Request)
...
@@ -107,6 +107,8 @@ func (s *server) peerSettlementsHandler(w http.ResponseWriter, r *http.Request)
s
.
Logger
.
Errorf
(
"debug api: settlements peer: can't get peer %s received settlement"
,
peer
.
String
())
s
.
Logger
.
Errorf
(
"debug api: settlements peer: can't get peer %s received settlement"
,
peer
.
String
())
jsonhttp
.
InternalServerError
(
w
,
errCantSettlementsPeer
)
jsonhttp
.
InternalServerError
(
w
,
errCantSettlementsPeer
)
return
return
}
else
{
received
=
big
.
NewInt
(
0
)
}
}
}
}
...
@@ -121,6 +123,8 @@ func (s *server) peerSettlementsHandler(w http.ResponseWriter, r *http.Request)
...
@@ -121,6 +123,8 @@ func (s *server) peerSettlementsHandler(w http.ResponseWriter, r *http.Request)
s
.
Logger
.
Errorf
(
"debug api: settlements peer: can't get peer %s sent settlement"
,
peer
.
String
())
s
.
Logger
.
Errorf
(
"debug api: settlements peer: can't get peer %s sent settlement"
,
peer
.
String
())
jsonhttp
.
InternalServerError
(
w
,
errCantSettlementsPeer
)
jsonhttp
.
InternalServerError
(
w
,
errCantSettlementsPeer
)
return
return
}
else
{
sent
=
big
.
NewInt
(
0
)
}
}
}
}
...
...
pkg/debugapi/settlements_test.go
View file @
1dc35eab
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
"github.com/ethersphere/bee/pkg/settlement"
"github.com/ethersphere/bee/pkg/settlement/swap/mock"
"github.com/ethersphere/bee/pkg/settlement/swap/mock"
"github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/swarm"
)
)
...
@@ -112,6 +113,50 @@ func TestSettlementsPeers(t *testing.T) {
...
@@ -112,6 +113,50 @@ func TestSettlementsPeers(t *testing.T) {
)
)
}
}
func
TestSettlementsPeersNoSettlements
(
t
*
testing
.
T
)
{
peer
:=
"bff2c89e85e78c38bd89fca1acc996afb876c21bf5a8482ad798ce15f1c223fa"
noErrFunc
:=
func
(
swarm
.
Address
)
(
*
big
.
Int
,
error
)
{
return
big
.
NewInt
(
1000000000000000000
),
nil
}
errFunc
:=
func
(
swarm
.
Address
)
(
*
big
.
Int
,
error
)
{
return
nil
,
settlement
.
ErrPeerNoSettlements
}
t
.
Run
(
"no sent"
,
func
(
t
*
testing
.
T
)
{
testServer
:=
newTestServer
(
t
,
testServerOptions
{
SettlementOpts
:
[]
mock
.
Option
{
mock
.
WithSettlementSentFunc
(
errFunc
),
mock
.
WithSettlementRecvFunc
(
noErrFunc
),
},
})
jsonhttptest
.
Request
(
t
,
testServer
.
Client
,
http
.
MethodGet
,
"/settlements/"
+
peer
,
http
.
StatusOK
,
jsonhttptest
.
WithExpectedJSONResponse
(
debugapi
.
SettlementResponse
{
Peer
:
peer
,
SettlementSent
:
big
.
NewInt
(
0
),
SettlementReceived
:
big
.
NewInt
(
1000000000000000000
),
}),
)
})
t
.
Run
(
"no received"
,
func
(
t
*
testing
.
T
)
{
testServer
:=
newTestServer
(
t
,
testServerOptions
{
SettlementOpts
:
[]
mock
.
Option
{
mock
.
WithSettlementSentFunc
(
noErrFunc
),
mock
.
WithSettlementRecvFunc
(
errFunc
),
},
})
jsonhttptest
.
Request
(
t
,
testServer
.
Client
,
http
.
MethodGet
,
"/settlements/"
+
peer
,
http
.
StatusOK
,
jsonhttptest
.
WithExpectedJSONResponse
(
debugapi
.
SettlementResponse
{
Peer
:
peer
,
SettlementSent
:
big
.
NewInt
(
1000000000000000000
),
SettlementReceived
:
big
.
NewInt
(
0
),
}),
)
})
}
func
TestSettlementsPeersError
(
t
*
testing
.
T
)
{
func
TestSettlementsPeersError
(
t
*
testing
.
T
)
{
peer
:=
"bff2c89e85e78c38bd89fca1acc996afb876c21bf5a8482ad798ce15f1c223fa"
peer
:=
"bff2c89e85e78c38bd89fca1acc996afb876c21bf5a8482ad798ce15f1c223fa"
wantErr
:=
errors
.
New
(
"Error"
)
wantErr
:=
errors
.
New
(
"Error"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment