Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions quantus_sdk/lib/src/services/taskmaster_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class TaskmasterService {
final _referralEndpoint = Uri.parse('${AppConstants.taskMasterEndpoint}/referrals');
final _ethAssociationsEndpoint = Uri.parse('${AppConstants.taskMasterEndpoint}/addresses/associations/eth');
final _xAssociationsEndpoint = Uri.parse('${AppConstants.taskMasterEndpoint}/addresses/associations/x');
final remoteConfigsEndpoint = Uri.parse('${AppConstants.taskMasterEndpoint}/configs/wallet');

final String _minerStatsQuery = r'''
query MinerStats($ids: [String!]!) {
Expand Down Expand Up @@ -493,18 +494,16 @@ class TaskmasterService {
}

Future<RemoteConfigModel> getRemoteConfig() async {
final Uri uri = Uri.parse('${AppConstants.taskMasterEndpoint}/feature-flags/wallet');

final http.Response response = await http.get(uri, headers: {'Content-Type': 'application/json'});
final http.Response response = await http.get(remoteConfigsEndpoint, headers: {'Content-Type': 'application/json'});
if (response.statusCode != 200) {
throw Exception('Feature flags request failed with status: ${response.statusCode}. Body: ${response.body}');
throw Exception('Configs request failed with status: ${response.statusCode}. Body: ${response.body}');
}

final Map<String, dynamic>? responseBody = jsonDecode(response.body);
final Map<String, dynamic>? data = responseBody?['data'];

if (data == null) {
throw Exception('Feature flags request failed with status: ${response.statusCode}. Body: ${response.body}');
throw Exception('Configs request failed with status: ${response.statusCode}. Body: ${response.body}');
}

return RemoteConfigModel.fromJson(data);
Expand Down
14 changes: 8 additions & 6 deletions quantus_sdk/test/contract/remote_config_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import 'package:http/http.dart' as http;

void main() {
group('API Contract Tests', () {
test('Remote Feature Flags API exactly matches RemoteConfigModel properties', () async {
final Uri uri = Uri.parse('${AppConstants.taskMasterEndpoint}/feature-flags/wallet');
final http.Response response = await http.get(uri, headers: {'Content-Type': 'application/json'});
test('Remote Configs API exactly matches RemoteConfigModel properties', () async {
final http.Response response = await http.get(
TaskmasterService().remoteConfigsEndpoint,
headers: {'Content-Type': 'application/json'},
);

if (response.statusCode != 200) {
fail('Feature flags request failed with status: ${response.statusCode}. Body: ${response.body}');
fail('Configs request failed with status: ${response.statusCode}. Body: ${response.body}');
}

final Map<String, dynamic>? responseBody = jsonDecode(response.body);
final Map<String, dynamic>? data = responseBody?['data'];

if (data == null) {
fail('Feature flags request failed: Data is null');
fail('Configs request failed: Data is null');
}

final expectedKeys = {
Expand All @@ -41,7 +43,7 @@ void main() {
try {
RemoteConfigModel.fromJson(data);
} catch (e) {
fail('Failed to parse feature flags model: $e');
fail('Failed to parse configs model: $e');
}
});
});
Expand Down
Loading