1515 OracleWebhookStatuses ,
1616 OracleWebhookTypes ,
1717)
18- from src .crons .process_exchange_oracle_webhooks import process_incoming_exchange_oracle_webhooks
18+ from src .crons .process_exchange_oracle_webhooks import (
19+ process_incoming_exchange_oracle_webhook_escrow_recorded ,
20+ process_incoming_exchange_oracle_webhooks ,
21+ )
1922from src .db import SessionLocal
2023from src .models .validation import Task
2124from src .models .webhook import Webhook
2225from src .services .cloud import StorageClient
2326from src .services .webhook import OracleWebhookDirectionTags
2427
25- from tests .utils .constants import DEFAULT_GAS_PAYER_PRIV , SIGNATURE
28+ from tests .utils .constants import DEFAULT_GAS_PAYER_PRIV , ESCROW_ADDRESS , SIGNATURE
2629from tests .utils .setup_escrow import create_escrow , fund_escrow , setup_escrow
2730
2831
@@ -74,7 +77,7 @@ def test_process_exchange_oracle_webhook(self):
7477 assert updated_webhook .attempts == 1
7578
7679 def test_process_exchange_oracle_webhook_escrow_cleaned (self ):
77- escrow_address = "123"
80+ escrow_address = ESCROW_ADDRESS
7881 webhook = self .make_webhook (escrow_address , ExchangeOracleEventTypes .escrow_cleaned )
7982 self .session .add (webhook )
8083 task_id = str (uuid .uuid4 ())
@@ -101,6 +104,55 @@ def test_process_exchange_oracle_webhook_escrow_cleaned(self):
101104 call (prefix = compose_results_bucket_prefix (escrow_address , webhook .chain_id )),
102105 ]
103106
107+ def test_process_exchange_oracle_webhook_escrow_recorded (self ):
108+ escrow_address = ESCROW_ADDRESS
109+
110+ webhook = self .make_webhook (escrow_address , ExchangeOracleEventTypes .escrow_recorded )
111+ self .session .add (webhook )
112+
113+ task_id = str (uuid .uuid4 ())
114+ task = Task (id = task_id , escrow_address = escrow_address , chain_id = webhook .chain_id )
115+ self .session .add (task )
116+
117+ self .session .commit ()
118+
119+ with (
120+ patch ("src.crons.process_exchange_oracle_webhooks.validate_escrow" ),
121+ patch (
122+ "src.crons.process_exchange_oracle_webhooks.export_results"
123+ ) as mock_export_results ,
124+ ):
125+ process_incoming_exchange_oracle_webhook_escrow_recorded ()
126+
127+ mock_export_results .assert_called_once ()
128+
129+ self .session .refresh (webhook )
130+ self .session .refresh (task )
131+ assert webhook .status == OracleWebhookStatuses .completed
132+ assert webhook .attempts == 1
133+
134+ def test_process_exchange_oracle_webhook_job_finished (self ):
135+ escrow_address = ESCROW_ADDRESS
136+
137+ webhook = self .make_webhook (escrow_address , ExchangeOracleEventTypes .job_finished )
138+ self .session .add (webhook )
139+
140+ self .session .commit ()
141+
142+ with (
143+ patch ("src.crons.process_exchange_oracle_webhooks.validate_escrow" ),
144+ patch (
145+ "src.crons.process_exchange_oracle_webhooks.validate_results"
146+ ) as mock_validate_results ,
147+ ):
148+ process_incoming_exchange_oracle_webhooks ()
149+
150+ mock_validate_results .assert_called_once ()
151+
152+ self .session .refresh (webhook )
153+ assert webhook .status == OracleWebhookStatuses .completed
154+ assert webhook .attempts == 1
155+
104156 def test_process_recording_oracle_webhooks_invalid_escrow_address (self ):
105157 escrow_address = "invalid_address"
106158 webhook = self .make_webhook (escrow_address )
0 commit comments