Skip to content

Commit

Permalink
try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xinran chen committed Jul 11, 2023
1 parent f294cdc commit a8b31bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions miner-api/internal/orm/prover_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions miner-api/test/prover_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a8b31bb

Please sign in to comment.