aboutsummaryrefslogtreecommitdiffstats
path: root/core/test
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-12-26 15:23:54 +0800
committerGitHub <noreply@github.com>2018-12-26 15:23:54 +0800
commit39c02fe0f7c81491ea897fafcf32595d280bbdbe (patch)
tree1ac3d002de42bb7471624656713e331db55aaea2 /core/test
parent00416c9df2fec5398389863fb6f885a1fe11a6cc (diff)
downloadtangerine-consensus-39c02fe0f7c81491ea897fafcf32595d280bbdbe.tar.gz
tangerine-consensus-39c02fe0f7c81491ea897fafcf32595d280bbdbe.tar.zst
tangerine-consensus-39c02fe0f7c81491ea897fafcf32595d280bbdbe.zip
core: fix stuffs (#383)
* Merge core.Consensus constructors * Downgrade severity of logs * Refine logic to add blocks from pool to lattice * Add test.LaunchDummyReceiver
Diffstat (limited to 'core/test')
-rw-r--r--core/test/utils.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/test/utils.go b/core/test/utils.go
index 84c90a9..8a14ebf 100644
--- a/core/test/utils.go
+++ b/core/test/utils.go
@@ -18,6 +18,7 @@
package test
import (
+ "context"
"errors"
"fmt"
"math"
@@ -225,3 +226,21 @@ func VerifyDB(db db.Database) error {
}
return nil
}
+
+// LaunchDummyReceiver launches a go routine to receive and drop messages from
+// a network module. An optional context could be passed to stop the go routine.
+func LaunchDummyReceiver(
+ ctx context.Context, networkModule *Network) context.CancelFunc {
+ dummyCtx, dummyCancel := context.WithCancel(ctx)
+ go func() {
+ loop:
+ for {
+ select {
+ case <-dummyCtx.Done():
+ break loop
+ case <-networkModule.ReceiveChan():
+ }
+ }
+ }()
+ return dummyCancel
+}