diff --git a/test/electrumx_test.dart b/test/electrumx_test.dart index 0d8bb93d1..cbf978f9c 100644 --- a/test/electrumx_test.dart +++ b/test/electrumx_test.dart @@ -5,6 +5,7 @@ import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/electrumx_rpc/rpc.dart'; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/utilities/prefs.dart'; @@ -1528,7 +1529,8 @@ void main() { .thenAnswer((_) => false); // Or true, shouldn't matter. when(mockPrefs.wifiOnly).thenAnswer((_) => false); final mockTorService = MockTorService(); - when(mockTorService.enabled).thenAnswer((_) => false); + when(mockTorService.status) + .thenAnswer((_) => TorConnectionStatus.disconnected); final client = ElectrumX( host: "some server", @@ -1551,7 +1553,7 @@ void main() { verify(mockPrefs.useTor).called(1); verifyNever(mockPrefs.torKillSwitch); verifyNoMoreInteractions(mockPrefs); - verifyNever(mockTorService.enabled); + verifyNever(mockTorService.status); verifyNoMoreInteractions(mockTorService); }); @@ -1575,8 +1577,9 @@ void main() { when(mockPrefs.wifiOnly).thenAnswer((_) => false); final mockTorService = MockTorService(); - when(mockTorService.enabled).thenAnswer((_) => false); - when(mockTorService.proxyInfo).thenAnswer((_) => ( + when(mockTorService.status) + .thenAnswer((_) => TorConnectionStatus.disconnected); + when(mockTorService.getProxyInfo()).thenAnswer((_) => ( host: InternetAddress('1.2.3.4'), port: -1 )); // Port is set to -1 until Tor is enabled. @@ -1601,8 +1604,8 @@ void main() { verify(mockPrefs.useTor).called(1); verify(mockPrefs.torKillSwitch).called(1); verifyNoMoreInteractions(mockPrefs); - verify(mockTorService.enabled).called(1); - verifyNever(mockTorService.proxyInfo); + verify(mockTorService.status).called(1); + verifyNever(mockTorService.getProxyInfo()); verifyNoMoreInteractions(mockTorService); }); @@ -1628,8 +1631,9 @@ void main() { when(mockPrefs.wifiOnly).thenAnswer((_) => false); final mockTorService = MockTorService(); - when(mockTorService.enabled).thenAnswer((_) => true); - when(mockTorService.proxyInfo) + when(mockTorService.status) + .thenAnswer((_) => TorConnectionStatus.connected); + when(mockTorService.getProxyInfo()) .thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42)); final client = ElectrumX( @@ -1653,8 +1657,8 @@ void main() { verify(mockPrefs.useTor).called(1); verifyNever(mockPrefs.torKillSwitch); verifyNoMoreInteractions(mockPrefs); - verify(mockTorService.enabled).called(1); - verify(mockTorService.proxyInfo).called(1); + verify(mockTorService.status).called(1); + verify(mockTorService.getProxyInfo()).called(1); verifyNoMoreInteractions(mockTorService); }); @@ -1685,7 +1689,8 @@ void main() { when(mockPrefs.torKillSwitch).thenAnswer((_) => true); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final mockTorService = MockTorService(); - when(mockTorService.enabled).thenAnswer((_) => false); + when(mockTorService.status) + .thenAnswer((_) => TorConnectionStatus.disconnected); final client = ElectrumX( host: "some server", @@ -1712,7 +1717,7 @@ void main() { verify(mockPrefs.useTor).called(1); verify(mockPrefs.torKillSwitch).called(1); verifyNoMoreInteractions(mockPrefs); - verify(mockTorService.enabled).called(1); + verify(mockTorService.status).called(1); verifyNoMoreInteractions(mockTorService); }); @@ -1740,7 +1745,8 @@ void main() { when(mockPrefs.torKillSwitch).thenAnswer((_) => false); when(mockPrefs.wifiOnly).thenAnswer((_) => false); final mockTorService = MockTorService(); - when(mockTorService.enabled).thenAnswer((_) => false); + when(mockTorService.status) + .thenAnswer((_) => TorConnectionStatus.disconnected); final client = ElectrumX( host: "some server", @@ -1763,7 +1769,7 @@ void main() { verify(mockPrefs.useTor).called(1); verify(mockPrefs.torKillSwitch).called(1); verifyNoMoreInteractions(mockPrefs); - verify(mockTorService.enabled).called(1); + verify(mockTorService.status).called(1); verifyNoMoreInteractions(mockTorService); }); }); diff --git a/test/electrumx_test.mocks.dart b/test/electrumx_test.mocks.dart index 521aff526..557b983a6 100644 --- a/test/electrumx_test.mocks.dart +++ b/test/electrumx_test.mocks.dart @@ -9,13 +9,15 @@ import 'dart:ui' as _i10; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/rpc.dart' as _i2; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart' + as _i12; import 'package:stackwallet/services/tor_service.dart' as _i11; import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i8; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i7; import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9; import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i6; import 'package:stackwallet/utilities/prefs.dart' as _i5; -import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i12; +import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i13; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -659,27 +661,40 @@ class MockTorService extends _i1.Mock implements _i11.TorService { } @override - bool get enabled => (super.noSuchMethod( - Invocation.getter(#enabled), - returnValue: false, - ) as bool); + _i12.TorConnectionStatus get status => (super.noSuchMethod( + Invocation.getter(#status), + returnValue: _i12.TorConnectionStatus.disconnected, + ) as _i12.TorConnectionStatus); @override - ({_i3.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod( - Invocation.getter(#proxyInfo), + ({_i3.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod( + Invocation.method( + #getProxyInfo, + [], + ), returnValue: ( host: _FakeInternetAddress_2( this, - Invocation.getter(#proxyInfo), + Invocation.method( + #getProxyInfo, + [], + ), ), port: 0 ), ) as ({_i3.InternetAddress host, int port})); @override - void init({_i12.Tor? mockableOverride}) => super.noSuchMethod( + void init({ + required String? torDataDirPath, + _i13.Tor? mockableOverride, + }) => + super.noSuchMethod( Invocation.method( #init, [], - {#mockableOverride: mockableOverride}, + { + #torDataDirPath: torDataDirPath, + #mockableOverride: mockableOverride, + }, ), returnValueForMissingStub: null, ); @@ -695,7 +710,7 @@ class MockTorService extends _i1.Mock implements _i11.TorService { @override _i4.Future disable() => (super.noSuchMethod( Invocation.method( - #stop, + #disable, [], ), returnValue: _i4.Future.value(), diff --git a/test/widget_tests/node_options_sheet_test.mocks.dart b/test/widget_tests/node_options_sheet_test.mocks.dart index d6d630335..42528b822 100644 --- a/test/widget_tests/node_options_sheet_test.mocks.dart +++ b/test/widget_tests/node_options_sheet_test.mocks.dart @@ -12,6 +12,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/node_model.dart' as _i18; import 'package:stackwallet/services/coins/manager.dart' as _i6; +import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart' + as _i20; import 'package:stackwallet/services/node_service.dart' as _i3; import 'package:stackwallet/services/tor_service.dart' as _i19; import 'package:stackwallet/services/wallets.dart' as _i9; @@ -23,7 +25,7 @@ import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i15; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i13; -import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i20; +import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i21; import 'package:tuple/tuple.dart' as _i11; // ignore_for_file: type=lint @@ -1025,27 +1027,40 @@ class MockTorService extends _i1.Mock implements _i19.TorService { } @override - bool get enabled => (super.noSuchMethod( - Invocation.getter(#enabled), - returnValue: false, - ) as bool); + _i20.TorConnectionStatus get status => (super.noSuchMethod( + Invocation.getter(#status), + returnValue: _i20.TorConnectionStatus.disconnected, + ) as _i20.TorConnectionStatus); @override - ({_i8.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod( - Invocation.getter(#proxyInfo), + ({_i8.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod( + Invocation.method( + #getProxyInfo, + [], + ), returnValue: ( host: _FakeInternetAddress_5( this, - Invocation.getter(#proxyInfo), + Invocation.method( + #getProxyInfo, + [], + ), ), port: 0 ), ) as ({_i8.InternetAddress host, int port})); @override - void init({_i20.Tor? mockableOverride}) => super.noSuchMethod( + void init({ + required String? torDataDirPath, + _i21.Tor? mockableOverride, + }) => + super.noSuchMethod( Invocation.method( #init, [], - {#mockableOverride: mockableOverride}, + { + #torDataDirPath: torDataDirPath, + #mockableOverride: mockableOverride, + }, ), returnValueForMissingStub: null, ); @@ -1061,7 +1076,7 @@ class MockTorService extends _i1.Mock implements _i19.TorService { @override _i12.Future disable() => (super.noSuchMethod( Invocation.method( - #stop, + #disable, [], ), returnValue: _i12.Future.value(),