This commit is contained in:
Alessio Treglia
2020-11-29 12:07:15 +00:00
parent 1b665fe822
commit 02a2ce6b10
8 changed files with 166 additions and 109 deletions
+8 -11
View File
@@ -2,7 +2,6 @@ package v0
import (
"fmt"
"os"
"sort"
"testing"
"time"
@@ -132,8 +131,7 @@ func newBlockchainReactor(
}
func TestNoBlockResponse(t *testing.T) {
config = cfg.ResetTestRoot("blockchain_reactor_test")
defer os.RemoveAll(config.RootDir)
config = cfg.SetupTestConfiguration(t)
genDoc, privVals := randGenesisDoc(1, false, 30)
maxBlockHeight := int64(65)
@@ -149,14 +147,14 @@ func TestNoBlockResponse(t *testing.T) {
}, p2p.Connect2Switches)
defer func() {
t.Cleanup(func() {
for _, r := range reactorPairs {
err := r.reactor.Stop()
require.NoError(t, err)
err = r.app.Stop()
require.NoError(t, err)
}
}()
})
tests := []struct {
height int64
@@ -194,8 +192,7 @@ func TestNoBlockResponse(t *testing.T) {
// Alternatively we could actually dial a TCP conn but
// that seems extreme.
func TestBadBlockStopsPeer(t *testing.T) {
config = cfg.ResetTestRoot("blockchain_reactor_test")
defer os.RemoveAll(config.RootDir)
config = cfg.SetupTestConfiguration(t)
genDoc, privVals := randGenesisDoc(1, false, 30)
maxBlockHeight := int64(148)
@@ -204,12 +201,12 @@ func TestBadBlockStopsPeer(t *testing.T) {
otherGenDoc, otherPrivVals := randGenesisDoc(1, false, 30)
otherChain := newBlockchainReactor(log.TestingLogger(), otherGenDoc, otherPrivVals, maxBlockHeight)
defer func() {
t.Cleanup(func() {
err := otherChain.reactor.Stop()
require.Error(t, err)
err = otherChain.app.Stop()
require.NoError(t, err)
}()
})
reactorPairs := make([]BlockchainReactorPair, 4)
@@ -224,7 +221,7 @@ func TestBadBlockStopsPeer(t *testing.T) {
}, p2p.Connect2Switches)
defer func() {
t.Cleanup(func() {
for _, r := range reactorPairs {
err := r.reactor.Stop()
require.NoError(t, err)
@@ -232,7 +229,7 @@ func TestBadBlockStopsPeer(t *testing.T) {
err = r.app.Stop()
require.NoError(t, err)
}
}()
})
for {
time.Sleep(1 * time.Second)
+8 -12
View File
@@ -2,7 +2,6 @@ package v1
import (
"fmt"
"os"
"sort"
"sync"
"testing"
@@ -180,9 +179,7 @@ func (conR *consensusReactorTest) SwitchToConsensus(state sm.State, blocksSynced
}
func TestFastSyncNoBlockResponse(t *testing.T) {
config = cfg.ResetTestRoot("blockchain_new_reactor_test")
defer os.RemoveAll(config.RootDir)
config = cfg.SetupTestConfiguration(t)
genDoc, privVals := randGenesisDoc(1, false, 30)
maxBlockHeight := int64(65)
@@ -203,12 +200,12 @@ func TestFastSyncNoBlockResponse(t *testing.T) {
}, p2p.Connect2Switches)
defer func() {
t.Cleanup(func() {
for _, r := range reactorPairs {
_ = r.bcR.Stop()
_ = r.conR.Stop()
}
}()
})
tests := []struct {
height int64
@@ -251,15 +248,14 @@ func TestFastSyncBadBlockStopsPeer(t *testing.T) {
numNodes := 4
maxBlockHeight := int64(148)
config = cfg.ResetTestRoot("blockchain_reactor_test")
defer os.RemoveAll(config.RootDir)
config = cfg.SetupTestConfiguration(t)
genDoc, privVals := randGenesisDoc(1, false, 30)
otherChain := newBlockchainReactorPair(t, log.TestingLogger(), genDoc, privVals, maxBlockHeight)
defer func() {
t.Cleanup(func() {
_ = otherChain.bcR.Stop()
_ = otherChain.conR.Stop()
}()
})
reactorPairs := make([]BlockchainReactorPair, numNodes)
logger := make([]log.Logger, numNodes)
@@ -284,12 +280,12 @@ func TestFastSyncBadBlockStopsPeer(t *testing.T) {
}, p2p.Connect2Switches)
defer func() {
t.Cleanup(func() {
for _, r := range reactorPairs {
_ = r.bcR.Stop()
_ = r.conR.Stop()
}
}()
})
outerFor:
for {
+2 -5
View File
@@ -3,7 +3,6 @@ package v2
import (
"fmt"
"net"
"os"
"sort"
"sync"
"testing"
@@ -351,8 +350,7 @@ func TestReactorHelperMode(t *testing.T) {
channelID = byte(0x40)
)
config := cfg.ResetTestRoot("blockchain_reactor_v2_test")
defer os.RemoveAll(config.RootDir)
config := cfg.SetupTestConfiguration(t)
genDoc, privVals := randGenesisDoc(config.ChainID(), 1, false, 30)
params := testReactorParams{
@@ -427,8 +425,7 @@ func TestReactorHelperMode(t *testing.T) {
}
func TestReactorSetSwitchNil(t *testing.T) {
config := cfg.ResetTestRoot("blockchain_reactor_v2_test")
defer os.RemoveAll(config.RootDir)
config := cfg.SetupTestConfiguration(t)
genDoc, privVals := randGenesisDoc(config.ChainID(), 1, false, 30)
reactor := newTestReactor(testReactorParams{