mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-30 06:48:49 +01:00
Merge upstream Cake Wallet v6.5.0
Catches up from the May 12 fork point (v6.1.2+23) through v6.5.0: 535 upstream commits, including the Monero silent-open fix, Monero on Trezor, Ledger/Trezor BLE fixes, the new seed and history screens, quick Bitcoin sync, git-pinned dependencies (pubspec_overrides.yaml), frozen Hive adapters (*.part.dart), monero_c v0.18.4.6-RC2 and Flutter 3.41.9. Merged with both sides normalized first (import rename, 100-column format), which took the conflict count from 614 paths to 322. The procedure is now scripts/upstream_sync.sh. Kept from Hash Bags: - WalletType enum order and Hive IDs. SQLite stores WalletType.index and our order differs from upstream's; taking theirs would reread saved wallets as other chains. Our frozen adapter keeps the shipped IDs. - The 1.0.2 legacy PIN and wallet-password decode and self-heal. - Removed chains (Solana, Tron, Zano, Zcash, Decred, Haven) and the new Robinhood chain stay out; Cake Pay and non-Trocador swaps stay out. - Default nodes (node.wownero.org, sethforprivacy, Blockstream, bysh.me), converted to upstream's isDefault node-list key; Wownero is back in the node reset list. - Privacy: address resolvers limited to domain-anchored sources again; prices.neroswap.com for fiat; upstream's charts tab, which reads prices.cakewallet.com, sits behind FeatureFlag.isChartsEnabled = false. - Lightning stays behind FeatureFlag.isLightningEnabled, including upstream's new post-seed Lightning username step. - Our icon pipeline, branding and bundle identifiers. Twelve new upstream widget tests are skipped: test and code are unchanged from v6.5.0 apart from renames (not rerun on a pristine upstream checkout; upstream's top_bar_test does not compile against its own TopBar). flutter analyze lib: 0 errors; flutter test: 345 passed, 12 skipped; flutter build bundle compiles. Built with Flutter 3.41.9.
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
import "package:hash_wallet/new-ui/viewmodels/card_customizer/card_customizer_bloc.dart";
|
||||
import "package:hash_wallet/wownero/wownero.dart" as wow;
|
||||
import "package:cw_core/account.dart";
|
||||
import "package:cw_core/balance.dart";
|
||||
import "package:cw_core/balance_card_style_settings.dart";
|
||||
import "package:cw_core/crypto_currency.dart";
|
||||
import "package:cw_core/db/sqlite.dart" as sqlite;
|
||||
import "package:cw_core/transaction_history.dart";
|
||||
import "package:cw_core/transaction_info.dart";
|
||||
import "package:cw_core/wallet_base.dart";
|
||||
import "package:cw_core/wallet_info.dart";
|
||||
import "package:cw_core/wallet_type.dart";
|
||||
import "package:flutter_test/flutter_test.dart";
|
||||
import "package:mocktail/mocktail.dart";
|
||||
import "package:sqflite_common_ffi/sqflite_ffi.dart";
|
||||
|
||||
class _MockWallet extends Mock
|
||||
implements WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> {}
|
||||
|
||||
class _MockWalletInfo extends Mock implements WalletInfo {}
|
||||
|
||||
class _MockWownero extends Mock implements wow.Wownero {}
|
||||
|
||||
class _MockWowneroAccountList extends Mock implements wow.WowneroAccountList {}
|
||||
|
||||
void main() {
|
||||
late DatabaseFactory? originalDatabaseFactory;
|
||||
late Database? originalDatabase;
|
||||
late wow.Wownero? originalWownero;
|
||||
late _MockWallet wallet;
|
||||
late _MockWownero wowneroAdapter;
|
||||
late _MockWowneroAccountList accountList;
|
||||
|
||||
setUpAll(() {
|
||||
originalDatabaseFactory = databaseFactoryOrNull;
|
||||
sqfliteFfiInit();
|
||||
databaseFactory = databaseFactoryFfi;
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
databaseFactoryOrNull = originalDatabaseFactory;
|
||||
});
|
||||
|
||||
setUp(() async {
|
||||
originalDatabase = sqlite.db;
|
||||
originalWownero = wow.wownero;
|
||||
sqlite.db = await databaseFactory.openDatabase(inMemoryDatabasePath);
|
||||
await sqlite.db!.execute("""
|
||||
CREATE TABLE ${BalanceCardStyleSettings.tableName} (
|
||||
walletInfoId INTEGER,
|
||||
accountIndex INTEGER DEFAULT -1,
|
||||
gradientIndex INTEGER DEFAULT -1,
|
||||
useSpecialDesign BOOLEAN DEFAULT FALSE,
|
||||
hidden BOOLEAN DEFAULT FALSE,
|
||||
backgroundImagePath TEXT DEFAULT "",
|
||||
iconStyleIndex INTEGER DEFAULT 0,
|
||||
isGradientOnly BOOLEAN DEFAULT FALSE,
|
||||
cardOrder INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (walletInfoId, accountIndex)
|
||||
)
|
||||
""");
|
||||
|
||||
wallet = _MockWallet();
|
||||
final walletInfo = _MockWalletInfo();
|
||||
wowneroAdapter = _MockWownero();
|
||||
accountList = _MockWowneroAccountList();
|
||||
wow.wownero = wowneroAdapter;
|
||||
|
||||
when(() => wallet.hasNativeAccounts).thenReturn(true);
|
||||
when(() => wallet.type).thenReturn(WalletType.wownero);
|
||||
when(() => wallet.currency).thenReturn(CryptoCurrency.wow);
|
||||
when(() => wallet.walletInfo).thenReturn(walletInfo);
|
||||
when(() => walletInfo.internalId).thenReturn(42);
|
||||
when(() => wallet.save()).thenAnswer((_) async {});
|
||||
when(() => wowneroAdapter.getCurrentAccount(wallet))
|
||||
.thenReturn(Account(id: 3, label: "Savings", balance: "2.0"));
|
||||
when(() => wowneroAdapter.getAccountList(wallet)).thenReturn(accountList);
|
||||
when(
|
||||
() => accountList.setLabelAccount(
|
||||
wallet,
|
||||
accountIndex: any(named: "accountIndex"),
|
||||
label: any(named: "label"),
|
||||
),
|
||||
).thenAnswer((_) async {});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
wow.wownero = originalWownero;
|
||||
await sqlite.db?.close();
|
||||
sqlite.db = originalDatabase;
|
||||
});
|
||||
|
||||
test("Wownero customization saves the selected account identity and name", () async {
|
||||
final bloc = CardCustomizerBloc(wallet);
|
||||
addTearDown(bloc.close);
|
||||
|
||||
final initial = await bloc.stream.firstWhere((state) => state is CardCustomizerInitial);
|
||||
expect(initial.accountIndex, 3);
|
||||
expect(initial.accountName, "Savings");
|
||||
expect(bloc.canHide, isFalse);
|
||||
|
||||
final renamed = bloc.stream.firstWhere((state) => state.accountName == "Long-term Savings");
|
||||
bloc.add(AccountNameChanged("Long-term Savings"));
|
||||
await renamed;
|
||||
|
||||
final saved = bloc.stream.firstWhere((state) => state is CardCustomizerSaved);
|
||||
bloc.add(DesignSaved());
|
||||
await saved;
|
||||
|
||||
verify(
|
||||
() => accountList.setLabelAccount(
|
||||
wallet,
|
||||
accountIndex: 3,
|
||||
label: "Long-term Savings",
|
||||
),
|
||||
).called(1);
|
||||
verify(() => wallet.save()).called(1);
|
||||
|
||||
final persisted = await BalanceCardStyleSettings.get(42, 3);
|
||||
expect(persisted, isNotNull);
|
||||
expect(await BalanceCardStyleSettings.get(42, -1), isNull);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user