Skip to content

Commit

Permalink
stores: fix TestBusRecordedMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Aug 5, 2024
1 parent a24a026 commit 2bb2190
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion stores/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ func (s *SQLStore) SetContractSet(ctx context.Context, name string, contractIds
var diff []types.FileContractID
var nContractsAfter int
err := s.db.Transaction(ctx, func(tx sql.DatabaseTx) error {
// build diff
prevContracts, err := tx.Contracts(ctx, api.ContractsOpts{ContractSet: name})
if err != nil && !errors.Is(err, api.ErrContractSetNotFound) {
return fmt.Errorf("failed to fetch contracts: %w", err)
Expand All @@ -617,7 +618,17 @@ func (s *SQLStore) SetContractSet(ctx context.Context, name string, contractIds
for fcid := range wanted {
diff = append(diff, fcid) // addition
}
return tx.SetContractSet(ctx, name, contractIds)
// update contract set
if err := tx.SetContractSet(ctx, name, contractIds); err != nil {
return fmt.Errorf("failed to set contract set: %w", err)
}
// fetch contracts after update
afterContracts, err := tx.Contracts(ctx, api.ContractsOpts{ContractSet: name})
if err != nil {
return fmt.Errorf("failed to fetch contracts after update: %w", err)
}
nContractsAfter = len(afterContracts)
return nil
})
if err != nil {
return fmt.Errorf("failed to set contract set: %w", err)
Expand Down

0 comments on commit 2bb2190

Please sign in to comment.