mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-18 08:34:31 +00:00
fix tests
This commit is contained in:
parent
d6d0e9a9af
commit
c900f8f779
3 changed files with 72 additions and 36 deletions
|
@ -5,6 +5,7 @@ import 'package:mockito/annotations.dart';
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||||
import 'package:stackwallet/electrumx_rpc/rpc.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/services/tor_service.dart';
|
||||||
import 'package:stackwallet/utilities/prefs.dart';
|
import 'package:stackwallet/utilities/prefs.dart';
|
||||||
|
|
||||||
|
@ -1528,7 +1529,8 @@ void main() {
|
||||||
.thenAnswer((_) => false); // Or true, shouldn't matter.
|
.thenAnswer((_) => false); // Or true, shouldn't matter.
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
host: "some server",
|
host: "some server",
|
||||||
|
@ -1551,7 +1553,7 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verifyNever(mockPrefs.torKillSwitch);
|
verifyNever(mockPrefs.torKillSwitch);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verifyNever(mockTorService.enabled);
|
verifyNever(mockTorService.status);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1575,8 +1577,9 @@ void main() {
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
|
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
when(mockTorService.proxyInfo).thenAnswer((_) => (
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
when(mockTorService.getProxyInfo()).thenAnswer((_) => (
|
||||||
host: InternetAddress('1.2.3.4'),
|
host: InternetAddress('1.2.3.4'),
|
||||||
port: -1
|
port: -1
|
||||||
)); // Port is set to -1 until Tor is enabled.
|
)); // Port is set to -1 until Tor is enabled.
|
||||||
|
@ -1601,8 +1604,8 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verify(mockPrefs.torKillSwitch).called(1);
|
verify(mockPrefs.torKillSwitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verifyNever(mockTorService.proxyInfo);
|
verifyNever(mockTorService.getProxyInfo());
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1628,8 +1631,9 @@ void main() {
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
|
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => true);
|
when(mockTorService.status)
|
||||||
when(mockTorService.proxyInfo)
|
.thenAnswer((_) => TorConnectionStatus.connected);
|
||||||
|
when(mockTorService.getProxyInfo())
|
||||||
.thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42));
|
.thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42));
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
|
@ -1653,8 +1657,8 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verifyNever(mockPrefs.torKillSwitch);
|
verifyNever(mockPrefs.torKillSwitch);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verify(mockTorService.proxyInfo).called(1);
|
verify(mockTorService.getProxyInfo()).called(1);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1685,7 +1689,8 @@ void main() {
|
||||||
when(mockPrefs.torKillSwitch).thenAnswer((_) => true);
|
when(mockPrefs.torKillSwitch).thenAnswer((_) => true);
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
host: "some server",
|
host: "some server",
|
||||||
|
@ -1712,7 +1717,7 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verify(mockPrefs.torKillSwitch).called(1);
|
verify(mockPrefs.torKillSwitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1740,7 +1745,8 @@ void main() {
|
||||||
when(mockPrefs.torKillSwitch).thenAnswer((_) => false);
|
when(mockPrefs.torKillSwitch).thenAnswer((_) => false);
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
host: "some server",
|
host: "some server",
|
||||||
|
@ -1763,7 +1769,7 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verify(mockPrefs.torKillSwitch).called(1);
|
verify(mockPrefs.torKillSwitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,13 +9,15 @@ import 'dart:ui' as _i10;
|
||||||
|
|
||||||
import 'package:mockito/mockito.dart' as _i1;
|
import 'package:mockito/mockito.dart' as _i1;
|
||||||
import 'package:stackwallet/electrumx_rpc/rpc.dart' as _i2;
|
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/services/tor_service.dart' as _i11;
|
||||||
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i8;
|
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/backup_frequency_type.dart' as _i7;
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9;
|
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/enums/sync_type_enum.dart' as _i6;
|
||||||
import 'package:stackwallet/utilities/prefs.dart' as _i5;
|
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: type=lint
|
||||||
// ignore_for_file: avoid_redundant_argument_values
|
// ignore_for_file: avoid_redundant_argument_values
|
||||||
|
@ -659,27 +661,40 @@ class MockTorService extends _i1.Mock implements _i11.TorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get enabled => (super.noSuchMethod(
|
_i12.TorConnectionStatus get status => (super.noSuchMethod(
|
||||||
Invocation.getter(#enabled),
|
Invocation.getter(#status),
|
||||||
returnValue: false,
|
returnValue: _i12.TorConnectionStatus.disconnected,
|
||||||
) as bool);
|
) as _i12.TorConnectionStatus);
|
||||||
@override
|
@override
|
||||||
({_i3.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod(
|
({_i3.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod(
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
returnValue: (
|
returnValue: (
|
||||||
host: _FakeInternetAddress_2(
|
host: _FakeInternetAddress_2(
|
||||||
this,
|
this,
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
port: 0
|
port: 0
|
||||||
),
|
),
|
||||||
) as ({_i3.InternetAddress host, int port}));
|
) as ({_i3.InternetAddress host, int port}));
|
||||||
@override
|
@override
|
||||||
void init({_i12.Tor? mockableOverride}) => super.noSuchMethod(
|
void init({
|
||||||
|
required String? torDataDirPath,
|
||||||
|
_i13.Tor? mockableOverride,
|
||||||
|
}) =>
|
||||||
|
super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#init,
|
#init,
|
||||||
[],
|
[],
|
||||||
{#mockableOverride: mockableOverride},
|
{
|
||||||
|
#torDataDirPath: torDataDirPath,
|
||||||
|
#mockableOverride: mockableOverride,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
returnValueForMissingStub: null,
|
returnValueForMissingStub: null,
|
||||||
);
|
);
|
||||||
|
@ -695,7 +710,7 @@ class MockTorService extends _i1.Mock implements _i11.TorService {
|
||||||
@override
|
@override
|
||||||
_i4.Future<void> disable() => (super.noSuchMethod(
|
_i4.Future<void> disable() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#stop,
|
#disable,
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
returnValue: _i4.Future<void>.value(),
|
returnValue: _i4.Future<void>.value(),
|
||||||
|
|
|
@ -12,6 +12,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5;
|
||||||
import 'package:mockito/mockito.dart' as _i1;
|
import 'package:mockito/mockito.dart' as _i1;
|
||||||
import 'package:stackwallet/models/node_model.dart' as _i18;
|
import 'package:stackwallet/models/node_model.dart' as _i18;
|
||||||
import 'package:stackwallet/services/coins/manager.dart' as _i6;
|
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/node_service.dart' as _i3;
|
||||||
import 'package:stackwallet/services/tor_service.dart' as _i19;
|
import 'package:stackwallet/services/tor_service.dart' as _i19;
|
||||||
import 'package:stackwallet/services/wallets.dart' as _i9;
|
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'
|
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
|
||||||
as _i7;
|
as _i7;
|
||||||
import 'package:stackwallet/utilities/prefs.dart' as _i13;
|
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;
|
import 'package:tuple/tuple.dart' as _i11;
|
||||||
|
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
|
@ -1025,27 +1027,40 @@ class MockTorService extends _i1.Mock implements _i19.TorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get enabled => (super.noSuchMethod(
|
_i20.TorConnectionStatus get status => (super.noSuchMethod(
|
||||||
Invocation.getter(#enabled),
|
Invocation.getter(#status),
|
||||||
returnValue: false,
|
returnValue: _i20.TorConnectionStatus.disconnected,
|
||||||
) as bool);
|
) as _i20.TorConnectionStatus);
|
||||||
@override
|
@override
|
||||||
({_i8.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod(
|
({_i8.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod(
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
returnValue: (
|
returnValue: (
|
||||||
host: _FakeInternetAddress_5(
|
host: _FakeInternetAddress_5(
|
||||||
this,
|
this,
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
port: 0
|
port: 0
|
||||||
),
|
),
|
||||||
) as ({_i8.InternetAddress host, int port}));
|
) as ({_i8.InternetAddress host, int port}));
|
||||||
@override
|
@override
|
||||||
void init({_i20.Tor? mockableOverride}) => super.noSuchMethod(
|
void init({
|
||||||
|
required String? torDataDirPath,
|
||||||
|
_i21.Tor? mockableOverride,
|
||||||
|
}) =>
|
||||||
|
super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#init,
|
#init,
|
||||||
[],
|
[],
|
||||||
{#mockableOverride: mockableOverride},
|
{
|
||||||
|
#torDataDirPath: torDataDirPath,
|
||||||
|
#mockableOverride: mockableOverride,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
returnValueForMissingStub: null,
|
returnValueForMissingStub: null,
|
||||||
);
|
);
|
||||||
|
@ -1061,7 +1076,7 @@ class MockTorService extends _i1.Mock implements _i19.TorService {
|
||||||
@override
|
@override
|
||||||
_i12.Future<void> disable() => (super.noSuchMethod(
|
_i12.Future<void> disable() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#stop,
|
#disable,
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
returnValue: _i12.Future<void>.value(),
|
returnValue: _i12.Future<void>.value(),
|
||||||
|
|
Loading…
Reference in a new issue