harmonytask more lints

This commit is contained in:
Andrew Jackson (Ajax) 2023-08-21 17:33:25 -05:00
parent 84f4cdfc15
commit 415a0ac364
3 changed files with 15 additions and 7 deletions

2
go.sum
View File

@ -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=

View File

@ -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

View File

@ -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 {