Esempio n. 1
0
// Run the blackbox test on JsonFileRaftpersistentState
func TestNewJsonFileRaftpersistentState_Blackbox(t *testing.T) {
	wd, err := os.Getwd()
	if err != nil {
		t.Fatal(err)
	}
	filename := filepath.Join(wd, "test_jsonfilerps.json")

	err = os.Remove(filename)
	if err != nil && !os.IsNotExist(err) {
		t.Fatal(err)
	}

	jfrps, err := rps.NewJsonFileRaftPersistentState(filename)
	if err != nil {
		t.Fatal(err)
	}

	testhelpers.BlackboxTest_RaftPersistentState(t, jfrps)

	if jfrps.GetCurrentTerm() != 4 {
		t.Fatal()
	}
	if jfrps.GetVotedFor() != "s2" {
		t.Fatal()
	}
}
Esempio n. 2
0
// Run the blackbox test on InMemoryRaftPersistentState
func TestInMemoryRaftPersistentState(t *testing.T) {
	imps := rps.NewIMPSWithCurrentTerm(0)
	testhelpers.BlackboxTest_RaftPersistentState(t, imps)
}