Skip to content

Commit

Permalink
fix 2 test - lose commits message (hyperledger-labs#568) (#18)
Browse files Browse the repository at this point in the history
* fix 2 test - lose commits message (hyperledger-labs#568)

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>
Co-authored-by: C0rWin <artem@bargr.net>

* Sometimes there isn't enough time to wait for an event. (hyperledger-labs#569)

* Sometimes there isn't enough time to wait for an event. Increased the time.

Fixed working with break operator

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>

* add constant for real view change timeout

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>

---------

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>
Co-authored-by: C0rWin <artem@bargr.net>

---------

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>
Co-authored-by: pfi79 <pfi79@mail.ru>
Co-authored-by: C0rWin <artem@bargr.net>
  • Loading branch information
3 people authored Feb 19, 2024
1 parent 74b27e8 commit c44565b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"go.uber.org/zap/zapcore"
)

const (
realViewChangeTimeout = 90 * time.Second
)

func TestBasic(t *testing.T) {
t.Parallel()
network := NewNetwork()
Expand Down Expand Up @@ -1279,6 +1283,10 @@ func TestLeaderCatchUpWithoutSync(t *testing.T) {
restoredWG := sync.WaitGroup{}
restoredWG.Add(1)

var blockCommits uint32
nodes[0].LoseMessages(func(msg *smartbftprotos.Message) bool {
return msg.GetCommit() != nil && atomic.LoadUint32(&blockCommits) == 1
})
baseLogger := nodes[0].logger.Desugar()
nodes[0].logger = baseLogger.WithOptions(zap.Hooks(func(entry zapcore.Entry) error {
if strings.Contains(entry.Message, "Processed prepares for proposal with seq 1") {
Expand All @@ -1296,13 +1304,15 @@ func TestLeaderCatchUpWithoutSync(t *testing.T) {
return nil
})).Sugar()
nodes[0].Setup()
atomic.StoreUint32(&blockCommits, 1)

startNodes(nodes, network)

nodes[0].Submit(Request{ID: "1", ClientID: "alice"})

restartWG.Wait()
nodes[0].RestartSync(false)
atomic.StoreUint32(&blockCommits, 0)
restoredWG.Wait()

data := make([]*AppRecord, 0)
Expand Down Expand Up @@ -1358,6 +1368,10 @@ func TestLeaderProposeAfterRestartWithoutSync(t *testing.T) {
contViewWG := sync.WaitGroup{}
contViewWG.Add(2)

var blockCommits uint32
nodes[0].LoseMessages(func(msg *smartbftprotos.Message) bool {
return msg.GetCommit() != nil && atomic.LoadUint32(&blockCommits) == 1
})
baseLogger := nodes[0].logger.Desugar()
nodes[0].logger = baseLogger.WithOptions(zap.Hooks(func(entry zapcore.Entry) error {
if strings.Contains(entry.Message, "Processed prepares for proposal with seq 1") {
Expand Down Expand Up @@ -1387,13 +1401,15 @@ func TestLeaderProposeAfterRestartWithoutSync(t *testing.T) {
return nil
})).Sugar()
nodes[0].Setup()
atomic.StoreUint32(&blockCommits, 1)

startNodes(nodes, network)

nodes[0].Submit(Request{ID: "1", ClientID: "alice"})

restartWG.Wait()
nodes[0].RestartSync(false)
atomic.StoreUint32(&blockCommits, 0)
restoredWG.Wait()

nodes[0].Submit(Request{ID: "2", ClientID: "alice"})
Expand Down Expand Up @@ -2663,7 +2679,7 @@ func TestViewChangeAfterTryingToFork(t *testing.T) {
nodes[5].Connect()
nodes[4].Connect()

fail = time.After(1 * time.Minute)
fail = time.After(realViewChangeTimeout)
for i := 0; i < 7; i++ {
select {
case <-realViewChangeCh:
Expand Down Expand Up @@ -2927,7 +2943,7 @@ func TestLeaderStopSendHeartbeat(t *testing.T) {
nodes[2].Connect()
nodes[3].Connect()

fail = time.After(1 * time.Minute)
fail = time.After(realViewChangeTimeout)
for i := 0; i < 4; i++ {
select {
case <-realViewChangeCh:
Expand Down

0 comments on commit c44565b

Please sign in to comment.