@@ -36,7 +36,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
3636 type AdapterError = AdpaterErrorMock ;
3737 fn store_receipt ( & mut self , receipt : ReceivedReceipt ) -> Result < u64 , Self :: AdapterError > {
3838 let id = self . unique_id ;
39- let mut receipt_storage = self . receipt_storage . write ( ) . unwrap ( ) ;
39+ let mut receipt_storage =
40+ self . receipt_storage
41+ . write ( )
42+ . map_err ( |e| Self :: AdapterError :: AdapterError {
43+ error : e. to_string ( ) ,
44+ } ) ?;
4045 receipt_storage. insert ( id, receipt) ;
4146 self . unique_id += 1 ;
4247 Ok ( id)
@@ -45,7 +50,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
4550 & self ,
4651 receipt_id : u64 ,
4752 ) -> Result < ReceivedReceipt , Self :: AdapterError > {
48- let receipt_storage = self . receipt_storage . read ( ) . unwrap ( ) ;
53+ let receipt_storage =
54+ self . receipt_storage
55+ . read ( )
56+ . map_err ( |e| Self :: AdapterError :: AdapterError {
57+ error : e. to_string ( ) ,
58+ } ) ?;
4959
5060 receipt_storage
5161 . get ( & receipt_id)
@@ -58,7 +68,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
5868 & self ,
5969 timestamp_ns : u64 ,
6070 ) -> Result < Vec < ( u64 , ReceivedReceipt ) > , Self :: AdapterError > {
61- let receipt_storage = self . receipt_storage . read ( ) . unwrap ( ) ;
71+ let receipt_storage =
72+ self . receipt_storage
73+ . read ( )
74+ . map_err ( |e| Self :: AdapterError :: AdapterError {
75+ error : e. to_string ( ) ,
76+ } ) ?;
6277 Ok ( receipt_storage
6378 . iter ( )
6479 . filter ( |( _, rx_receipt) | {
@@ -71,7 +86,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
7186 & self ,
7287 timestamp_ns : u64 ,
7388 ) -> Result < Vec < ( u64 , ReceivedReceipt ) > , Self :: AdapterError > {
74- let receipt_storage = self . receipt_storage . read ( ) . unwrap ( ) ;
89+ let receipt_storage =
90+ self . receipt_storage
91+ . read ( )
92+ . map_err ( |e| Self :: AdapterError :: AdapterError {
93+ error : e. to_string ( ) ,
94+ } ) ?;
7595 Ok ( receipt_storage
7696 . iter ( )
7797 . filter ( |( _, rx_receipt) | {
@@ -84,7 +104,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
84104 & self ,
85105 timestamp_range_ns : Range < u64 > ,
86106 ) -> Result < Vec < ( u64 , ReceivedReceipt ) > , Self :: AdapterError > {
87- let receipt_storage = self . receipt_storage . read ( ) . unwrap ( ) ;
107+ let receipt_storage =
108+ self . receipt_storage
109+ . read ( )
110+ . map_err ( |e| Self :: AdapterError :: AdapterError {
111+ error : e. to_string ( ) ,
112+ } ) ?;
88113 Ok ( receipt_storage
89114 . iter ( )
90115 . filter ( |( _, rx_receipt) | {
@@ -98,7 +123,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
98123 receipt_id : u64 ,
99124 receipt : ReceivedReceipt ,
100125 ) -> Result < ( ) , Self :: AdapterError > {
101- let mut receipt_storage = self . receipt_storage . write ( ) . unwrap ( ) ;
126+ let mut receipt_storage =
127+ self . receipt_storage
128+ . write ( )
129+ . map_err ( |e| Self :: AdapterError :: AdapterError {
130+ error : e. to_string ( ) ,
131+ } ) ?;
102132
103133 if !receipt_storage. contains_key ( & receipt_id) {
104134 return Err ( AdpaterErrorMock :: AdapterError {
@@ -111,7 +141,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
111141 Ok ( ( ) )
112142 }
113143 fn remove_receipt_by_id ( & mut self , receipt_id : u64 ) -> Result < ( ) , Self :: AdapterError > {
114- let mut receipt_storage = self . receipt_storage . write ( ) . unwrap ( ) ;
144+ let mut receipt_storage =
145+ self . receipt_storage
146+ . write ( )
147+ . map_err ( |e| Self :: AdapterError :: AdapterError {
148+ error : e. to_string ( ) ,
149+ } ) ?;
115150 receipt_storage
116151 . remove ( & receipt_id)
117152 . map ( |_| ( ) )
@@ -129,7 +164,12 @@ impl ReceiptStorageAdapter for ReceiptStorageAdapterMock {
129164 & mut self ,
130165 timestamp_ns : Range < u64 > ,
131166 ) -> Result < ( ) , Self :: AdapterError > {
132- let mut receipt_storage = self . receipt_storage . write ( ) . unwrap ( ) ;
167+ let mut receipt_storage =
168+ self . receipt_storage
169+ . write ( )
170+ . map_err ( |e| Self :: AdapterError :: AdapterError {
171+ error : e. to_string ( ) ,
172+ } ) ?;
133173 receipt_storage. retain ( |_, rx_receipt| {
134174 !timestamp_ns. contains ( & rx_receipt. signed_receipt . message . timestamp_ns )
135175 } ) ;
0 commit comments