@@ -10,15 +10,10 @@ use tracing::info_span;
1010
1111use hyperlane_base:: {
1212 cache:: { LocalCache , MeteredCache , MeteredCacheConfig , MeteredCacheMetrics , OptionalCache } ,
13- db:: {
14- test_utils, DbResult , HyperlaneRocksDB , InterchainGasExpenditureData ,
15- InterchainGasPaymentData ,
16- } ,
17- } ;
18- use hyperlane_core:: {
19- identifiers:: UniqueIdentifier , test_utils:: dummy_domain, GasPaymentKey , InterchainGasPayment ,
20- InterchainGasPaymentMeta , MerkleTreeInsertion , PendingOperationStatus , H256 ,
13+ db:: { test_utils, HyperlaneRocksDB } ,
14+ tests:: mock_hyperlane_db:: MockHyperlaneDb as MockDb ,
2115} ;
16+ use hyperlane_core:: test_utils:: dummy_domain;
2217use hyperlane_operation_verifier:: {
2318 ApplicationOperationVerifier , ApplicationOperationVerifierReport ,
2419} ;
@@ -171,166 +166,6 @@ async fn get_first_n_operations_from_db_loader(
171166 pending_messages
172167}
173168
174- mockall:: mock! {
175- pub Db { }
176-
177- impl Debug for Db {
178- fn fmt<' a>( & self , f: & mut std:: fmt:: Formatter <' a>) -> std:: fmt:: Result ;
179- }
180-
181- impl HyperlaneDb for Db {
182- /// Retrieve the nonce of the highest processed message we're aware of
183- fn retrieve_highest_seen_message_nonce( & self ) -> DbResult <Option <u32 >>;
184-
185- /// Retrieve a message by its nonce
186- fn retrieve_message_by_nonce( & self , nonce: u32 ) -> DbResult <Option <HyperlaneMessage >>;
187-
188- /// Retrieve whether a message has been processed
189- fn retrieve_processed_by_nonce( & self , nonce: & u32 ) -> DbResult <Option <bool >>;
190-
191- /// Get the origin domain of the database
192- fn domain( & self ) -> & HyperlaneDomain ;
193-
194- fn store_message_id_by_nonce( & self , nonce: & u32 , id: & H256 ) -> DbResult <( ) >;
195-
196- fn retrieve_message_id_by_nonce( & self , nonce: & u32 ) -> DbResult <Option <H256 >>;
197-
198- fn store_message_by_id( & self , id: & H256 , message: & HyperlaneMessage ) -> DbResult <( ) >;
199-
200- fn retrieve_message_by_id( & self , id: & H256 ) -> DbResult <Option <HyperlaneMessage >>;
201-
202- fn store_dispatched_block_number_by_nonce(
203- & self ,
204- nonce: & u32 ,
205- block_number: & u64 ,
206- ) -> DbResult <( ) >;
207-
208- fn retrieve_dispatched_block_number_by_nonce( & self , nonce: & u32 ) -> DbResult <Option <u64 >>;
209-
210- /// Store whether a message was processed by its nonce
211- fn store_processed_by_nonce( & self , nonce: & u32 , processed: & bool ) -> DbResult <( ) >;
212-
213- fn store_processed_by_gas_payment_meta(
214- & self ,
215- meta: & InterchainGasPaymentMeta ,
216- processed: & bool ,
217- ) -> DbResult <( ) >;
218-
219- fn retrieve_processed_by_gas_payment_meta(
220- & self ,
221- meta: & InterchainGasPaymentMeta ,
222- ) -> DbResult <Option <bool >>;
223-
224- fn store_interchain_gas_expenditure_data_by_message_id(
225- & self ,
226- message_id: & H256 ,
227- data: & InterchainGasExpenditureData ,
228- ) -> DbResult <( ) >;
229-
230- fn retrieve_interchain_gas_expenditure_data_by_message_id(
231- & self ,
232- message_id: & H256 ,
233- ) -> DbResult <Option <InterchainGasExpenditureData >>;
234-
235- /// Store the status of an operation by its message id
236- fn store_status_by_message_id(
237- & self ,
238- message_id: & H256 ,
239- status: & PendingOperationStatus ,
240- ) -> DbResult <( ) >;
241-
242- /// Retrieve the status of an operation by its message id
243- fn retrieve_status_by_message_id(
244- & self ,
245- message_id: & H256 ,
246- ) -> DbResult <Option <PendingOperationStatus >>;
247-
248- fn store_interchain_gas_payment_data_by_gas_payment_key(
249- & self ,
250- key: & GasPaymentKey ,
251- data: & InterchainGasPaymentData ,
252- ) -> DbResult <( ) >;
253-
254- fn retrieve_interchain_gas_payment_data_by_gas_payment_key(
255- & self ,
256- key: & GasPaymentKey ,
257- ) -> DbResult <Option <InterchainGasPaymentData >>;
258-
259- fn store_gas_payment_by_sequence(
260- & self ,
261- sequence: & u32 ,
262- payment: & InterchainGasPayment ,
263- ) -> DbResult <( ) >;
264-
265- fn retrieve_gas_payment_by_sequence(
266- & self ,
267- sequence: & u32 ,
268- ) -> DbResult <Option <InterchainGasPayment >>;
269-
270- fn store_gas_payment_block_by_sequence(
271- & self ,
272- sequence: & u32 ,
273- block_number: & u64 ,
274- ) -> DbResult <( ) >;
275-
276- fn retrieve_gas_payment_block_by_sequence( & self , sequence: & u32 ) -> DbResult <Option <u64 >>;
277-
278- /// Store the retry count for a pending message by its message id
279- fn store_pending_message_retry_count_by_message_id(
280- & self ,
281- message_id: & H256 ,
282- count: & u32 ,
283- ) -> DbResult <( ) >;
284-
285- /// Retrieve the retry count for a pending message by its message id
286- fn retrieve_pending_message_retry_count_by_message_id(
287- & self ,
288- message_id: & H256 ,
289- ) -> DbResult <Option <u32 >>;
290-
291- fn store_merkle_tree_insertion_by_leaf_index(
292- & self ,
293- leaf_index: & u32 ,
294- insertion: & MerkleTreeInsertion ,
295- ) -> DbResult <( ) >;
296-
297- /// Retrieve the merkle tree insertion event by its leaf index
298- fn retrieve_merkle_tree_insertion_by_leaf_index(
299- & self ,
300- leaf_index: & u32 ,
301- ) -> DbResult <Option <MerkleTreeInsertion >>;
302-
303- fn store_merkle_leaf_index_by_message_id(
304- & self ,
305- message_id: & H256 ,
306- leaf_index: & u32 ,
307- ) -> DbResult <( ) >;
308-
309- /// Retrieve the merkle leaf index of a message in the merkle tree
310- fn retrieve_merkle_leaf_index_by_message_id( & self , message_id: & H256 ) -> DbResult <Option <u32 >>;
311-
312- fn store_merkle_tree_insertion_block_number_by_leaf_index(
313- & self ,
314- leaf_index: & u32 ,
315- block_number: & u64 ,
316- ) -> DbResult <( ) >;
317-
318- fn retrieve_merkle_tree_insertion_block_number_by_leaf_index(
319- & self ,
320- leaf_index: & u32 ,
321- ) -> DbResult <Option <u64 >>;
322-
323- fn store_highest_seen_message_nonce_number( & self , nonce: & u32 ) -> DbResult <( ) >;
324-
325- /// Retrieve the nonce of the highest processed message we're aware of
326- fn retrieve_highest_seen_message_nonce_number( & self ) -> DbResult <Option <u32 >>;
327-
328- fn store_payload_uuids_by_message_id( & self , message_id: & H256 , payload_uuids: Vec <UniqueIdentifier >) -> DbResult <( ) >;
329-
330- fn retrieve_payload_uuids_by_message_id( & self , message_id: & H256 ) -> DbResult <Option <Vec <UniqueIdentifier >>>;
331- }
332- }
333-
334169#[ tokio:: test]
335170async fn test_full_pending_message_persistence_flow ( ) {
336171 test_utils:: run_test_db ( |db| async move {
0 commit comments