Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make voter electing staisfy finality #123

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Make voter sorting working well
  • Loading branch information
kukugi authored and user committed Sep 24, 2020
commit 16736b8b5dc3167fe58800501547b464fafe2279
2 changes: 1 addition & 1 deletion libs/rand/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func ElectVotersNonDup(candidates []Candidate, seed, tolerableByzantinePercent u
losersPriorities -= winner.Priority()

//sort voters in ascending votingPower/stakingPower
sortVoters(voters)
voters = sortVoters(voters)
totalWinPoint := float64(0)

//calculateVotingPowers(voters)
Expand Down
2 changes: 1 addition & 1 deletion libs/rand/sampling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestElectVotersNonDupCandidate(t *testing.T) {
func TestElectVotersNonDupSamplingThreshold(t *testing.T) {
candidates := newCandidates(100, func(i int) uint64 { return uint64(1000 * (i + 1)) })

for i := uint64(1); i <= 30; i++ {
for i := uint64(1); i <= 20; i++ {
winners := ElectVotersNonDup(candidates, 0, i)
assert.True(t, !isByzantine(winners, sumTotalPriority(candidates), i))
resetPoints(candidates)
Expand Down