From 963b85a8e7212546f7ae761cc98c1981b0791bd4 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Fri, 11 Nov 2022 10:48:49 +0100 Subject: [PATCH] Add example --- core/mock_test.go | 4 ++-- core/rapid_test.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/mock_test.go b/core/mock_test.go index 896c9ea..a3cd797 100644 --- a/core/mock_test.go +++ b/core/mock_test.go @@ -275,7 +275,7 @@ func (m mockMessages) GetMostRoundChangeMessages(round, height uint64) []*proto. } type backendConfigCallback func(*mockBackend) -type loggerConfigCallback func(*mockLogger) +type loggerConfigCallback func(string, *mockLogger) type transportConfigCallback func(*mockTransport) // newMockCluster creates a new IBFT cluster @@ -308,7 +308,7 @@ func newMockCluster( if loggerCallbackMap != nil { if loggerCallback, isSet := loggerCallbackMap[index]; isSet { - loggerCallback(logger) + loggerCallback(fmt.Sprintf("node_%d", index), logger) } } diff --git a/core/rapid_test.go b/core/rapid_test.go index 3f68313..d9714ac 100644 --- a/core/rapid_test.go +++ b/core/rapid_test.go @@ -435,7 +435,7 @@ func TestProperty_MajorityHonestNodes_BroadcastBadMessage(t *testing.T) { } // numNodes = rapid.Uint64Range(4, 30).Draw(t, "number of cluster nodes") - numNodes = uint64(12) + numNodes = uint64(7) // numByzantineNodes = rapid.Uint64Range(1, maxFaulty(numNodes)).Draw(t, "number of byzantine nodes") numByzantineNodes = maxFaulty(numNodes) // desiredHeight = rapid.Uint64Range(1, 5).Draw(t, "minimum height to be reached") @@ -445,17 +445,19 @@ func TestProperty_MajorityHonestNodes_BroadcastBadMessage(t *testing.T) { insertedProposals = newMockInsertedProposals(numNodes) ) - commonLoggerCallback := func(logger *mockLogger) { + fmt.Println(numNodes, numByzantineNodes) + + commonLoggerCallback := func(id string, logger *mockLogger) { logger.infoFn = func(s string, i ...interface{}) { - t.Log(append([]interface{}{s}, i...)...) + t.Log(append([]interface{}{id, s}, i...)...) } logger.errorFn = func(s string, i ...interface{}) { - t.Error(append([]interface{}{s}, i...)...) + t.Error(append([]interface{}{id, s}, i...)...) } logger.debugFn = func(s string, i ...interface{}) { - t.Log(append([]interface{}{s}, i...)...) + t.Log(append([]interface{}{id, s}, i...)...) } } @@ -592,7 +594,7 @@ func TestProperty_MajorityHonestNodes_BroadcastBadMessage(t *testing.T) { // Wait until Quorum nodes finish their run loop ctx, cancelFn := context.WithTimeout(context.Background(), time.Second*5) err := cluster.awaitNCompletions(ctx, int64(quorum(numNodes))) - assert.NoError(t, err, "unable to wait for nodes to complete") + require.NoError(t, err, "unable to wait for nodes to complete") fmt.Println(height, " => ", err) // Shutdown the remaining nodes that might be hanging