aboutsummaryrefslogtreecommitdiffstats
path: root/core/utils
diff options
context:
space:
mode:
Diffstat (limited to 'core/utils')
-rw-r--r--core/utils/utils.go2
-rw-r--r--core/utils/utils_test.go16
2 files changed, 10 insertions, 8 deletions
diff --git a/core/utils/utils.go b/core/utils/utils.go
index 1a372c7..dc29bdf 100644
--- a/core/utils/utils.go
+++ b/core/utils/utils.go
@@ -105,7 +105,7 @@ func VerifyDKGComplaint(
// channel of a network module. An context is required to stop the go routine
// automatically. An optinal message handler could be provided.
func LaunchDummyReceiver(
- ctx context.Context, recv <-chan interface{}, handler func(interface{})) (
+ ctx context.Context, recv <-chan types.Msg, handler func(types.Msg)) (
context.CancelFunc, <-chan struct{}) {
var (
dummyCtx, dummyCancel = context.WithCancel(ctx)
diff --git a/core/utils/utils_test.go b/core/utils/utils_test.go
index c3afea9..c6f8543 100644
--- a/core/utils/utils_test.go
+++ b/core/utils/utils_test.go
@@ -121,14 +121,16 @@ func (s *UtilsTestSuite) TestDummyReceiver() {
for i := 0; i < msgCount; i++ {
fakeMsgs = append(fakeMsgs, i)
}
- launchDummySender := func(msgs []int, inputChan chan<- interface{}) {
+ launchDummySender := func(msgs []int, inputChan chan<- types.Msg) {
finished := make(chan struct{}, 1)
go func() {
defer func() {
finished <- struct{}{}
}()
for _, v := range msgs {
- inputChan <- v
+ inputChan <- types.Msg{
+ Payload: v,
+ }
}
}()
select {
@@ -137,17 +139,17 @@ func (s *UtilsTestSuite) TestDummyReceiver() {
s.Require().FailNow("unable to deliver all messages in time")
}
}
- checkBuffer := func(sent []int, buff []interface{}) {
+ checkBuffer := func(sent []int, buff []types.Msg) {
s.Require().Len(buff, len(sent))
for i := range sent {
- s.Require().Equal(sent[i], buff[i].(int))
+ s.Require().Equal(sent[i], buff[i].Payload.(int))
}
}
// Basic scenario: a dummy receiver with caching enabled.
- recv := make(chan interface{})
- buff := []interface{}{}
+ recv := make(chan types.Msg)
+ buff := []types.Msg{}
cancel, finished := LaunchDummyReceiver(
- context.Background(), recv, func(msg interface{}) {
+ context.Background(), recv, func(msg types.Msg) {
buff = append(buff, msg)
})
launchDummySender(fakeMsgs, recv)