Skip to content

Commit

Permalink
fix up
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Yuan <yy19902439@126.com>
  • Loading branch information
SamYuan1990 committed Apr 20, 2021
1 parent 2637a4a commit 30595a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions e2e/mock/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Peer struct {
GrpcServer *grpc.Server
BlkSize, txCnt uint64
TxC chan struct{}
CtlCh chan struct{}
CtlCh chan bool
}

func (p *Peer) ProcessProposal(context.Context, *peer.SignedProposal) (*peer.ProposalResponse, error) {
Expand Down Expand Up @@ -42,8 +42,8 @@ func (p *Peer) DeliverFiltered(srv peer.Deliver_DeliverFilteredServer) error {
Number: p.txCnt / p.BlkSize,
FilteredTransactions: make([]*peer.FilteredTransaction, p.BlkSize)}}})
}
case <-p.CtlCh:
if txc != nil {
case action := <-p.CtlCh:
if action {
txc = nil
} else {
txc = p.TxC
Expand Down Expand Up @@ -74,7 +74,7 @@ func NewPeer(TxC chan struct{}, credentials credentials.TransportCredentials) (*
if err != nil {
return nil, err
}
CtlCh := make(chan struct{})
CtlCh := make(chan bool)
instance := &Peer{
Listener: lis,
GrpcServer: grpc.NewServer(grpc.Creds(credentials)),
Expand All @@ -89,6 +89,10 @@ func NewPeer(TxC chan struct{}, credentials credentials.TransportCredentials) (*
return instance, nil
}

func (p *Peer) Toggle() {
p.CtlCh <- struct{}{}
func (p *Peer) Pause() {
p.CtlCh <- true
}

func (p *Peer) Unpause() {
p.CtlCh <- false
}
4 changes: 2 additions & 2 deletions pkg/infra/observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ var _ = Describe("Observer", func() {
}(i)
}
for i := 0; i < COMMIT_THRESHOLD; i++ {
mpeers[i].Toggle()
mpeers[i].Pause()
}
Consistently(finishCh).ShouldNot(Receive())
for i := 0; i < COMMIT_THRESHOLD; i++ {
mpeers[i].Toggle()
mpeers[i].Unpause()
}
<-finishCh
})
Expand Down

0 comments on commit 30595a6

Please sign in to comment.