@@ -42,14 +42,15 @@ import { getFakeTransaction } from '../../../utils/wallet/testing';
42
42
import Dialog from '../../../components/Dialog' ;
43
43
import { resetBackupState } from '../../../store/slices/backup' ;
44
44
import { updateUi } from '../../../store/slices/ui' ;
45
+ import { __E2E__ } from '../../../constants/env' ;
45
46
46
47
const DevSettings = ( {
47
48
navigation,
48
49
} : SettingsScreenProps < 'DevSettings' > ) : ReactElement => {
49
50
const dispatch = useAppDispatch ( ) ;
50
51
const { t } = useTranslation ( 'lightning' ) ;
51
52
const [ showDialog , setShowDialog ] = useState ( false ) ;
52
- // const [throwError, setThrowError] = useState(false);
53
+ const [ throwError , setThrowError ] = useState ( false ) ;
53
54
const selectedWallet = useAppSelector ( selectedWalletSelector ) ;
54
55
const selectedNetwork = useAppSelector ( selectedNetworkSelector ) ;
55
56
const addressType = useAppSelector ( addressTypeSelector ) ;
@@ -145,78 +146,6 @@ const DevSettings = ({
145
146
}
146
147
} ,
147
148
} ,
148
- {
149
- title : 'Inject Fake Transaction' ,
150
- type : EItemType . button ,
151
- testID : 'InjectFakeTransaction' ,
152
- onPress : ( ) : void => {
153
- const id =
154
- '9c0bed5b4c0833824210d29c3c847f47132c03f231ef8df228862132b3a8d80a' ;
155
- const fakeTx = getFakeTransaction ( id ) ;
156
- fakeTx [ id ] . height = 0 ;
157
- injectFakeTransaction ( {
158
- selectedWallet,
159
- selectedNetwork,
160
- fakeTx,
161
- } ) ;
162
- refreshWallet ( { selectedWallet, selectedNetwork } ) . then ( ) ;
163
- } ,
164
- } ,
165
- // {
166
- // title: 'Trigger exception in React render',
167
- // type: EItemType.button,
168
- // testID: 'TriggerRenderError',
169
- // onPress: (): void => {
170
- // setThrowError(true);
171
- // },
172
- // },
173
- {
174
- title : 'Trigger exception in action handler' ,
175
- type : EItemType . button ,
176
- testID : 'TriggerActionError' ,
177
- onPress : ( ) : void => {
178
- throw new Error ( 'test action error' ) ;
179
- } ,
180
- } ,
181
- {
182
- title : 'Trigger unhandled async exception' ,
183
- type : EItemType . button ,
184
- testID : 'TriggerAsyncError' ,
185
- onPress : ( ) : void => {
186
- throw new Error ( 'test async error' ) ;
187
- } ,
188
- } ,
189
- {
190
- title : 'Trigger Storage Warning' ,
191
- type : EItemType . button ,
192
- hide : selectedNetwork !== 'bitcoinRegtest' ,
193
- testID : 'TriggerStorageWarning' ,
194
- onPress : ( ) : void => {
195
- const wallet = getWalletStore ( ) ;
196
- const addresses =
197
- wallet . wallets [ selectedWallet ] . addresses [ selectedNetwork ] [
198
- addressType
199
- ] ;
200
- Object . keys ( addresses ) . map ( ( key ) => {
201
- if ( addresses [ key ] . index === 0 ) {
202
- addresses [ key ] . address =
203
- 'bcrt1qjp22nm804mtl6vtzf65z2jgmeaedrlvzlxffjv' ;
204
- }
205
- } ) ;
206
- const changeAddresses =
207
- wallet . wallets [ selectedWallet ] . changeAddresses [ selectedNetwork ] [
208
- addressType
209
- ] ;
210
- Object . keys ( changeAddresses ) . map ( ( key ) => {
211
- if ( changeAddresses [ key ] . index === 0 ) {
212
- changeAddresses [ key ] . address =
213
- 'bcrt1qwxfllzxchc9eq95zrcc9cjxhzqpkgtznc4wpzc' ;
214
- }
215
- } ) ;
216
- updateWallet ( wallet ) ;
217
- runChecks ( { selectedWallet, selectedNetwork } ) . then ( ) ;
218
- } ,
219
- } ,
220
149
] ,
221
150
} ,
222
151
{
@@ -331,9 +260,88 @@ const DevSettings = ({
331
260
} ,
332
261
] ;
333
262
334
- // if (throwError) {
335
- // throw new Error('test render error');
336
- // }
263
+ // add only in dev or e2e mode
264
+ if ( __DEV__ || __E2E__ ) {
265
+ settingsListData [ 1 ] . data = [
266
+ ...settingsListData [ 1 ] . data ,
267
+ {
268
+ title : 'Inject Fake Transaction' ,
269
+ type : EItemType . button ,
270
+ testID : 'InjectFakeTransaction' ,
271
+ onPress : ( ) : void => {
272
+ const id =
273
+ '9c0bed5b4c0833824210d29c3c847f47132c03f231ef8df228862132b3a8d80a' ;
274
+ const fakeTx = getFakeTransaction ( id ) ;
275
+ fakeTx [ id ] . height = 0 ;
276
+ injectFakeTransaction ( {
277
+ selectedWallet,
278
+ selectedNetwork,
279
+ fakeTx,
280
+ } ) ;
281
+ refreshWallet ( { selectedWallet, selectedNetwork } ) . then ( ) ;
282
+ } ,
283
+ } ,
284
+ {
285
+ title : 'Trigger exception in React render' ,
286
+ type : EItemType . button ,
287
+ testID : 'TriggerRenderError' ,
288
+ onPress : ( ) : void => {
289
+ setThrowError ( true ) ;
290
+ } ,
291
+ } ,
292
+ {
293
+ title : 'Trigger exception in action handler' ,
294
+ type : EItemType . button ,
295
+ testID : 'TriggerActionError' ,
296
+ onPress : ( ) : void => {
297
+ throw new Error ( 'test action error' ) ;
298
+ } ,
299
+ } ,
300
+ {
301
+ title : 'Trigger unhandled async exception' ,
302
+ type : EItemType . button ,
303
+ testID : 'TriggerAsyncError' ,
304
+ onPress : ( ) : void => {
305
+ throw new Error ( 'test async error' ) ;
306
+ } ,
307
+ } ,
308
+ {
309
+ title : 'Trigger Storage Warning' ,
310
+ type : EItemType . button ,
311
+ hide : selectedNetwork !== 'bitcoinRegtest' ,
312
+ testID : 'TriggerStorageWarning' ,
313
+ onPress : ( ) : void => {
314
+ const wallet = getWalletStore ( ) ;
315
+ const addresses =
316
+ wallet . wallets [ selectedWallet ] . addresses [ selectedNetwork ] [
317
+ addressType
318
+ ] ;
319
+ Object . keys ( addresses ) . map ( ( key ) => {
320
+ if ( addresses [ key ] . index === 0 ) {
321
+ addresses [ key ] . address =
322
+ 'bcrt1qjp22nm804mtl6vtzf65z2jgmeaedrlvzlxffjv' ;
323
+ }
324
+ } ) ;
325
+ const changeAddresses =
326
+ wallet . wallets [ selectedWallet ] . changeAddresses [ selectedNetwork ] [
327
+ addressType
328
+ ] ;
329
+ Object . keys ( changeAddresses ) . map ( ( key ) => {
330
+ if ( changeAddresses [ key ] . index === 0 ) {
331
+ changeAddresses [ key ] . address =
332
+ 'bcrt1qwxfllzxchc9eq95zrcc9cjxhzqpkgtznc4wpzc' ;
333
+ }
334
+ } ) ;
335
+ updateWallet ( wallet ) ;
336
+ runChecks ( { selectedWallet, selectedNetwork } ) . then ( ) ;
337
+ } ,
338
+ } ,
339
+ ] ;
340
+ }
341
+
342
+ if ( throwError ) {
343
+ throw new Error ( 'test render error' ) ;
344
+ }
337
345
338
346
return (
339
347
< >
0 commit comments