fix(simple): reset stale job window on pool session change
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
f4f0081eb0
commit
65f6c733a0
2 changed files with 34 additions and 0 deletions
|
|
@ -315,6 +315,9 @@ func (m *SimpleMapper) OnJob(job proxy.Job) {
|
|||
}
|
||||
m.mu.Lock()
|
||||
m.prevJob = m.currentJob
|
||||
if m.prevJob.ClientID != job.ClientID {
|
||||
m.prevJob = proxy.Job{}
|
||||
}
|
||||
m.currentJob = job
|
||||
m.stopped = false
|
||||
m.idleAt = time.Time{}
|
||||
|
|
|
|||
|
|
@ -293,6 +293,37 @@ func TestSimpleMapper_OnResultAccepted_CustomDiffUsesEffectiveDifficulty(t *test
|
|||
}
|
||||
}
|
||||
|
||||
func TestSimpleMapper_OnJob_PreservesPreviousJobForSamePoolSession_Good(t *testing.T) {
|
||||
mapper := &SimpleMapper{
|
||||
currentJob: proxy.Job{JobID: "job-1", Blob: "blob-1", ClientID: "session-a"},
|
||||
}
|
||||
|
||||
mapper.OnJob(proxy.Job{JobID: "job-2", Blob: "blob-2", ClientID: "session-a"})
|
||||
|
||||
if mapper.currentJob.JobID != "job-2" {
|
||||
t.Fatalf("expected current job to roll forward, got %q", mapper.currentJob.JobID)
|
||||
}
|
||||
if mapper.prevJob.JobID != "job-1" {
|
||||
t.Fatalf("expected previous job to remain available within one pool session, got %q", mapper.prevJob.JobID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleMapper_OnJob_ResetsPreviousJobAcrossPoolSessions_Ugly(t *testing.T) {
|
||||
mapper := &SimpleMapper{
|
||||
currentJob: proxy.Job{JobID: "job-1", Blob: "blob-1", ClientID: "session-a"},
|
||||
prevJob: proxy.Job{JobID: "job-0", Blob: "blob-0", ClientID: "session-a"},
|
||||
}
|
||||
|
||||
mapper.OnJob(proxy.Job{JobID: "job-2", Blob: "blob-2", ClientID: "session-b"})
|
||||
|
||||
if mapper.currentJob.JobID != "job-2" {
|
||||
t.Fatalf("expected current job to advance after session change, got %q", mapper.currentJob.JobID)
|
||||
}
|
||||
if mapper.prevJob.JobID != "" {
|
||||
t.Fatalf("expected previous job history to reset on new pool session, got %q", mapper.prevJob.JobID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSimpleMapper_Submit_InvalidJob_Good(t *testing.T) {
|
||||
minerConn, clientConn := net.Pipe()
|
||||
defer minerConn.Close()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue