Skip to content

Commit

Permalink
[Exchange Oracle] escrow_finished -> escrow_completed, finished -> de…
Browse files Browse the repository at this point in the history
…leted
  • Loading branch information
Bobronium committed Aug 26, 2024
1 parent 1117800 commit c4945e4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExchangeOracleEvent_EscrowCleaned(OracleEvent):
pass # escrow is enough for now


class ReputationOracleEvent_EscrowFinished(OracleEvent): # (will refactor later)
class ReputationOracleEvent_EscrowCompleted(OracleEvent): # (will refactor later)
pass


Expand All @@ -59,7 +59,7 @@ class ReputationOracleEvent_EscrowFinished(OracleEvent): # (will refactor later
ExchangeOracleEventTypes.task_creation_failed: ExchangeOracleEvent_TaskCreationFailed,
ExchangeOracleEventTypes.task_finished: ExchangeOracleEvent_TaskFinished,
ExchangeOracleEventTypes.escrow_cleaned: ExchangeOracleEvent_EscrowCleaned,
ReputationOracleEventTypes.escrow_finished: ReputationOracleEvent_EscrowFinished,
ReputationOracleEventTypes.escrow_completed: ReputationOracleEvent_EscrowCompleted,
}


Expand Down
8 changes: 4 additions & 4 deletions packages/examples/cvat/exchange-oracle/src/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ class ProjectStatuses(str, Enum, metaclass=BetterEnumMeta):
validation = "validation"
canceled = "canceled"
recorded = "recorded"
finished = "finished"
deleted = "deleted"


class TaskStatuses(str, Enum, metaclass=BetterEnumMeta):
annotation = "annotation"
completed = "completed"
finished = "finished"
deleted = "deleted"


class JobStatuses(str, Enum, metaclass=BetterEnumMeta):
new = "new"
in_progress = "in progress"
rejected = "rejected"
completed = "completed"
finished = "finished"
deleted = "deleted"


class TaskTypes(str, Enum, metaclass=BetterEnumMeta):
Expand Down Expand Up @@ -79,7 +79,7 @@ class RecordingOracleEventTypes(str, Enum, metaclass=BetterEnumMeta):

class ReputationOracleEventTypes(str, Enum, metaclass=BetterEnumMeta):
# TODO: rename to ReputationOracleEventType
escrow_finished = "escrow_finished"
escrow_completed = "escrow_completed"


class OracleWebhookStatuses(str, Enum, metaclass=BetterEnumMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def process_incoming_reputation_oracle_webhooks(logger: logging.Logger, session:
for webhook in webhooks:
with handle_webhook(logger, session, webhook):
match webhook.event_type:
case ReputationOracleEventTypes.escrow_finished:
case ReputationOracleEventTypes.escrow_completed:
projects = db_service.get_projects_by_escrow_address(
session, webhook.escrow_address
)
Expand All @@ -48,9 +48,9 @@ def process_incoming_reputation_oracle_webhooks(logger: logging.Logger, session:
session,
webhook.escrow_address,
webhook.chain_id,
status=ProjectStatuses.finished,
tasks_status=TaskStatuses.finished,
jobs_status=JobStatuses.finished,
status=ProjectStatuses.deleted,
tasks_status=TaskStatuses.deleted,
jobs_status=JobStatuses.deleted,
)

oracle_db_service.outbox.create_webhook(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,25 @@ class Case:
project_status=ProjectStatuses.completed,
task_status=TaskStatuses.completed,
job_status=JobStatuses.completed,
expected_project_status=ProjectStatuses.finished,
expected_task_status=TaskStatuses.finished,
expected_job_status=JobStatuses.finished,
expected_project_status=ProjectStatuses.deleted,
expected_task_status=TaskStatuses.deleted,
expected_job_status=JobStatuses.deleted,
),
Case(
project_status=ProjectStatuses.finished,
task_status=TaskStatuses.finished,
job_status=JobStatuses.finished,
expected_project_status=ProjectStatuses.finished,
expected_task_status=TaskStatuses.finished,
expected_job_status=JobStatuses.finished,
project_status=ProjectStatuses.deleted,
task_status=TaskStatuses.deleted,
job_status=JobStatuses.deleted,
expected_project_status=ProjectStatuses.deleted,
expected_task_status=TaskStatuses.deleted,
expected_job_status=JobStatuses.deleted,
),
Case(
project_status=ProjectStatuses.annotation,
task_status=TaskStatuses.annotation,
job_status=JobStatuses.in_progress,
expected_project_status=ProjectStatuses.finished,
expected_task_status=TaskStatuses.finished,
expected_job_status=JobStatuses.finished,
expected_project_status=ProjectStatuses.deleted,
expected_task_status=TaskStatuses.deleted,
expected_job_status=JobStatuses.deleted,
),
],
ids=["completed", "finished", "in progress"],
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_process_incoming_reputation_oracle_webhooks_task_rejected_type(
session.add(cvat_job)

webhook = create_webhook(
ReputationOracleEventTypes.escrow_finished, OracleWebhookDirectionTags.incoming
ReputationOracleEventTypes.escrow_completed, OracleWebhookDirectionTags.incoming
)
mock_storage_client = mocker.MagicMock(spec=StorageClient)
mocker.patch.object(cloud, cloud.make_client.__name__, return_value=mock_storage_client)
Expand Down

0 comments on commit c4945e4

Please sign in to comment.