package main

import "testing"

func TestMajorityIntersection(t *testing.T) {
	for n := 1; n <= 9; n++ {
		_, d := majorityIntersections(n)
		if d != 0 {
			t.Fatal(n)
		}
	}
}
func TestRaftPredicates(t *testing.T) {
	if directCommit(2, 4, 5, 5) || directCommit(4, 4, 2, 5) || !directCommit(4, 4, 3, 5) {
		t.Fatal("commit predicate")
	}
	if upToDate(Tail{2, 100}, Tail{3, 10}) || !upToDate(Tail{3, 10}, Tail{3, 9}) {
		t.Fatal("tail ordering")
	}
	v := Vote{}
	if !v.grant(7, "A") || v.grant(7, "B") || v.grant(6, "A") || !v.grant(8, "B") {
		t.Fatal("vote")
	}
}
