add to killswitch enabled test

This commit is contained in:
sneurlax 2023-09-08 14:51:00 -05:00
parent 4aba0b50fb
commit 941a24a6cc

View file

@ -1506,6 +1506,7 @@ void main() {
});
group("Tor killswitch tests", () {
// useTor is true, but TorService is not enabled and the killswitch is on, so no TorService calls should be made.
test("killswitch enabled", () async {
final mockClient = MockJsonRPC();
const command = "blockchain.transaction.get";
@ -1531,8 +1532,8 @@ void main() {
when(mockPrefs.useTor).thenAnswer((_) => true);
when(mockPrefs.torKillswitch).thenAnswer((_) => true);
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
final torService = MockTorService();
when(torService.enabled).thenAnswer((_) => false);
final mockTorService = MockTorService();
when(mockTorService.enabled).thenAnswer((_) => false);
final client = ElectrumX(
host: "some server",
@ -1541,7 +1542,7 @@ void main() {
client: mockClient,
failovers: [],
prefs: mockPrefs,
torService: torService,
torService: mockTorService,
);
try {
@ -1559,6 +1560,8 @@ void main() {
verify(mockPrefs.useTor).called(1);
verify(mockPrefs.torKillswitch).called(1);
verifyNoMoreInteractions(mockPrefs);
verify(mockTorService.enabled).called(1);
verifyNoMoreInteractions(mockTorService);
});
// useTor is true but Tor is not enabled, but because the killswitch is off, TorService calls should be made.