From 415a0ac364b946ac67b37996d3382308b933d142 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Mon, 21 Aug 2023 17:33:25 -0500 Subject: [PATCH] harmonytask more lints --- go.sum | 2 -- itests/harmonytask_test.go | 17 +++++++++++++---- lib/harmony/harmonytask/harmonytask.go | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/go.sum b/go.sum index 81bc9dbfb..496fe2205 100644 --- a/go.sum +++ b/go.sum @@ -1521,8 +1521,6 @@ github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0 github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= -github.com/samuel/go-opencl v0.0.0-20171108220231-cbcfd10c32ad h1:zyvTnsJPPAqVg2v3bbvTI+RdbVPJufZ+CWCPOX0Dtp8= -github.com/samuel/go-opencl v0.0.0-20171108220231-cbcfd10c32ad/go.mod h1:KCqoxhWgoxCWg13iOq53YFf50jlonuuhIpO916aWEkg= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sercand/kuberesolver v2.4.0+incompatible h1:WE2OlRf6wjLxHwNkkFLQGaZcVLEXjMjBPjjEU5vksH8= diff --git a/itests/harmonytask_test.go b/itests/harmonytask_test.go index 0754d8cca..158a7dc5c 100644 --- a/itests/harmonytask_test.go +++ b/itests/harmonytask_test.go @@ -26,6 +26,15 @@ type task1 struct { WorkCompleted []string } +func withDbSetup(t *testing.T, f func(*kit.TestMiner)) { + _, miner, _ := kit.EnsembleMinimal(t, + kit.LatestActorsAt(-1), + kit.MockProofs(), + ) + + f(miner) +} + func (t *task1) Do(tID harmonytask.TaskID, stillOwned func() bool) (done bool, err error) { if !stillOwned() { return false, errors.New("Why not still owned?") @@ -63,7 +72,7 @@ func (t *task1) Adder(add harmonytask.AddTaskFunc) { } func TestHarmonyTasks(t *testing.T) { - withSetup(t, func(m *kit.TestMiner) { + withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB t1 := &task1{ toAdd: []int{56, 73}, @@ -145,7 +154,7 @@ func fooLetterSaver(t *testing.T, cdb *harmonydb.DB) *passthru { } func TestHarmonyTasksWith2PartiesPolling(t *testing.T) { - withSetup(t, func(m *kit.TestMiner) { + withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB senderParty := fooLetterAdder(t, cdb) workerParty := fooLetterSaver(t, cdb) @@ -163,7 +172,7 @@ func TestHarmonyTasksWith2PartiesPolling(t *testing.T) { } func TestWorkStealing(t *testing.T) { - withSetup(t, func(m *kit.TestMiner) { + withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB ctx := context.Background() @@ -190,7 +199,7 @@ func TestWorkStealing(t *testing.T) { } func TestTaskRetry(t *testing.T) { - withSetup(t, func(m *kit.TestMiner) { + withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB senderParty := fooLetterAdder(t, cdb) harmonytask.POLL_DURATION = time.Millisecond * 100 diff --git a/lib/harmony/harmonytask/harmonytask.go b/lib/harmony/harmonytask/harmonytask.go index 078a19be4..eefe5b8a0 100644 --- a/lib/harmony/harmonytask/harmonytask.go +++ b/lib/harmony/harmonytask/harmonytask.go @@ -327,7 +327,8 @@ func (e *TaskEngine) GetHttpHandlers() http.Handler { return } taskAdded := false - for _, v := range vs { + for _, vTmp := range vs { + v := vTmp taskAdded = taskAdded || v.f(TaskID(tID), v.h.AddTask) } if taskAdded {