Skip to content

Commit

Permalink
style: sort methods alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommytrg committed Aug 25, 2023
1 parent 9dd8de1 commit d4fbc00
Show file tree
Hide file tree
Showing 6 changed files with 732 additions and 9 deletions.
673 changes: 673 additions & 0 deletions compare.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/bloc/crypto/crypto_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CryptoBloc extends Bloc<CryptoEvent, CryptoState> {

Future<void> _cryptoInitializeWalletEvent(
CryptoInitializeWalletEvent event, Emitter<CryptoState> emit) async {
print("----------2-----------");
/// setup default default structure for database and unlock it
emit(
CryptoInitializingWalletState(
Expand Down Expand Up @@ -236,7 +237,7 @@ class CryptoBloc extends Bloc<CryptoEvent, CryptoState> {
ApiDatabase db = Locator.instance<ApiDatabase>();
String key = await db.getKeychain();
final masterKey = key != '' ? key : event.password;

print("----------1-----------");
apiCrypto.setInitialWalletData(
event.walletName,
event.keyData,
Expand Down
1 change: 1 addition & 0 deletions lib/shared/api_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class ApiDatabase {

Future<bool> addWallet(Wallet wallet) async {
_wallets[wallet.name] = wallet;
print("addWallet: $wallet");
return await _processIsolate(
method: 'add', params: {'type': 'wallet', 'value': wallet.jsonMap()});
}
Expand Down
12 changes: 6 additions & 6 deletions lib/util/storage/database/database_isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import 'database_service.dart';

Map<String, Function(DatabaseService, SendPort, Map<String, dynamic>)>
methodMap = {
'configure': _configure,
'add': _addRecord,
'configure': _configure,
'delete': _deleteRecord,
'deleteDatabase': _deleteDatabase,
'update': _updateRecord,
'setPassword': _setPassword,
'verifyPassword': _verifyPassword,
'masterKeySet': _masterKeySet,
'loadWallets': _getAllWallets,
'getKeychain': _getKeychain,
'loadWallets': _getAllWallets,
'lock': _lock,
'masterKeySet': _masterKeySet,
'setPassword': _setPassword,
'update': _updateRecord,
'verifyPassword': _verifyPassword,
};

class DatabaseIsolate {
Expand Down
4 changes: 2 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import FlutterMacOS
import Foundation

import mobile_scanner
import path_provider_foundation
import path_provider_macos
import screen_retriever
import shared_preferences_foundation
import shared_preferences_macos
import url_launcher_macos
import window_manager

Expand Down
48 changes: 48 additions & 0 deletions test/storage/read_through_in_memory_cache_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:my_wit_wallet/util/storage/cache/read_through_in_memory_cache.dart';
import 'package:test/test.dart';

void main() {
group('Storage implementation of read through cache pattern in memory', () {
test('Should call fetch callback if it\'s first time getting the value',
() async {
int timesCalled = 0;
String expectedValue = "Potato";

ReadThroughInMemoryCache<String> cache =
ReadThroughInMemoryCache((p0) async {
timesCalled = timesCalled += 1;

await Future.delayed(Duration(seconds: 0));

return expectedValue;
});

expect(await cache.get("whatever"), expectedValue);
expect(timesCalled, 1);
});

test('Should NOT call fetch callback if it\'s the second time getting the value',
() async {
int timesCalled = 0;
String expectedValue = "Potato";

ReadThroughInMemoryCache<String> cache =
ReadThroughInMemoryCache((p0) async {
timesCalled = timesCalled += 1;

await Future.delayed(Duration(seconds: 0));

return expectedValue;
});


// call get multiple times
expect(await cache.get("whatever"), expectedValue);
expect(await cache.get("whatever"), expectedValue);
expect(await cache.get("whatever"), expectedValue);
expect(await cache.get("whatever"), expectedValue);

expect(timesCalled, 1);
});
});
}

0 comments on commit d4fbc00

Please sign in to comment.