Skip to content

Commit

Permalink
feat: Collect flutter code coverage (#404)
Browse files Browse the repository at this point in the history
* test: Fix tests after cat-gateway update.

* docs: Add `CatalystDataGatewayRepository` usage examples.

* docs: Move docs from README to code comment.

* test: Update `CatalystDataGatewayRepository` tests.

* test: Use Fake instead of Mock.

* chore: Fix Markdown errors.

* chore: Explicit use of `HttpStatus` codes.

* chore(deps-dev): bump vite in /utilities/wallet-tester (#397)

Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.6 to 5.1.7.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.1.7/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.1.7/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Apisit Ritreungroj <[email protected]>

* feat: Get slot number by provided date-time endpoint (#387)

* fix CardanoStakeAddress error handling

* refactor, add sync_state_get endpoint

* refactor types

* refactor

* add block_hash validation

* wip

* wip

* wip

* wip

* add check_network fn

* fix

* fix schematisis test

* try

* wip

* try

* try

* try

* try

* wip

* try

* try

* fix

* update Network

* add test_utxo test

* try

* fix

* try

* fix

* wip

* fix

* fix docket-compose.yml file

* try

* try

* fix

* try

* try

* try

* try

* wip

* fix

* wip

* try

* try

* wip

* try

* try

* revert

* wip

* wip

* wip

* fix

* fix

* fix

* remove mithril_snapshot loader

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* add stake addr bech32 encode utils function

* wip

* wip

* update indexing of the utxo data

* fix spelling

* wip

* wip

* finish utxo test

* fix deny

* fix check

* fix

* fix

* update earthly builder versions

* wip

* ignore test_utxo.py in CI

* dont ignore tests

* add date_time_to_slot_number_get endpoint

* add sql queries

* fix

* update slot info, fix follower indexing block time issue

* add previous slot info field

* fix

* refactor

* fix sync_state_get

* wip

* fix check

* try

* fix

* finish slot_info test, fix queries

* fix

* cleanup

* wip

* wip

* wip

* feat: RBAC Documentation Drafting (#332)

* chore: wip

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* Update 0005-flutter-app.md

* docs(docs): Use latest docs builders and fix concepts page

* docs(cips): Start drafting the CIPS for milestone 2

* docs(cips): More text for RBAC metadata draft

* docs(cips): WIP updates to draft cip for role registration

* docs(cips): define draft specification for a ULID cbor tag

* docs(cips): Further WIP edits to RBAC

* docs(cips): fix ulid spec binary encoding reference

* docs(cips): Add a tag to the epoch time.

* docs(cips): Add CBOR tag cip for ED25519-BIP32 Keys, Derivation paths and Signatures

* docs(cips): Properly define the field tags to use where known, and clean up Stake Address specification.

* docs(cips): Fix nonce so its reliable without needing blockchain data

* docs(cips): updates

* docs(docs): Add CDDL definition for POC x509 envelope metadata

* fix(vscode): update vscode extension recommendations

* docs(cips): rbac x509 envelope fix

* docs(cips): wip updates to high level docs

* docs(cips): Add overview of cardano transaction processign and data

* docs(cips): update cardano block to be complete for clarity

* docs(cips): fix layout engine

* docs(cips): wip cddl for envelope metadata

* docs(cips): Add cddl specs and diagrams for x509 rbac registration work

* docs(cips): Add full transaction/metadata relationship diagram

* refactor(cips): reorganize documentation ready for drafting descriptive prose about the formats and uses

* docs(cips): add cip draft for catalyst roles using the x509-rbac standard

* docs(cips): Add c509 cddl with restrictions and enhancements for plutus usage

* docs(cips): Metadata envelope specification draft complete

* Update docs/src/catalyst-standards/draft-cips/c509-plutus-restricted-certificate/c509-cert-plutus-restricted.cddl

Co-authored-by: bkioshn <[email protected]>

* Update docs/src/catalyst-standards/draft-cips/c509-plutus-restricted-certificate/c509-cert-plutus-restricted.cddl

Co-authored-by: bkioshn <[email protected]>

* Update docs/src/catalyst-standards/draft-cips/x509-role-registration-metadata/x509-roles.cddl

Co-authored-by: bkioshn <[email protected]>

* Update docs/src/catalyst-standards/draft-cips/x509-role-registration-metadata/x509-roles.cddl

Co-authored-by: bkioshn <[email protected]>

* Update docs/src/catalyst-standards/draft-cips/x509-envelope-metadata/x509-envelope.cddl

Co-authored-by: bkioshn <[email protected]>

* Update docs/src/catalyst-standards/draft-cips/x509-envelope-metadata/x509-envelope.cddl

Co-authored-by: bkioshn <[email protected]>

* Update docs/src/catalyst-standards/draft-cips/x509-envelope-metadata/x509-envelope.cddl

Co-authored-by: bkioshn <[email protected]>

* Update docs/src/catalyst-standards/draft-cips/c509-plutus-restricted-certificate/c509-cert-plutus-restricted.cddl

Co-authored-by: bkioshn <[email protected]>

* docs(cips): Fix time and algorithm comments

* build(frontend): Relax flutter/dart version requirements to last minor release

* docs(cips): wip

* fix(cips): rename draft x509 envelope CIP so its easier to identify

* docs(cips): WIP updates to x509 roles

* fix(cips): rename RBAC definition CIP draft so its easier to identify

* docs(cips): x509 certificate registration format fully defined

* docs(cips): Document the restricted plutus subset.

* docs(cips): Add document detailing how CIP-30 is used to sign the transaction

* fix(cips): remove trailing spaces

* fix(cips): Fix line lengths

* fix(cips): Correct spelling

* fix(cips): spelling

* fix(frontend): revert changes to flutter/dart versions

* fix(frontend): more flutter/dart version corrections

* fix(frontend): Revert flutter files to same as main branch

* fix(frontend): revert more flutter .yml files to those in main

* fix(cips): Fix links between files

* docs(cips): Add catalyst specific role registration documentation

* docs(spelling): fix spelling

---------

Co-authored-by: minikin <[email protected]>
Co-authored-by: bkioshn <[email protected]>

* ci: configure static analysis & code formatting check

* style: formatting

* fix: revert browser installation scripts

* style: format code

* ci: optimize directions include in repo-catalyst-voices-all artifact to include only needed ones

* refactor: remove empty tests

* ci: add melos script to generate test reports

* ci: melos script to generate test report

* style: revert previously generated files formatting

* style: format files

* ci: update melos to exclude generated code form code coverage

* ci: cleanup build script

* ci: generate multiple junit test reports and save them at /test_reports

* ci: depend on melos analyze instead of custom command

* docs: improve melos docs

* ci: remove unused melos scripts

* ci: format files in test & integration_test directories

* ci: break code to make sure CI will report failure for demonstration purposes

* style: fix lint issues

* ci: change WORKDIR after creating the user to make sure it will be owned by that user

* ci: restore root user

* Revert "Merge branch 'main' into feat/collect-flutter-code-coverage"

This reverts commit d0f66b2, reversing
changes made to 39ce401.

* style: format code

* ci: revert test-unit target name

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Lucio Baglione <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Apisit Ritreungroj <[email protected]>
Co-authored-by: Alex Pozhylenkov <[email protected]>
Co-authored-by: Steven Johnson <[email protected]>
Co-authored-by: minikin <[email protected]>
Co-authored-by: bkioshn <[email protected]>
  • Loading branch information
8 people authored Apr 12, 2024
1 parent 805482c commit bb245a1
Show file tree
Hide file tree
Showing 26 changed files with 394 additions and 366 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
with:
earthfile: ./catalyst_voices/
flags:
targets: test-unit
targets: test-report
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
Expand Down
10 changes: 10 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ repo-catalyst-voices-packages:
WORKDIR /repo
COPY --dir catalyst_voices_packages .

SAVE ARTIFACT /repo repo

# repo-catalyst-voices-all - Creates artifacts of all configuration files,
# packages and folders related to catalyst_voices frontend.
repo-catalyst-voices-all:
FROM scratch

WORKDIR /repo
COPY --dir catalyst_voices catalyst_voices_packages utilities melos.yaml pubspec.yaml .

SAVE ARTIFACT /repo repo
30 changes: 23 additions & 7 deletions catalyst_voices/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ VERSION --try --global-cache --arg-scope-and-set 0.7
deps:
FROM debian:bookworm-slim
RUN apt-get update
RUN apt-get install -y git curl unzip bzip2 bash jq gpg
RUN apt-get install -y git curl unzip bzip2 bash jq gpg lcov
COPY --dir test_driver/scripts .
RUN chmod +x scripts/install-chrome-linux64.sh && ./scripts/install-chrome-linux64.sh
RUN chmod +x scripts/install-edge-linux64.sh && ./scripts/install-edge-linux64.sh
Expand All @@ -23,7 +23,9 @@ deps:
RUN flutter --version
RUN flutter doctor -v
RUN flutter config --enable-web
RUN dart pub global activate melos
RUN dart pub global activate junitreport
RUN dart pub global activate coverage

src:
FROM +deps
Expand Down Expand Up @@ -60,6 +62,20 @@ check-flutter-code-generator:
# Check diff between local code and earthly artifacts
RUN diff /tmp/repo_generated lib/generated/catalyst_gateway

check-static-analysis:
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos bootstrap
RUN melos analyze --fatal-infos --fatal-warnings

check-code-formatting:
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos bootstrap
RUN melos run format-check

# Build web version of Catalyst Voices
build:
FROM +src
Expand All @@ -72,12 +88,12 @@ build:
SAVE ARTIFACT web /web AS LOCAL web

test-unit:
FROM +build
WORKDIR /frontend
TRY
RUN flutter test --reporter expanded . --machine | tojunit --output flutter.junit-report.xml
FINALLY
SAVE ARTIFACT flutter.junit-report.xml AS LOCAL flutter-unit-tests.junit-report.xml
FROM +deps
COPY ../+repo-catalyst-voices-all/repo repo/
WORKDIR repo
RUN melos run test-report
WAIT
SAVE ARTIFACT test_reports AS LOCAL test_reports
END

package:
Expand Down
4 changes: 2 additions & 2 deletions catalyst_voices/lib/pages/coming_soon/coming_soon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ final class ComingSoonPage extends StatelessWidget {
decoration: BoxDecoration(
image: DecorationImage(
image: CatalystImage.asset(
VoicesAssets.images.comingSoonBkg.path,
).image,
VoicesAssets.images.comingSoonBkg.path,
).image,
fit: BoxFit.cover,
),
),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;

import 'catalyst_voices_localizations_en.dart' deferred as catalyst_voices_localizations_en;
import 'catalyst_voices_localizations_es.dart' deferred as catalyst_voices_localizations_es;
import 'catalyst_voices_localizations_en.dart'
deferred as catalyst_voices_localizations_en;
import 'catalyst_voices_localizations_es.dart'
deferred as catalyst_voices_localizations_es;

/// Callers can lookup localized strings with an instance of VoicesLocalizations
/// returned by `VoicesLocalizations.of(context)`.
Expand Down Expand Up @@ -59,15 +61,17 @@ import 'catalyst_voices_localizations_es.dart' deferred as catalyst_voices_local
/// be consistent with the languages listed in the VoicesLocalizations.supportedLocales
/// property.
abstract class VoicesLocalizations {
VoicesLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
VoicesLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());

final String localeName;

static VoicesLocalizations? of(BuildContext context) {
return Localizations.of<VoicesLocalizations>(context, VoicesLocalizations);
}

static const LocalizationsDelegate<VoicesLocalizations> delegate = _VoicesLocalizationsDelegate();
static const LocalizationsDelegate<VoicesLocalizations> delegate =
_VoicesLocalizationsDelegate();

/// A list of this localizations delegate along with the default localizations
/// delegates.
Expand All @@ -79,7 +83,8 @@ abstract class VoicesLocalizations {
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates = <LocalizationsDelegate<dynamic>>[
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
Expand Down Expand Up @@ -177,7 +182,8 @@ abstract class VoicesLocalizations {
String get comingSoonDescription;
}

class _VoicesLocalizationsDelegate extends LocalizationsDelegate<VoicesLocalizations> {
class _VoicesLocalizationsDelegate
extends LocalizationsDelegate<VoicesLocalizations> {
const _VoicesLocalizationsDelegate();

@override
Expand All @@ -186,25 +192,27 @@ class _VoicesLocalizationsDelegate extends LocalizationsDelegate<VoicesLocalizat
}

@override
bool isSupported(Locale locale) => <String>['en', 'es'].contains(locale.languageCode);
bool isSupported(Locale locale) =>
<String>['en', 'es'].contains(locale.languageCode);

@override
bool shouldReload(_VoicesLocalizationsDelegate old) => false;
}

Future<VoicesLocalizations> lookupVoicesLocalizations(Locale locale) {


// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en': return catalyst_voices_localizations_en.loadLibrary().then((dynamic _) => catalyst_voices_localizations_en.VoicesLocalizationsEn());
case 'es': return catalyst_voices_localizations_es.loadLibrary().then((dynamic _) => catalyst_voices_localizations_es.VoicesLocalizationsEs());
case 'en':
return catalyst_voices_localizations_en.loadLibrary().then((dynamic _) =>
catalyst_voices_localizations_en.VoicesLocalizationsEn());
case 'es':
return catalyst_voices_localizations_es.loadLibrary().then((dynamic _) =>
catalyst_voices_localizations_es.VoicesLocalizationsEs());
}

throw FlutterError(
'VoicesLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.'
);
'VoicesLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.');
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ class VoicesLocalizationsEn extends VoicesLocalizations {
String get comingSoonTitle2 => 'soon';

@override
String get comingSoonDescription => 'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
String get comingSoonDescription =>
'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class VoicesLocalizationsEs extends VoicesLocalizations {
String get passwordHintText => 'Mi1ContraseñaSecreta';

@override
String get passwordErrorText => 'La contraseña debe tener al menos 8 caracteres';
String get passwordErrorText =>
'La contraseña debe tener al menos 8 caracteres';

@override
String get loginTitleText => 'Acceso';
Expand All @@ -44,5 +45,6 @@ class VoicesLocalizationsEs extends VoicesLocalizations {
String get comingSoonTitle2 => 'soon';

@override
String get comingSoonDescription => 'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
String get comingSoonDescription =>
'Project Catalyst is the world\'s largest decentralized innovation engine for solving real-world challenges.';
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'dart:async';

import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:catalyst_voices_services/generated/catalyst_gateway/cat_gateway_api.enums.swagger.dart' as enums;
import 'package:catalyst_voices_services/generated/catalyst_gateway/cat_gateway_api.enums.swagger.dart'
as enums;
import 'package:catalyst_voices_services/generated/catalyst_gateway/cat_gateway_api.swagger.dart';
import 'package:chopper/chopper.dart';
import 'package:result_type/result_type.dart';
Expand All @@ -15,9 +16,9 @@ import 'package:result_type/result_type.dart';
// The repository uses, under the hood, the [CatGatewayApi] directly generated
// from backend OpenAPI specification.
//
// To use the repository is necessary to initialize it by specifying the API
// To use the repository is necessary to initialize it by specifying the API
// base URL:
//
//
// ```dart
// final repository = CatalystDataGatewayRepository(Uri.parse('https://example.org/api'));
// ```
Expand All @@ -28,7 +29,7 @@ import 'package:result_type/result_type.dart';
// ```dart
// final health_status = await repository.getHealthLive();
// ```
//
//
// fetch staked ADA by stake address:
//
// ```dart
Expand All @@ -48,11 +49,10 @@ final class CatalystDataGatewayRepository {
final CatGatewayApi _catGatewayApi;

CatalystDataGatewayRepository(
Uri baseUrl,
{CatGatewayApi? catGatewayApiInstance,}
)
: _catGatewayApi = catGatewayApiInstance ??
CatGatewayApi.create(baseUrl: baseUrl);
Uri baseUrl, {
CatGatewayApi? catGatewayApiInstance,
}) : _catGatewayApi =
catGatewayApiInstance ?? CatGatewayApi.create(baseUrl: baseUrl);

Future<Result<void, NetworkErrors>> getHealthStarted() async {
try {
Expand Down Expand Up @@ -120,10 +120,10 @@ final class CatalystDataGatewayRepository {
Result<void, NetworkErrors> _emptyBodyOrThrow(Response<dynamic> response) {
// `bodyOrThrow` from chopper can't be used when the body is empty (like in
// case the endpoint replies with 204) because it would throw an exception
// as a false positive.
// as a false positive.
if (response.isSuccessful) {
return Success(null);
}
throw ChopperHttpException(response);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,12 @@ void main() {
});

test('getCardanoSyncState success', () async {
const blockHash =
'0x0000000000000000000000000000000000000000000000000000000000000000';

final syncState = SyncState(
slotNumber: 5,
blockHash:
'0x0000000000000000000000000000000000000000000000000000000000000000',
blockHash: blockHash,
lastUpdated: DateTime.utc(1970),
);
final repository = setupRepository<SyncState>(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ final class CatalystPlatform {
static bool get isWindows => Platform.isWindows;

static Map<PlatformKey, bool> get identifiers => {
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ final class CatalystPlatform {
];
return mobileIdentifiers.any(userAgent.contains);
}

static Map<PlatformKey, bool> get identifiers => {
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};
PlatformKey.android: isAndroid,
PlatformKey.desktop: isDesktop,
PlatformKey.fuchsia: isFuchsia,
PlatformKey.iOS: isIOS,
PlatformKey.linux: isLinux,
PlatformKey.macOS: isMacOS,
PlatformKey.mobile: isMobile,
PlatformKey.mobileWeb: isMobileWeb,
PlatformKey.web: isWeb,
PlatformKey.webDesktop: isWebDesktop,
PlatformKey.windows: isWindows,
};

const CatalystPlatform._();
}
Loading

0 comments on commit bb245a1

Please sign in to comment.