Add break statements to case, add test connection to node_card and include port when testing node connection

This commit is contained in:
likho 2023-08-23 16:59:00 +02:00
parent c44b64f4c0
commit 4729789f9a
4 changed files with 17 additions and 6 deletions

View file

@ -194,12 +194,15 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
try {
// await client.getSyncStatus();
} catch (_) {}
break;
case Coin.stellar:
case Coin.stellarTestnet:
try {
testPassed = await testStellarNodeConnection(formData.host!);
testPassed = await testStellarNodeConnection(formData.host!, formData.port!);
} catch(_) {}
break;
case Coin.nano:
case Coin.banano:

View file

@ -26,6 +26,7 @@ import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_eth_node_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/test_stellar_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
@ -170,10 +171,17 @@ class _NodeDetailsViewState extends ConsumerState<NodeDetailsView> {
}
break;
case Coin.nano:
case Coin.banano:
case Coin.stellar:
case Coin.stellarTestnet:
try {
testPassed = await testStellarNodeConnection(node!.host, node.port);
} catch(_) {
testPassed = false;
}
break;
case Coin.nano:
case Coin.banano:
throw UnimplementedError();
//TODO: check network/node
}

View file

@ -3,10 +3,10 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';
Future<bool> testStellarNodeConnection(String host) async {
Future<bool> testStellarNodeConnection(String host, int port) async {
final client = http.Client();
Uri uri = Uri.parse(host);
Uri uri = Uri.parse("$host:$port");
final response = await client.get(
uri,
headers: {'Content-Type': 'application/json'},

View file

@ -196,7 +196,7 @@ class _NodeCardState extends ConsumerState<NodeCard> {
case Coin.stellar:
case Coin.stellarTestnet:
try {
testPassed = await testStellarNodeConnection(node.host);
testPassed = await testStellarNodeConnection(node.host, node.port);
} catch(_) {
testPassed = false;
}