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
0a861f1a
Unverified
Commit
0a861f1a
authored
Jun 16, 2021
by
Ralph Pichler
Committed by
GitHub
Jun 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: don't disconnect on non-swap peers (#2102)
parent
e95b245b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
36 deletions
+1
-36
chain.go
pkg/node/chain.go
+0
-1
swap.go
pkg/settlement/swap/swap.go
+1
-9
swap_test.go
pkg/settlement/swap/swap_test.go
+0
-26
No files found.
pkg/node/chain.go
View file @
0a861f1a
...
@@ -245,7 +245,6 @@ func InitSwap(
...
@@ -245,7 +245,6 @@ func InitSwap(
swapAddressBook
,
swapAddressBook
,
networkID
,
networkID
,
cashoutService
,
cashoutService
,
p2ps
,
accounting
,
accounting
,
)
)
...
...
pkg/settlement/swap/swap.go
View file @
0a861f1a
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/crypto"
"github.com/ethersphere/bee/pkg/crypto"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/settlement"
"github.com/ethersphere/bee/pkg/settlement"
"github.com/ethersphere/bee/pkg/settlement/swap/chequebook"
"github.com/ethersphere/bee/pkg/settlement/swap/chequebook"
"github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol"
"github.com/ethersphere/bee/pkg/settlement/swap/swapprotocol"
...
@@ -58,13 +57,12 @@ type Service struct {
...
@@ -58,13 +57,12 @@ type Service struct {
chequebook
chequebook
.
Service
chequebook
chequebook
.
Service
chequeStore
chequebook
.
ChequeStore
chequeStore
chequebook
.
ChequeStore
cashout
chequebook
.
CashoutService
cashout
chequebook
.
CashoutService
p2pService
p2p
.
Service
addressbook
Addressbook
addressbook
Addressbook
networkID
uint64
networkID
uint64
}
}
// New creates a new swap Service.
// New creates a new swap Service.
func
New
(
proto
swapprotocol
.
Interface
,
logger
logging
.
Logger
,
store
storage
.
StateStorer
,
chequebook
chequebook
.
Service
,
chequeStore
chequebook
.
ChequeStore
,
addressbook
Addressbook
,
networkID
uint64
,
cashout
chequebook
.
CashoutService
,
p2pService
p2p
.
Service
,
accounting
settlement
.
Accounting
)
*
Service
{
func
New
(
proto
swapprotocol
.
Interface
,
logger
logging
.
Logger
,
store
storage
.
StateStorer
,
chequebook
chequebook
.
Service
,
chequeStore
chequebook
.
ChequeStore
,
addressbook
Addressbook
,
networkID
uint64
,
cashout
chequebook
.
CashoutService
,
accounting
settlement
.
Accounting
)
*
Service
{
return
&
Service
{
return
&
Service
{
proto
:
proto
,
proto
:
proto
,
logger
:
logger
,
logger
:
logger
,
...
@@ -75,7 +73,6 @@ func New(proto swapprotocol.Interface, logger logging.Logger, store storage.Stat
...
@@ -75,7 +73,6 @@ func New(proto swapprotocol.Interface, logger logging.Logger, store storage.Stat
addressbook
:
addressbook
,
addressbook
:
addressbook
,
networkID
:
networkID
,
networkID
:
networkID
,
cashout
:
cashout
,
cashout
:
cashout
,
p2pService
:
p2pService
,
accounting
:
accounting
,
accounting
:
accounting
,
}
}
}
}
...
@@ -134,11 +131,6 @@ func (s *Service) Pay(ctx context.Context, peer swarm.Address, amount *big.Int)
...
@@ -134,11 +131,6 @@ func (s *Service) Pay(ctx context.Context, peer swarm.Address, amount *big.Int)
return
return
}
}
if
!
known
{
if
!
known
{
s
.
logger
.
Warningf
(
"disconnecting non-swap peer %v"
,
peer
)
err
=
s
.
p2pService
.
Disconnect
(
peer
)
if
err
!=
nil
{
return
}
err
=
ErrUnknownBeneficary
err
=
ErrUnknownBeneficary
return
return
}
}
...
...
pkg/settlement/swap/swap_test.go
View file @
0a861f1a
...
@@ -15,7 +15,6 @@ import (
...
@@ -15,7 +15,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/crypto"
"github.com/ethersphere/bee/pkg/crypto"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/logging"
mockp2p
"github.com/ethersphere/bee/pkg/p2p/mock"
"github.com/ethersphere/bee/pkg/settlement/swap"
"github.com/ethersphere/bee/pkg/settlement/swap"
"github.com/ethersphere/bee/pkg/settlement/swap/chequebook"
"github.com/ethersphere/bee/pkg/settlement/swap/chequebook"
mockchequebook
"github.com/ethersphere/bee/pkg/settlement/swap/chequebook/mock"
mockchequebook
"github.com/ethersphere/bee/pkg/settlement/swap/chequebook/mock"
...
@@ -212,7 +211,6 @@ func TestReceiveCheque(t *testing.T) {
...
@@ -212,7 +211,6 @@ func TestReceiveCheque(t *testing.T) {
addressbook
,
addressbook
,
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
observer
,
observer
,
)
)
...
@@ -286,7 +284,6 @@ func TestReceiveChequeReject(t *testing.T) {
...
@@ -286,7 +284,6 @@ func TestReceiveChequeReject(t *testing.T) {
addressbook
,
addressbook
,
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
observer
,
observer
,
)
)
...
@@ -342,7 +339,6 @@ func TestReceiveChequeWrongChequebook(t *testing.T) {
...
@@ -342,7 +339,6 @@ func TestReceiveChequeWrongChequebook(t *testing.T) {
addressbook
,
addressbook
,
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
observer
,
observer
,
)
)
...
@@ -406,7 +402,6 @@ func TestPay(t *testing.T) {
...
@@ -406,7 +402,6 @@ func TestPay(t *testing.T) {
addressbook
,
addressbook
,
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
observer
,
observer
,
)
)
...
@@ -449,7 +444,6 @@ func TestPayIssueError(t *testing.T) {
...
@@ -449,7 +444,6 @@ func TestPayIssueError(t *testing.T) {
addressbook
,
addressbook
,
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
nil
,
nil
,
)
)
...
@@ -491,7 +485,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
...
@@ -491,7 +485,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
observer
:=
newTestObserver
()
observer
:=
newTestObserver
()
var
disconnectCalled
bool
swapService
:=
swap
.
New
(
swapService
:=
swap
.
New
(
&
swapProtocolMock
{},
&
swapProtocolMock
{},
logger
,
logger
,
...
@@ -501,15 +494,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
...
@@ -501,15 +494,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
addressbook
,
addressbook
,
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(
mockp2p
.
WithDisconnectFunc
(
func
(
disconnectPeer
swarm
.
Address
)
error
{
if
!
peer
.
Equal
(
disconnectPeer
)
{
t
.
Fatalf
(
"disconnecting wrong peer. wanted %v, got %v"
,
peer
,
disconnectPeer
)
}
disconnectCalled
=
true
return
nil
}),
),
observer
,
observer
,
)
)
...
@@ -517,7 +501,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
...
@@ -517,7 +501,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
select
{
select
{
case
call
:=
<-
observer
.
sentCalled
:
case
call
:=
<-
observer
.
sentCalled
:
if
!
call
.
peer
.
Equal
(
peer
)
{
if
!
call
.
peer
.
Equal
(
peer
)
{
t
.
Fatalf
(
"observer called with wrong peer. got %v, want %v"
,
call
.
peer
,
peer
)
t
.
Fatalf
(
"observer called with wrong peer. got %v, want %v"
,
call
.
peer
,
peer
)
}
}
...
@@ -528,10 +511,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
...
@@ -528,10 +511,6 @@ func TestPayUnknownBeneficiary(t *testing.T) {
case
<-
time
.
After
(
time
.
Second
)
:
case
<-
time
.
After
(
time
.
Second
)
:
t
.
Fatal
(
"expected observer to be called"
)
t
.
Fatal
(
"expected observer to be called"
)
}
}
if
!
disconnectCalled
{
t
.
Fatal
(
"disconnect was not called"
)
}
}
}
func
TestHandshake
(
t
*
testing
.
T
)
{
func
TestHandshake
(
t
*
testing
.
T
)
{
...
@@ -560,7 +539,6 @@ func TestHandshake(t *testing.T) {
...
@@ -560,7 +539,6 @@ func TestHandshake(t *testing.T) {
},
},
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
nil
,
nil
,
)
)
...
@@ -600,7 +578,6 @@ func TestHandshakeNewPeer(t *testing.T) {
...
@@ -600,7 +578,6 @@ func TestHandshakeNewPeer(t *testing.T) {
},
},
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
nil
,
nil
,
)
)
...
@@ -631,7 +608,6 @@ func TestHandshakeWrongBeneficiary(t *testing.T) {
...
@@ -631,7 +608,6 @@ func TestHandshakeWrongBeneficiary(t *testing.T) {
&
addressbookMock
{},
&
addressbookMock
{},
networkID
,
networkID
,
&
cashoutMock
{},
&
cashoutMock
{},
mockp2p
.
New
(),
nil
,
nil
,
)
)
...
@@ -681,7 +657,6 @@ func TestCashout(t *testing.T) {
...
@@ -681,7 +657,6 @@ func TestCashout(t *testing.T) {
return
txHash
,
nil
return
txHash
,
nil
},
},
},
},
mockp2p
.
New
(),
nil
,
nil
,
)
)
...
@@ -728,7 +703,6 @@ func TestCashoutStatus(t *testing.T) {
...
@@ -728,7 +703,6 @@ func TestCashoutStatus(t *testing.T) {
return
expectedStatus
,
nil
return
expectedStatus
,
nil
},
},
},
},
mockp2p
.
New
(),
nil
,
nil
,
)
)
...
...
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