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
9ea9ca2e
Commit
9ea9ca2e
authored
5 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
update FPC test
parent
8b5497bf
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
plugins/analysis/dashboard/fpc_livefeed.go
+6
-4
6 additions, 4 deletions
plugins/analysis/dashboard/fpc_livefeed.go
plugins/analysis/dashboard/fpc_livefeed_test.go
+5
-5
5 additions, 5 deletions
plugins/analysis/dashboard/fpc_livefeed_test.go
with
11 additions
and
9 deletions
plugins/analysis/dashboard/fpc_livefeed.go
+
6
−
4
View file @
9ea9ca2e
...
@@ -55,7 +55,7 @@ func runFPCLiveFeed() {
...
@@ -55,7 +55,7 @@ func runFPCLiveFeed() {
onFPCHeartbeatReceived
:=
events
.
NewClosure
(
func
(
hb
*
packet
.
FPCHeartbeat
)
{
onFPCHeartbeatReceived
:=
events
.
NewClosure
(
func
(
hb
*
packet
.
FPCHeartbeat
)
{
select
{
select
{
case
<-
newMsgRateLimiter
.
C
:
case
<-
newMsgRateLimiter
.
C
:
fpcLiveFeedWorkerPool
.
TrySubmit
(
createFPCUpdate
(
hb
))
fpcLiveFeedWorkerPool
.
TrySubmit
(
createFPCUpdate
(
hb
,
true
))
default
:
default
:
}
}
})
})
...
@@ -71,7 +71,7 @@ func runFPCLiveFeed() {
...
@@ -71,7 +71,7 @@ func runFPCLiveFeed() {
},
shutdown
.
PriorityDashboard
)
},
shutdown
.
PriorityDashboard
)
}
}
func
createFPCUpdate
(
hb
*
packet
.
FPCHeartbeat
)
*
FPCUpdate
{
func
createFPCUpdate
(
hb
*
packet
.
FPCHeartbeat
,
recordEvent
bool
)
*
FPCUpdate
{
// prepare the update
// prepare the update
conflicts
:=
make
(
map
[
string
]
Conflict
)
conflicts
:=
make
(
map
[
string
]
Conflict
)
nodeID
:=
base58
.
Encode
(
hb
.
OwnID
)
nodeID
:=
base58
.
Encode
(
hb
.
OwnID
)
...
@@ -90,9 +90,11 @@ func createFPCUpdate(hb *packet.FPCHeartbeat) *FPCUpdate {
...
@@ -90,9 +90,11 @@ func createFPCUpdate(hb *packet.FPCHeartbeat) *FPCUpdate {
conflicts
[
ID
]
=
newConflict
()
conflicts
[
ID
]
=
newConflict
()
conflicts
[
ID
]
.
NodesView
[
nodeID
]
=
newVoteContext
conflicts
[
ID
]
.
NodesView
[
nodeID
]
=
newVoteContext
if
recordEvent
{
// update recorded events
// update recorded events
recordedConflicts
.
Update
(
ID
,
Conflict
{
NodesView
:
map
[
string
]
voteContext
{
nodeID
:
newVoteContext
}})
recordedConflicts
.
Update
(
ID
,
Conflict
{
NodesView
:
map
[
string
]
voteContext
{
nodeID
:
newVoteContext
}})
}
}
}
return
&
FPCUpdate
{
return
&
FPCUpdate
{
Conflicts
:
conflicts
,
Conflicts
:
conflicts
,
...
...
This diff is collapsed.
Click to expand it.
plugins/analysis/dashboard/fpc_livefeed_test.go
+
5
−
5
View file @
9ea9ca2e
...
@@ -2,19 +2,19 @@ package dashboard
...
@@ -2,19 +2,19 @@ package dashboard
import
(
import
(
"crypto/sha256"
"crypto/sha256"
"fmt"
"testing"
"testing"
"time"
"time"
"github.com/iotaledger/goshimmer/packages/vote"
"github.com/iotaledger/goshimmer/packages/vote"
"github.com/iotaledger/goshimmer/plugins/analysis/packet"
"github.com/iotaledger/goshimmer/plugins/analysis/packet"
"github.com/mr-tron/base58/base58"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
// TestCreateFPCUpdate checks that given a FPC heartbeat, the returned FPCUpdate is ok.
// TestCreateFPCUpdate checks that given a FPC heartbeat, the returned FPCUpdate is ok.
func
TestCreateFPCUpdate
(
t
*
testing
.
T
)
{
func
TestCreateFPCUpdate
(
t
*
testing
.
T
)
{
ownID
:=
sha256
.
Sum256
([]
byte
{
'A'
})
ownID
:=
sha256
.
Sum256
([]
byte
{
'A'
})
short
OwnID
:=
fmt
.
Sprintf
(
"%x"
,
ownID
[
:
8
])
base58
OwnID
:=
base58
.
Encode
(
ownID
[
:
])
// create a FPCHeartbeat
// create a FPCHeartbeat
hbTest
:=
&
packet
.
FPCHeartbeat
{
hbTest
:=
&
packet
.
FPCHeartbeat
{
...
@@ -38,8 +38,8 @@ func TestCreateFPCUpdate(t *testing.T) {
...
@@ -38,8 +38,8 @@ func TestCreateFPCUpdate(t *testing.T) {
Conflicts
:
map
[
string
]
Conflict
{
Conflicts
:
map
[
string
]
Conflict
{
"one"
:
{
"one"
:
{
NodesView
:
map
[
string
]
voteContext
{
NodesView
:
map
[
string
]
voteContext
{
short
OwnID
:
{
base58
OwnID
:
{
NodeID
:
short
OwnID
,
NodeID
:
base58
OwnID
,
Rounds
:
3
,
Rounds
:
3
,
Opinions
:
[]
int32
{
disliked
,
liked
,
disliked
},
Opinions
:
[]
int32
{
disliked
,
liked
,
disliked
},
Status
:
liked
,
Status
:
liked
,
...
@@ -50,6 +50,6 @@ func TestCreateFPCUpdate(t *testing.T) {
...
@@ -50,6 +50,6 @@ func TestCreateFPCUpdate(t *testing.T) {
}
}
// check that createFPCUpdate returns a matching FPCMsg
// check that createFPCUpdate returns a matching FPCMsg
require
.
Equal
(
t
,
want
,
createFPCUpdate
(
hbTest
))
require
.
Equal
(
t
,
want
,
createFPCUpdate
(
hbTest
,
false
))
}
}
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