forked from hyperledger/fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- A BFTDeliverer that fetches blocks and maintains a BFTCensorshipMonitor. - Abstract the creation of a BFTCensorshipMonitor via an abstract factory, so that we can use a mock for it in testing. - Add a "shuffledEndpoints" method to the connection source and test it. - Unit testing of BFTDeliverer. Signed-off-by: Yoav Tock <[email protected]> Change-Id: Ifead3f9e6c803c4d9fabc63acce11c6da472b88d
- Loading branch information
Showing
17 changed files
with
1,784 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
internal/pkg/peer/blocksprovider/bft_censorship_monitor_factory.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package blocksprovider | ||
|
||
import "github.com/hyperledger/fabric/internal/pkg/peer/orderers" | ||
|
||
// BFTCensorshipMonitorFactory creates an instance of a BFTCensorshipMonitor. It is an implementation of the | ||
// CensorshipDetectorFactory interface which abstracts the creation of a BFTCensorshipMonitor. | ||
type BFTCensorshipMonitorFactory struct{} | ||
|
||
func (f *BFTCensorshipMonitorFactory) Create( | ||
chainID string, | ||
verifier BlockVerifier, | ||
requester DeliverClientRequester, | ||
progressReporter BlockProgressReporter, | ||
fetchSources []*orderers.Endpoint, | ||
blockSourceIndex int, | ||
timeoutConf TimeoutConfig, | ||
) CensorshipDetector { | ||
return NewBFTCensorshipMonitor(chainID, verifier, requester, progressReporter, fetchSources, blockSourceIndex, timeoutConf) | ||
} |
21 changes: 21 additions & 0 deletions
21
internal/pkg/peer/blocksprovider/bft_censorship_monitor_factory_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package blocksprovider_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/internal/pkg/peer/blocksprovider" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewBFTCensorshipMonitorFactory(t *testing.T) { | ||
s := newMonitorTestSetup(t, 5) | ||
f := &blocksprovider.BFTCensorshipMonitorFactory{} | ||
mon := f.Create(s.channelID, s.fakeBlockVerifier, s.fakeRequester, s.fakeProgressReporter, s.sources, 0, blocksprovider.TimeoutConfig{}) | ||
require.NotNil(t, mon) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.