mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-03 17:29:23 +00:00
fix killswitch enabled test, WIP killswitch disabled test
This commit is contained in:
parent
25bc126cf9
commit
6cf88d22b5
1 changed files with 17 additions and 18 deletions
|
@ -1528,8 +1528,8 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
final mockPrefs = MockPrefs();
|
final mockPrefs = MockPrefs();
|
||||||
when(mockPrefs.useTor).thenAnswer((realInvocation) => true);
|
when(mockPrefs.useTor).thenAnswer((_) => true);
|
||||||
when(mockPrefs.torKillswitch).thenAnswer((realInvocation) => true);
|
when(mockPrefs.torKillswitch).thenAnswer((_) => true);
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final torService = MockTorService();
|
final torService = MockTorService();
|
||||||
when(torService.enabled).thenAnswer((_) => false);
|
when(torService.enabled).thenAnswer((_) => false);
|
||||||
|
@ -1545,25 +1545,26 @@ void main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var result =
|
var result = await client.getTransaction(
|
||||||
client.getTransaction(requestID: "some requestId", txHash: '');
|
requestID: "some requestId", txHash: '');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
expect(e, isA<Exception>());
|
expect(e, isA<Exception>());
|
||||||
expect(
|
expect(
|
||||||
e.toString(),
|
e.toString(),
|
||||||
equals(
|
equals(
|
||||||
"Tor preference and killswitch set but Tor is not enabled, not connecting to ElectrumX"));
|
"Exception: Tor preference and killswitch set but Tor is not enabled, not connecting to ElectrumX"));
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(mockPrefs.wifiOnly).called(1);
|
verify(mockPrefs.wifiOnly).called(1);
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
|
verify(mockPrefs.torKillswitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("killswitch disabled", () async {
|
test("killswitch disabled", () async {
|
||||||
final mockClient = MockJsonRPC();
|
final mockClient = MockJsonRPC();
|
||||||
const command = "blockchain.transaction.get";
|
const command = "blockchain.transaction.get";
|
||||||
const jsonArgs = '["",true]';
|
const jsonArgs = '["${SampleGetTransactionData.txHash0}",true]';
|
||||||
when(
|
when(
|
||||||
mockClient.request(
|
mockClient.request(
|
||||||
'{"jsonrpc": "2.0", "id": "some requestId",'
|
'{"jsonrpc": "2.0", "id": "some requestId",'
|
||||||
|
@ -1573,17 +1574,14 @@ void main() {
|
||||||
).thenAnswer(
|
).thenAnswer(
|
||||||
(_) async => JsonRPCResponse(data: {
|
(_) async => JsonRPCResponse(data: {
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"error": {
|
"result": SampleGetTransactionData.txData0,
|
||||||
"code": 1,
|
"id": "some requestId"
|
||||||
"message": "None should be a transaction hash",
|
|
||||||
},
|
|
||||||
"id": "some requestId",
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
final mockPrefs = MockPrefs();
|
final mockPrefs = MockPrefs();
|
||||||
when(mockPrefs.useTor).thenAnswer((realInvocation) => true);
|
when(mockPrefs.useTor).thenAnswer((_) => true);
|
||||||
when(mockPrefs.torKillswitch).thenAnswer((realInvocation) => true);
|
when(mockPrefs.torKillswitch).thenAnswer((_) => true);
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final torService = MockTorService();
|
final torService = MockTorService();
|
||||||
when(torService.enabled).thenAnswer((_) => false);
|
when(torService.enabled).thenAnswer((_) => false);
|
||||||
|
@ -1609,15 +1607,16 @@ void main() {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
didThrow = true;
|
didThrow = true;
|
||||||
// expect(e, isNotA<Exception>());
|
// expect(e, isNotA<Exception>());
|
||||||
expect(
|
// expect(
|
||||||
e.toString(),
|
// e.toString(),
|
||||||
isNot(equals(
|
// isNot(equals(
|
||||||
"Tor preference and killswitch set but Tor is not enabled, not connecting to ElectrumX")));
|
// "Exception: Tor preference and killswitch set but Tor is not enabled, not connecting to ElectrumX")));
|
||||||
}
|
}
|
||||||
expect(didThrow, isFalse);
|
expect(didThrow, isFalse);
|
||||||
|
|
||||||
// verify(mockPrefs.wifiOnly).called(1);
|
verify(mockPrefs.wifiOnly).called(1);
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
|
verify(mockPrefs.torKillswitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue