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
37733d5f
Unverified
Commit
37733d5f
authored
5 years ago
by
jonastheis
Browse files
Options
Downloads
Patches
Plain Diff
Added relay message test
parent
6417afe0
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/tests/example_test.go
+0
-26
0 additions, 26 deletions
tools/integration-tests/tester/tests/example_test.go
tools/integration-tests/tester/tests/relaymessage_test.go
+92
-0
92 additions, 0 deletions
tools/integration-tests/tester/tests/relaymessage_test.go
with
92 additions
and
26 deletions
tools/integration-tests/tester/tests/example_test.go
deleted
100644 → 0
+
0
−
26
View file @
6417afe0
package
tests
import
(
"fmt"
"os"
"testing"
"github.com/iotaledger/goshimmer/tools/integration-tests/tester/framework"
"github.com/stretchr/testify/assert"
)
var
f
*
framework
.
Framework
func
TestMain
(
m
*
testing
.
M
)
{
f
=
framework
.
New
()
// call the tests
os
.
Exit
(
m
.
Run
())
}
func
TestExample
(
t
*
testing
.
T
)
{
fmt
.
Println
(
"This is an independent test."
)
fmt
.
Printf
(
"There are %d peers in the Docker network available.
\n
"
,
len
(
f
.
Peers
()))
assert
.
Equal
(
t
,
6
,
len
(
f
.
Peers
()))
}
This diff is collapsed.
Click to expand it.
tools/integration-tests/tester/tests/relaymessage_test.go
0 → 100644
+
92
−
0
View file @
37733d5f
package
tests
import
(
"os"
"testing"
"time"
"github.com/iotaledger/goshimmer/tools/integration-tests/tester/framework"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var
f
*
framework
.
Framework
func
TestMain
(
m
*
testing
.
M
)
{
f
=
framework
.
New
()
// call the tests
os
.
Exit
(
m
.
Run
())
}
func
TestRelayMessages
(
t
*
testing
.
T
)
{
numMessages
:=
100
hashes
:=
make
([]
string
,
numMessages
)
// create messages on random peers
for
i
:=
0
;
i
<
numMessages
;
i
++
{
req
:=
BroadcastDataRequest
{
Data
:
"Test"
}
resp
:=
new
(
BroadcastDataResponse
)
err
:=
f
.
HttpPost
(
f
.
RandomPeer
(),
"broadcastData"
,
req
,
resp
)
require
.
NoError
(
t
,
err
)
hashes
[
i
]
=
resp
.
Hash
}
// wait for messages to be gossiped
time
.
Sleep
(
5
*
time
.
Second
)
// check for messages on every peer
for
_
,
peer
:=
range
f
.
Peers
()
{
req
:=
GetMessageByHashRequest
{
Hashes
:
hashes
}
resp
:=
new
(
GetMessageByHashResponse
)
err
:=
f
.
HttpPost
(
peer
,
"getMessageByHash"
,
req
,
resp
)
require
.
NoError
(
t
,
err
)
// check for the count of messages
assert
.
Equal
(
t
,
numMessages
,
len
(
resp
.
Messages
))
// check that all messages are present in response
outer
:
for
_
,
hash
:=
range
hashes
{
for
_
,
msg
:=
range
resp
.
Messages
{
// if message found skip to next
if
msg
.
MessageId
==
hash
{
continue
outer
}
}
t
.
Errorf
(
"MessageId=%s not found in peer %s."
,
hash
,
peer
.
String
())
}
}
}
// 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