diff --git a/miner-api/internal/orm/prover_task.go b/miner-api/internal/orm/prover_task.go index 08633614c2..2ea635c910 100644 --- a/miner-api/internal/orm/prover_task.go +++ b/miner-api/internal/orm/prover_task.go @@ -61,14 +61,14 @@ func (o *ProverTask) GetProverTasksByHashes(ctx context.Context, hashes []string return proverTasks, nil } +// GetProverTasksByProver returns prover-tasks by the given prover's public key. func (o *ProverTask) GetProverTasksByProver(ctx context.Context, pubkey string) ([]*ProverTask, error) { var proverTasks []*ProverTask - err := o.db.WithContext(ctx).Model(&ProverTask{}).Where(&ProverTask{ProverPublicKey: pubkey}).Order("created_at asc").Find(&proverTasks).Error + err := o.db.WithContext(ctx).Model(&ProverTask{}).Where(&ProverTask{ProverPublicKey: pubkey}).Order("id asc").Find(&proverTasks).Error if err != nil { return nil, fmt.Errorf("ProverTask.GetProverTasksByProver error: %w, prover %s", err, pubkey) } return proverTasks, nil - } // SetProverTask updates or inserts a ProverTask record. diff --git a/miner-api/test/prover_task_test.go b/miner-api/test/prover_task_test.go index d1edbef1de..4271bce38a 100644 --- a/miner-api/test/prover_task_test.go +++ b/miner-api/test/prover_task_test.go @@ -61,14 +61,14 @@ func TestProverTaskAPIs(t *testing.T) { func testGetProverTasksByProver(t *testing.T) { var tasks []*orm.ProverTask getResp(t, fmt.Sprintf("%s/tasks?pubkey=%s", basicPath, proverPubkey), &tasks) - assert.Equal(t, "2", tasks[0].TaskID) - assert.Equal(t, "1", tasks[1].TaskID) + assert.Equal(t, task2, *tasks[0]) + assert.Equal(t, task1, *tasks[1]) } func testGetTotalRewards(t *testing.T) { - rewards := make(map[string]decimal.Decimal) + rewards := make(map[string]int) getResp(t, fmt.Sprintf("%s/total_rewards?pubkey=%s", basicPath, proverPubkey), &rewards) - assert.Equal(t, decimal.NewFromInt(22), rewards["rewards"]) + assert.Equal(t, 22, rewards["rewards"]) } func testGetProverTask(t *testing.T) {