summaryrefslogtreecommitdiff
path: root/internal/quorum
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-06-18 21:12:18 +0300
committerPaul Buetow <paul@buetow.org>2023-06-18 21:12:18 +0300
commit71a5b5fc4b1e8a652f1bc8ca7c04eacaa289faf3 (patch)
tree7b1a0d6b4fb01deec30536175df27d5dae1b5fd1 /internal/quorum
parent831137abdecfcafeb21fb5f3de45156819f35ed4 (diff)
can specify my id
Diffstat (limited to 'internal/quorum')
-rw-r--r--internal/quorum/quorum.go2
-rw-r--r--internal/quorum/quorum_test.go28
2 files changed, 15 insertions, 15 deletions
diff --git a/internal/quorum/quorum.go b/internal/quorum/quorum.go
index 20fbe8a..cb8f01e 100644
--- a/internal/quorum/quorum.go
+++ b/internal/quorum/quorum.go
@@ -140,5 +140,5 @@ func (quo Quorum) pruneVotes() (vote.Vote, error) {
delete(quo.votes, e)
}
- return vote.New(live)
+ return vote.New(quo.conf, live)
}
diff --git a/internal/quorum/quorum_test.go b/internal/quorum/quorum_test.go
index f5d847e..8f50493 100644
--- a/internal/quorum/quorum_test.go
+++ b/internal/quorum/quorum_test.go
@@ -17,22 +17,22 @@ func TestScore(t *testing.T) {
quo = New(conf)
)
- vote1, _ := vote.New([]string{"foo", "bar"})
+ vote1, _ := vote.New(conf, []string{"foo", "bar"})
vote1.FromID = "foo"
vote1.ExpiresAt = inOneHour
quo.vote(vote1)
- vote2, _ := vote.New([]string{"bar", "baz"})
+ vote2, _ := vote.New(conf, []string{"bar", "baz"})
vote2.FromID = "bar"
vote2.ExpiresAt = inOneHour
quo.vote(vote2)
- vote3_dup, _ := vote.New([]string{"bar", "baz"})
+ vote3_dup, _ := vote.New(conf, []string{"bar", "baz"})
vote3_dup.FromID = "bar"
vote3_dup.ExpiresAt = inOneHour
quo.vote(vote3_dup)
- vote4, _ := vote.New([]string{"foo", "bar", "baz"})
+ vote4, _ := vote.New(conf, []string{"foo", "bar", "baz"})
vote4.FromID = "baz"
vote4.ExpiresAt = inOneHour
quo.vote(vote4)
@@ -48,18 +48,18 @@ func TestScore(t *testing.T) {
}
func TestTieScore(t *testing.T) {
- addVotes := func(quo Quorum) {
- vote1, _ := vote.New([]string{"foo", "bar", "baz"})
+ addVotes := func(conf config.Config, quo Quorum) {
+ vote1, _ := vote.New(conf, []string{"foo", "bar", "baz"})
vote1.FromID = "foo"
vote1.ExpiresAt = inOneHour
quo.vote(vote1)
- vote2, _ := vote.New([]string{"foo", "bar", "baz"})
+ vote2, _ := vote.New(conf, []string{"foo", "bar", "baz"})
vote2.FromID = "bar"
vote2.ExpiresAt = inOneHour
quo.vote(vote2)
- vote3, _ := vote.New([]string{"foo", "bar", "baz"})
+ vote3, _ := vote.New(conf, []string{"foo", "bar", "baz"})
vote3.FromID = "baz"
vote3.ExpiresAt = inOneHour
quo.vote(vote3)
@@ -72,7 +72,7 @@ func TestTieScore(t *testing.T) {
quo = New(conf)
)
- addVotes(quo)
+ addVotes(conf, quo)
scores := quo.score()
if len(scores) != 3 {
@@ -95,7 +95,7 @@ func TestTieScore(t *testing.T) {
quo = New(conf)
)
- addVotes(quo)
+ addVotes(conf, quo)
scores := quo.score()
if len(scores) != 3 {
@@ -118,12 +118,12 @@ func TestExpire(t *testing.T) {
quo = New(conf)
)
- vote1, _ := vote.New([]string{"bar", "baz", "bay"})
+ vote1, _ := vote.New(conf, []string{"bar", "baz", "bay"})
vote1.FromID = "foo"
vote1.ExpiresAt = inOneHour
quo.vote(vote1)
- vote2, _ := vote.New([]string{"foo", "bar", "baz"})
+ vote2, _ := vote.New(conf, []string{"foo", "bar", "baz"})
vote2.FromID = "bar"
vote2.ExpiresAt = time.Now()
quo.vote(vote2)
@@ -152,11 +152,11 @@ func TestLiveNodes(t *testing.T) {
quo = New(conf)
)
- vote1, _ := vote.New([]string{"bar", "baz", "bay"})
+ vote1, _ := vote.New(conf, []string{"bar", "baz", "bay"})
vote1.ExpiresAt = inOneHour
quo.vote(vote1)
- vote2, _ := vote.New([]string{"foo", "bar", "baz"})
+ vote2, _ := vote.New(conf, []string{"foo", "bar", "baz"})
vote2.ExpiresAt = inOneHour
quo.vote(vote2)