Skip to content
Snippets Groups Projects
Unverified Commit 3f2b29b7 authored by jonastheis's avatar jonastheis
Browse files

Adjust to merge

parent 9caf969b
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
) )
const ( const (
routeGetNeighbors = "getNeighbors" routeGetNeighbors = "autopeering/neighbors"
) )
// GetNeighbors gets the chosen/accepted neighbors. // GetNeighbors gets the chosen/accepted neighbors.
......
...@@ -26,15 +26,15 @@ const ( ...@@ -26,15 +26,15 @@ const (
func NewGoShimmerAPI(node string, httpClient ...http.Client) *GoShimmerAPI { func NewGoShimmerAPI(node string, httpClient ...http.Client) *GoShimmerAPI {
if len(httpClient) > 0 { if len(httpClient) > 0 {
return &GoShimmerAPI{node: node, httpClient: httpClient[0]} return &GoShimmerAPI{baseUrl: node, httpClient: httpClient[0]}
} }
return &GoShimmerAPI{node: node} return &GoShimmerAPI{baseUrl: node}
} }
// GoShimmerAPI is an API wrapper over the web API of GoShimmer. // GoShimmerAPI is an API wrapper over the web API of GoShimmer.
type GoShimmerAPI struct { type GoShimmerAPI struct {
httpClient http.Client httpClient http.Client
node string baseUrl string
jwt string jwt string
} }
...@@ -62,7 +62,7 @@ func interpretBody(res *http.Response, decodeTo interface{}) error { ...@@ -62,7 +62,7 @@ func interpretBody(res *http.Response, decodeTo interface{}) error {
case http.StatusInternalServerError: case http.StatusInternalServerError:
return fmt.Errorf("%w: %s", ErrInternalServerError, errRes.Error) return fmt.Errorf("%w: %s", ErrInternalServerError, errRes.Error)
case http.StatusNotFound: case http.StatusNotFound:
return fmt.Errorf("%w: %s", ErrNotFound, errRes.Error) return fmt.Errorf("%w: %s", ErrNotFound, res.Request.URL.String())
case http.StatusBadRequest: case http.StatusBadRequest:
return fmt.Errorf("%w: %s", ErrBadRequest, errRes.Error) return fmt.Errorf("%w: %s", ErrBadRequest, errRes.Error)
case http.StatusUnauthorized: case http.StatusUnauthorized:
...@@ -86,7 +86,7 @@ func (api *GoShimmerAPI) do(method string, route string, reqObj interface{}, res ...@@ -86,7 +86,7 @@ func (api *GoShimmerAPI) do(method string, route string, reqObj interface{}, res
} }
// construct request // construct request
req, err := http.NewRequest(method, fmt.Sprintf("%s/%s", api.node, route), func() io.Reader { req, err := http.NewRequest(method, fmt.Sprintf("%s/%s", api.baseUrl, route), func() io.Reader {
if data == nil { if data == nil {
return nil return nil
} }
...@@ -121,3 +121,7 @@ func (api *GoShimmerAPI) do(method string, route string, reqObj interface{}, res ...@@ -121,3 +121,7 @@ func (api *GoShimmerAPI) do(method string, route string, reqObj interface{}, res
} }
return nil return nil
} }
func (api *GoShimmerAPI) BaseUrl() string {
return api.baseUrl
}
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
) )
const ( const (
routeFindById = "findById" routeFindById = "message/findById"
) )
// FindMessageById finds messages by the given ids. The messages are returned in the same order as // FindMessageById finds messages by the given ids. The messages are returned in the same order as
......
...@@ -10,9 +10,9 @@ import ( ...@@ -10,9 +10,9 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
dockerclient "github.com/docker/docker/client" dockerclient "github.com/docker/docker/client"
"github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors"
"github.com/iotaledger/goshimmer/client" "github.com/iotaledger/goshimmer/client"
"github.com/iotaledger/goshimmer/plugins/webapi/autopeering"
) )
// Peer represents a GoShimmer node inside the Docker network // Peer represents a GoShimmer node inside the Docker network
...@@ -21,8 +21,8 @@ type Peer struct { ...@@ -21,8 +21,8 @@ type Peer struct {
ip net.IP ip net.IP
*client.GoShimmerAPI *client.GoShimmerAPI
dockerCli *dockerclient.Client dockerCli *dockerclient.Client
chosen []getNeighbors.Neighbor chosen []autopeering.Neighbor
accepted []getNeighbors.Neighbor accepted []autopeering.Neighbor
} }
// NewPeer creates a new instance of Peer with the given information. // NewPeer creates a new instance of Peer with the given information.
...@@ -45,11 +45,11 @@ func (p *Peer) TotalNeighbors() int { ...@@ -45,11 +45,11 @@ func (p *Peer) TotalNeighbors() int {
} }
// SetNeighbors sets the neighbors of the peer accordingly. // SetNeighbors sets the neighbors of the peer accordingly.
func (p *Peer) SetNeighbors(chosen, accepted []getNeighbors.Neighbor) { func (p *Peer) SetNeighbors(chosen, accepted []autopeering.Neighbor) {
p.chosen = make([]getNeighbors.Neighbor, len(chosen)) p.chosen = make([]autopeering.Neighbor, len(chosen))
copy(p.chosen, chosen) copy(p.chosen, chosen)
p.accepted = make([]getNeighbors.Neighbor, len(accepted)) p.accepted = make([]autopeering.Neighbor, len(accepted))
copy(p.accepted, accepted) copy(p.accepted, accepted)
} }
......
This diff is collapsed.
...@@ -6,8 +6,6 @@ import ( ...@@ -6,8 +6,6 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/payload"
) )
// TestRelayMessages checks whether messages are actually relayed/gossiped through the network // TestRelayMessages checks whether messages are actually relayed/gossiped through the network
...@@ -16,11 +14,11 @@ func TestRelayMessages(t *testing.T) { ...@@ -16,11 +14,11 @@ func TestRelayMessages(t *testing.T) {
numMessages := 100 numMessages := 100
ids := make([]string, numMessages) ids := make([]string, numMessages)
data := payload.NewData([]byte("Test")).Bytes() data := []byte("Test")
// create messages on random peers // create messages on random peers
for i := 0; i < numMessages; i++ { for i := 0; i < numMessages; i++ {
id, err := f.RandomPeer().BroadcastData(data) id, err := f.RandomPeer().Data(data)
require.NoError(t, err) require.NoError(t, err)
ids[i] = id ids[i] = id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment