mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-30 02:50:23 +00:00
switch test modification
This commit is contained in:
@@ -320,7 +320,7 @@ FOR_LOOP:
|
||||
c.Logger.Debug("Send Ping")
|
||||
wire.WriteByte(packetTypePing, c.bufWriter, &n, &err)
|
||||
c.sendMonitor.Update(int(n))
|
||||
// c.flush
|
||||
// should be c.flush
|
||||
go c.flush()
|
||||
c.Logger.Debug("Starting pong timer")
|
||||
c.pongTimer.Set()
|
||||
|
||||
@@ -128,14 +128,17 @@ func TestSwitches(t *testing.T) {
|
||||
ch0Msg := "channel zero"
|
||||
ch1Msg := "channel foo"
|
||||
ch2Msg := "channel bar"
|
||||
ch3Msg := "channel baz"
|
||||
|
||||
s1.Broadcast(byte(0x00), ch0Msg)
|
||||
s1.Broadcast(byte(0x01), ch1Msg)
|
||||
s1.Broadcast(byte(0x02), ch2Msg)
|
||||
s1.TryBroadcast(byte(0x03), ch3Msg)
|
||||
|
||||
assertMsgReceivedWithTimeout(t, ch0Msg, byte(0x00), s2.Reactor("foo").(*TestReactor), 10*time.Millisecond, 5*time.Second)
|
||||
assertMsgReceivedWithTimeout(t, ch1Msg, byte(0x01), s2.Reactor("foo").(*TestReactor), 10*time.Millisecond, 5*time.Second)
|
||||
assertMsgReceivedWithTimeout(t, ch2Msg, byte(0x02), s2.Reactor("bar").(*TestReactor), 10*time.Millisecond, 5*time.Second)
|
||||
assertMsgReceivedWithTimeout(t, ch3Msg, byte(0x03), s2.Reactor("bar").(*TestReactor), 10*time.Millisecond, 5*time.Second)
|
||||
}
|
||||
|
||||
func assertMsgReceivedWithTimeout(t *testing.T, msg string, channel byte, reactor *TestReactor, checkPeriod, timeout time.Duration) {
|
||||
@@ -328,8 +331,11 @@ func BenchmarkSwitches(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
chID := byte(i % 4)
|
||||
successChan := s1.Broadcast(chID, "test data")
|
||||
for s := range successChan {
|
||||
if s {
|
||||
for res := range successChan {
|
||||
if !s1.peers.Has(res.PeerKey) {
|
||||
b.Error("Unexpected peerKey: " + res.PeerKey)
|
||||
}
|
||||
if res.Success {
|
||||
numSuccess++
|
||||
} else {
|
||||
numFailure++
|
||||
|
||||
Reference in New Issue
Block a user