@@ -54,7 +54,7 @@ macro_rules! wallet_info {
54
54
}
55
55
56
56
/// Various tests on checking functionality
57
- fn scan_impl ( test_dir : & str ) -> Result < ( ) , wallet :: Error > {
57
+ fn scan_impl ( test_dir : & str ) {
58
58
global:: set_local_chain_type ( global:: ChainTypes :: AutomatedTesting ) ;
59
59
// Create a new proxy to simulate server and wallet responses
60
60
let tx_pool: Arc < Mutex < Vec < Transaction > > > = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
@@ -107,14 +107,16 @@ fn scan_impl(test_dir: &str) -> Result<(), wallet::Error> {
107
107
api. create_account_path ( m, "account_3" ) ?;
108
108
api. set_active_account ( m, "named_account_1" ) ?;
109
109
Ok ( ( ) )
110
- } ) ?;
110
+ } )
111
+ . unwrap ( ) ;
111
112
112
113
// add account to wallet 2
113
114
wallet:: controller:: owner_single_use ( Some ( wallet2. clone ( ) ) , mask2, None , |api, m| {
114
115
api. create_account_path ( m, "account_1" ) ?;
115
116
api. set_active_account ( m, "account_1" ) ?;
116
117
Ok ( ( ) )
117
- } ) ?;
118
+ } )
119
+ . unwrap ( ) ;
118
120
119
121
// Do some mining
120
122
let bh = 20u64 ;
@@ -140,44 +142,48 @@ fn scan_impl(test_dir: &str) -> Result<(), wallet::Error> {
140
142
assert_eq ! ( wallet1_info. total, c) ;
141
143
assert_eq ! ( txs. len( ) , bh as usize ) ;
142
144
Ok ( ( ) )
143
- } ) ?;
145
+ } )
146
+ . unwrap ( ) ;
144
147
145
148
// Accidentally delete some outputs
146
149
let mut w1_outputs_commits = vec ! [ ] ;
147
150
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
148
151
w1_outputs_commits = api. retrieve_outputs ( m, false , true , None ) ?. 1 ;
149
152
Ok ( ( ) )
150
- } ) ?;
153
+ } )
154
+ . unwrap ( ) ;
151
155
let w1_outputs: Vec < libwallet:: OutputData > =
152
156
w1_outputs_commits. into_iter ( ) . map ( |m| m. output ) . collect ( ) ;
153
157
{
154
- wallet_inst ! ( wallet1, w) ;
158
+ wallet_inst_test ! ( wallet1, w) ;
155
159
{
156
- let mut batch = w. batch ( mask1) ? ;
157
- batch. delete ( & w1_outputs[ 4 ] . key_id , & None ) ? ;
158
- batch. delete ( & w1_outputs[ 10 ] . key_id , & None ) ? ;
160
+ let mut batch = w. batch ( mask1) . unwrap ( ) ;
161
+ batch. delete ( & w1_outputs[ 4 ] . key_id , & None ) . unwrap ( ) ;
162
+ batch. delete ( & w1_outputs[ 10 ] . key_id , & None ) . unwrap ( ) ;
159
163
let mut accidental_spent = w1_outputs[ 13 ] . clone ( ) ;
160
164
accidental_spent. status = libwallet:: OutputStatus :: Spent ;
161
- batch. save ( accidental_spent) ? ;
162
- batch. commit ( ) ? ;
165
+ batch. save ( accidental_spent) . unwrap ( ) ;
166
+ batch. commit ( ) . unwrap ( ) ;
163
167
}
164
168
}
165
169
166
170
// check we have a problem now
167
171
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
168
172
// For MWC we don't 'refresh_from_node'. Otherwise issue will be corrected
169
- let ( _, wallet1_info) = api. retrieve_summary_info ( m, false , 1 ) ? ;
173
+ let ( _, wallet1_info) = api. retrieve_summary_info ( m, false , 1 ) . unwrap ( ) ;
170
174
let ( _, txs) = api. retrieve_txs ( m, false , None , None , None , None ) ?;
171
175
let ( c, _) = libwallet:: TxLogEntry :: sum_confirmed ( & txs) ;
172
176
assert ! ( wallet1_info. total != c) ;
173
177
Ok ( ( ) )
174
- } ) ?;
178
+ } )
179
+ . unwrap ( ) ;
175
180
176
181
// this should restore our missing outputs
177
182
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
178
183
api. scan ( m, None , true ) ?;
179
184
Ok ( ( ) )
180
- } ) ?;
185
+ } )
186
+ . unwrap ( ) ;
181
187
182
188
// check our outputs match again
183
189
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
@@ -190,7 +196,8 @@ fn scan_impl(test_dir: &str) -> Result<(), wallet::Error> {
190
196
assert ! ( api. set_active_account( m, "account_1" ) . is_err( ) ) ;
191
197
assert ! ( api. set_active_account( m, "named_account_1" ) . is_ok( ) ) ;
192
198
Ok ( ( ) )
193
- } ) ?;
199
+ } )
200
+ . unwrap ( ) ;
194
201
195
202
// perform a transaction, but don't let it finish
196
203
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
@@ -211,7 +218,8 @@ fn scan_impl(test_dir: &str) -> Result<(), wallet::Error> {
211
218
PathToSlatePutter :: build_plain ( Some ( send_file. into ( ) ) ) . put_tx ( & slate, None , true , & secp) ?;
212
219
api. tx_lock_outputs ( m, & slate, None , 0 ) ?;
213
220
Ok ( ( ) )
214
- } ) ?;
221
+ } )
222
+ . unwrap ( ) ;
215
223
216
224
// check we're all locked
217
225
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
@@ -220,25 +228,27 @@ fn scan_impl(test_dir: &str) -> Result<(), wallet::Error> {
220
228
assert ! ( !wallet1_refreshed) ; // mwc implementation must be without refresh to see an issue. Refresh will fix everything
221
229
assert ! ( wallet1_info. amount_currently_spendable == 0 ) ;
222
230
Ok ( ( ) )
223
- } ) ?;
231
+ } )
232
+ . unwrap ( ) ;
224
233
225
234
// unlock/restore
226
235
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
227
236
api. scan ( m, None , true ) ?;
228
237
Ok ( ( ) )
229
- } ) ?;
238
+ } )
239
+ . unwrap ( ) ;
230
240
231
241
// check spendable amount again
232
242
wallet:: controller:: owner_single_use ( Some ( wallet1. clone ( ) ) , mask1, None , |api, m| {
233
243
let ( _, wallet1_info) = api. retrieve_summary_info ( m, true , 1 ) ?;
234
244
assert_eq ! ( wallet1_info. amount_currently_spendable, ( bh - cm) * reward) ;
235
245
Ok ( ( ) )
236
- } ) ?;
246
+ } )
247
+ . unwrap ( ) ;
237
248
238
249
// let logging finish
239
250
stopper. store ( false , Ordering :: Relaxed ) ;
240
251
thread:: sleep ( Duration :: from_millis ( 200 ) ) ;
241
- Ok ( ( ) )
242
252
}
243
253
244
254
fn two_wallets_one_seed_impl ( test_dir : & str ) {
@@ -1117,9 +1127,7 @@ fn output_scanning_impl(test_dir: &str) -> Result<(), wallet::Error> {
1117
1127
fn scan ( ) {
1118
1128
let test_dir = "test_output/scan" ;
1119
1129
setup ( test_dir) ;
1120
- if let Err ( e) = scan_impl ( test_dir) {
1121
- panic ! ( "Libwallet Error: {}" , e) ;
1122
- }
1130
+ scan_impl ( test_dir) ;
1123
1131
clean_output_dir ( test_dir) ;
1124
1132
}
1125
1133
0 commit comments