Browse Source

Merge pull request #1202 from tendermint/restore-mempool-memory-leak-tests

restore mempool memory leak tests
pull/1214/merge
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
0467de890a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 41 deletions
  1. +43
    -41
      mempool/reactor_test.go

+ 43
- 41
mempool/reactor_test.go View File

@ -6,6 +6,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/fortytw2/leaktest"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/go-kit/kit/log/term" "github.com/go-kit/kit/log/term"
@ -112,44 +114,44 @@ func TestReactorBroadcastTxMessage(t *testing.T) {
waitForTxs(t, txs, reactors) waitForTxs(t, txs, reactors)
} }
// func TestBroadcastTxForPeerStopsWhenPeerStops(t *testing.T) {
// if testing.Short() {
// t.Skip("skipping test in short mode.")
// }
// config := cfg.TestConfig()
// const N = 2
// reactors := makeAndConnectMempoolReactors(config, N)
// defer func() {
// for _, r := range reactors {
// r.Stop()
// }
// }()
// // stop peer
// sw := reactors[1].Switch
// sw.StopPeerForError(sw.Peers().List()[0], errors.New("some reason"))
// // check that we are not leaking any go-routines
// // i.e. broadcastTxRoutine finishes when peer is stopped
// leaktest.CheckTimeout(t, 10*time.Second)()
// }
// func TestBroadcastTxForPeerStopsWhenReactorStops(t *testing.T) {
// if testing.Short() {
// t.Skip("skipping test in short mode.")
// }
// config := cfg.TestConfig()
// const N = 2
// reactors := makeAndConnectMempoolReactors(config, N)
// // stop reactors
// for _, r := range reactors {
// r.Stop()
// }
// // check that we are not leaking any go-routines
// // i.e. broadcastTxRoutine finishes when reactor is stopped
// leaktest.CheckTimeout(t, 10*time.Second)()
// }
func TestBroadcastTxForPeerStopsWhenPeerStops(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
config := cfg.TestConfig()
const N = 2
reactors := makeAndConnectMempoolReactors(config, N)
defer func() {
for _, r := range reactors {
r.Stop()
}
}()
// stop peer
sw := reactors[1].Switch
sw.StopPeerForError(sw.Peers().List()[0], errors.New("some reason"))
// check that we are not leaking any go-routines
// i.e. broadcastTxRoutine finishes when peer is stopped
leaktest.CheckTimeout(t, 10*time.Second)()
}
func TestBroadcastTxForPeerStopsWhenReactorStops(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
config := cfg.TestConfig()
const N = 2
reactors := makeAndConnectMempoolReactors(config, N)
// stop reactors
for _, r := range reactors {
r.Stop()
}
// check that we are not leaking any go-routines
// i.e. broadcastTxRoutine finishes when reactor is stopped
leaktest.CheckTimeout(t, 10*time.Second)()
}

Loading…
Cancel
Save