This commit is contained in:
x88 2020-08-24 15:50:14 +03:00
parent 408b28a15a
commit 14c2cdff06
2 changed files with 12 additions and 12 deletions

View File

@ -229,12 +229,13 @@ func (m *DKGProposalFSM) actionValidateDkgProposalAwaitDeals(inEvent fsm.Event,
return
}
unconfirmedParticipants := m.payload.DKGQuorumCount()
// Only awaiting deals stage requires ({all_participants} - 1) confirmations
unconfirmedDealsParticipants := m.payload.DKGQuorumCount() - 1
for _, participant := range m.payload.DKGProposalPayload.Quorum {
if participant.Status == internal.DealConfirmationError {
isContainsError = true
} else if participant.Status == internal.DealConfirmed {
unconfirmedParticipants--
unconfirmedDealsParticipants--
}
}
@ -243,8 +244,7 @@ func (m *DKGProposalFSM) actionValidateDkgProposalAwaitDeals(inEvent fsm.Event,
return
}
// The are no declined and timed out participants, check for all confirmations
if unconfirmedParticipants > 1 { //TODO: this is bad
if unconfirmedDealsParticipants > 0 {
return
}

View File

@ -282,16 +282,13 @@ func Test_DkgProposal_Positive(t *testing.T) {
}
compareState(t, dpf.StateDkgCommitsAwaitConfirmations, fsmResponse.State)
// Commits
}
// Commits
func Test_DkgProposal_EventDKGCommitConfirmationReceived(t *testing.T) {
var fsmResponse *fsm.Response
pCounter := 0
for participantId, participant := range testIdMapParticipants {
pCounter--
testFSMInstance, err := FromDump(testFSMDump)
compareErrNil(t, err)
@ -343,9 +340,7 @@ func Test_DkgProposal_EventDKGCommitConfirmationReceived(t *testing.T) {
func Test_DkgProposal_EventDKGDealConfirmationReceived(t *testing.T) {
var fsmResponse *fsm.Response
pCounter := 0
for participantId, participant := range testIdMapParticipants {
pCounter--
testFSMInstance, err := FromDump(testFSMDump)
compareErrNil(t, err)
@ -364,6 +359,10 @@ func Test_DkgProposal_EventDKGDealConfirmationReceived(t *testing.T) {
compareFSMResponseNotNil(t, fsmResponse)
// Deals reached, next stage
if fsmResponse.State == dpf.StateDkgResponsesAwaitConfirmations {
break
}
}
compareState(t, dpf.StateDkgResponsesAwaitConfirmations, fsmResponse.State)
@ -374,8 +373,9 @@ func Test_DkgProposal_EventDKGDealConfirmationReceived(t *testing.T) {
t.Fatalf("expected response {DKGProposalDealParticipantResponse}")
}
if len(response) != len(testParticipantsListRequest.Participants) {
t.Fatalf("expected response len {%d}, got {%d}", len(testParticipantsListRequest.Participants), len(response))
// Deals count less than total users count by 1 unit
if len(response) != len(testParticipantsListRequest.Participants)-1 {
t.Fatalf("expected response len {%d}, got {%d}", len(testParticipantsListRequest.Participants), len(response)-1)
}
for _, responseEntry := range response {