OSDN Git Service

Add network delay simulation in test (#359)
authoryahtoo <yahtoo.ma@gmail.com>
Fri, 26 Jul 2019 09:01:29 +0000 (17:01 +0800)
committerPaladz <yzhu101@uottawa.ca>
Fri, 26 Jul 2019 09:01:29 +0000 (17:01 +0800)
netsync/chainmgr/tool_test.go

index b9d661f..63b6a2f 100644 (file)
@@ -4,6 +4,7 @@ import (
        "errors"
        "math/rand"
        "net"
        "errors"
        "math/rand"
        "net"
+       "time"
 
        "github.com/tendermint/go-wire"
        "github.com/tendermint/tmlibs/flowrate"
 
        "github.com/tendermint/go-wire"
        "github.com/tendermint/tmlibs/flowrate"
@@ -84,6 +85,7 @@ func (p *P2PPeer) setAsync(b bool) {
 func (p *P2PPeer) postMan() {
        for msgBytes := range p.msgCh {
                msgType, msg, _ := decodeMessage(msgBytes)
 func (p *P2PPeer) postMan() {
        for msgBytes := range p.msgCh {
                msgType, msg, _ := decodeMessage(msgBytes)
+               time.Sleep(10 * time.Millisecond)
                p.remoteNode.processMsg(p.srcPeer, msgType, msg)
        }
 }
                p.remoteNode.processMsg(p.srcPeer, msgType, msg)
        }
 }