Fix leader change event

master
Vitaliy Filippov 2024-05-07 15:06:21 +03:00
parent b559f9b555
commit 857cf668f2
2 changed files with 2 additions and 2 deletions

View File

@ -238,7 +238,7 @@ class TinyRaft extends EventEmitter
if (this.state == CANDIDATE && this.term == msg.term && from == this.leader)
{
this.state = FOLLOWER;
this.emit('change', { state: this.state, term: this.term, leader: this.nodeId });
this.emit('change', { state: this.state, term: this.term, leader: this.leader });
}
if (this.state == FOLLOWER && from == this.leader)
{

View File

@ -200,7 +200,7 @@ async function testRestart()
checkQuorum(nodes, 5);
if (leaderChanges >= 3)
{
throw new Error("leaderChanges = "+leaderChanges+" (expected < 3)")
throw new Error("leaderChanges = "+leaderChanges+" (expected < 3)");
}
// Stop a follower
let restarted = 1 + (prevLeader % 5);