[NOD-1208] Renamed NetAdapterMock to standalone.MinimalNetAdapter

This commit is contained in:
Mike Zak 2020-08-05 15:57:34 +03:00
parent ec03a094e5
commit 1a5d9fc65c
3 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
package netadaptermock
package standalone
import (
"github.com/kaspanet/kaspad/logger"

View File

@ -1,4 +1,4 @@
package netadaptermock
package standalone
import (
"sync"
@ -17,16 +17,16 @@ import (
"github.com/pkg/errors"
)
// NetAdapterMock allows tests and other tools to mockup a simple network adapter without implementing all the required
// supporting structures.
type NetAdapterMock struct {
// MinimalNetAdapter allows tests and other tools to use a simple network adapter without implementing
// all the required supporting structures.
type MinimalNetAdapter struct {
lock sync.Mutex
netAdapter *netadapter.NetAdapter
routesChan <-chan *Routes
}
// New creates a new instance of a NetAdapterMock
func New(cfg *config.Config) (*NetAdapterMock, error) {
// NewMinimalNetAdapter creates a new instance of a MinimalNetAdapter
func NewMinimalNetAdapter(cfg *config.Config) (*MinimalNetAdapter, error) {
netAdapter, err := netadapter.NewNetAdapter(cfg)
if err != nil {
return nil, errors.Wrap(err, "Error starting netAdapter")
@ -40,7 +40,7 @@ func New(cfg *config.Config) (*NetAdapterMock, error) {
return nil, errors.Wrap(err, "Error starting netAdapter")
}
return &NetAdapterMock{
return &MinimalNetAdapter{
lock: sync.Mutex{},
netAdapter: netAdapter,
routesChan: routesChan,
@ -51,7 +51,7 @@ func New(cfg *config.Config) (*NetAdapterMock, error) {
// To simplify usage the return type contains only two routes:
// OutgoingRoute - for all outgoing messages
// IncomingRoute - for all incoming messages (excluding handshake messages)
func (nam *NetAdapterMock) Connect(address string) (*Routes, error) {
func (nam *MinimalNetAdapter) Connect(address string) (*Routes, error) {
nam.lock.Lock()
defer nam.lock.Unlock()

View File

@ -1,4 +1,4 @@
package netadaptermock
package standalone
import (
"time"
@ -11,7 +11,7 @@ import (
"github.com/kaspanet/kaspad/wire"
)
// Routes holds the incoming and outgoing routes of a connection created by NetAdapterMock
// Routes holds the incoming and outgoing routes of a connection created by MinimalNetAdapter
type Routes struct {
netConnection *netadapter.NetConnection
IncomingRoute, OutgoingRoute *router.Route
@ -48,7 +48,7 @@ func (r *Routes) WaitForDisconnect(timeout time.Duration) error {
}
}
// Close closes all the routes in this Routes object
// Disconnect closes the connection behind the routes, thus closing all routes
func (r *Routes) Disconnect() {
r.netConnection.Disconnect()
}