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