Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLET Ismael
Goshimmer_without_tipselection
Commits
7238336f
Unverified
Commit
7238336f
authored
5 years ago
by
jonastheis
Browse files
Options
Downloads
Patches
Plain Diff
Adjust relay test to use new API wrapper
parent
a78b8b97
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/integration-tests/tester/api/api.go
+19
-2
19 additions, 2 deletions
tools/integration-tests/tester/api/api.go
tools/integration-tests/tester/tests/relaymessage_test.go
+5
-38
5 additions, 38 deletions
tools/integration-tests/tester/tests/relaymessage_test.go
with
24 additions
and
40 deletions
tools/integration-tests/tester/api/api.go
+
19
−
2
View file @
7238336f
...
@@ -22,6 +22,7 @@ var (
...
@@ -22,6 +22,7 @@ var (
const
(
const
(
routeBroadcastData
=
"broadcastData"
routeBroadcastData
=
"broadcastData"
routeGetNeighbors
=
"getNeighbors"
routeGetNeighbors
=
"getNeighbors"
routeGetMessageByHash
=
"getMessageByHash"
contentTypeJSON
=
"application/json"
contentTypeJSON
=
"application/json"
)
)
...
@@ -159,3 +160,19 @@ func (api *Api) GetNeighbors(knownPeers bool) (*GetNeighborResponse, error) {
...
@@ -159,3 +160,19 @@ func (api *Api) GetNeighbors(knownPeers bool) (*GetNeighborResponse, error) {
return
res
,
nil
return
res
,
nil
}
}
func
(
api
*
Api
)
GetMessageByHash
(
hashes
[]
string
)
(
*
GetMessageByHashResponse
,
error
)
{
res
:=
&
GetMessageByHashResponse
{}
err
:=
api
.
do
(
http
.
MethodPost
,
routeGetMessageByHash
,
&
GetMessageByHashRequest
{
Hashes
:
hashes
},
res
,
)
if
err
!=
nil
{
return
nil
,
err
}
return
res
,
nil
}
This diff is collapsed.
Click to expand it.
tools/integration-tests/tester/tests/relaymessage_test.go
+
5
−
38
View file @
7238336f
...
@@ -5,9 +5,10 @@ import (
...
@@ -5,9 +5,10 @@ import (
"testing"
"testing"
"time"
"time"
"github.com/iotaledger/goshimmer/tools/integration-tests/tester/framework"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/iotaledger/goshimmer/tools/integration-tests/tester/framework"
)
)
var
f
*
framework
.
Framework
var
f
*
framework
.
Framework
...
@@ -25,12 +26,10 @@ func TestRelayMessages(t *testing.T) {
...
@@ -25,12 +26,10 @@ func TestRelayMessages(t *testing.T) {
// create messages on random peers
// create messages on random peers
for
i
:=
0
;
i
<
numMessages
;
i
++
{
for
i
:=
0
;
i
<
numMessages
;
i
++
{
req
:=
BroadcastDataRequest
{
Data
:
"Test"
}
hash
,
err
:=
f
.
RandomPeer
()
.
BroadcastData
(
"Test"
)
resp
:=
new
(
BroadcastDataResponse
)
err
:=
f
.
HttpPost
(
f
.
RandomPeer
(),
"broadcastData"
,
req
,
resp
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
hashes
[
i
]
=
resp
.
H
ash
hashes
[
i
]
=
h
ash
}
}
// wait for messages to be gossiped
// wait for messages to be gossiped
...
@@ -38,9 +37,7 @@ func TestRelayMessages(t *testing.T) {
...
@@ -38,9 +37,7 @@ func TestRelayMessages(t *testing.T) {
// check for messages on every peer
// check for messages on every peer
for
_
,
peer
:=
range
f
.
Peers
()
{
for
_
,
peer
:=
range
f
.
Peers
()
{
req
:=
GetMessageByHashRequest
{
Hashes
:
hashes
}
resp
,
err
:=
peer
.
GetMessageByHash
(
hashes
)
resp
:=
new
(
GetMessageByHashResponse
)
err
:=
f
.
HttpPost
(
peer
,
"getMessageByHash"
,
req
,
resp
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// check for the count of messages
// check for the count of messages
...
@@ -60,33 +57,3 @@ func TestRelayMessages(t *testing.T) {
...
@@ -60,33 +57,3 @@ func TestRelayMessages(t *testing.T) {
}
}
}
}
}
}
// TODO: there should be a nice way to handle all those API endpoints
type
BroadcastDataResponse
struct
{
Hash
string
`json:"hash,omitempty"`
Error
string
`json:"error,omitempty"`
}
type
BroadcastDataRequest
struct
{
Data
string
`json:"data"`
}
type
GetMessageByHashResponse
struct
{
Messages
[]
Message
`json:"messages,omitempty"`
Error
string
`json:"error,omitempty"`
}
type
GetMessageByHashRequest
struct
{
Hashes
[]
string
`json:"hashes"`
}
type
Message
struct
{
MessageId
string
`json:"messageId,omitempty"`
TrunkTransactionId
string
`json:"trunkTransactionId,omitempty"`
BranchTransactionId
string
`json:"branchTransactionId,omitempty"`
IssuerPublicKey
string
`json:"issuerPublicKey,omitempty"`
IssuingTime
string
`json:"issuingTime,omitempty"`
SequenceNumber
uint64
`json:"sequenceNumber,omitempty"`
Payload
string
`json:"payload,omitempty"`
Signature
string
`json:"signature,omitempty"`
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment