fix tests

This commit is contained in:
julian 2023-07-26 11:54:46 -06:00
parent 6733a367e3
commit dbcb567d6b
3 changed files with 42 additions and 15 deletions

View file

@ -11,9 +11,7 @@ import 'package:mockito/mockito.dart';
import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart';
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
import 'package:stackwallet/models/lelantus_coin.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/models/lelantus_fee_data.dart';
import 'package:stackwallet/models/paymint/transactions_model.dart' as old;
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
@ -114,10 +112,7 @@ void main() {
final result = await staticProcessRestore(txData, message, currentHeight);
expect(result, isA<Map<String, dynamic>>());
expect(result["mintIndex"], 8);
expect(result["jindex"], [2, 4, 6]);
expect(
result["_lelantus_coins"], isA<List<Map<dynamic, LelantusCoin>>>());
expect(result["_lelantus_coins"], isA<List<LelantusCoin>>());
expect(result["newTxMap"], isA<Map<String, Transaction>>());
});
@ -532,18 +527,10 @@ void main() {
group("FiroWallet service class functions that depend on shared storage", () {
const testWalletId = "testWalletID";
const testWalletName = "Test Wallet";
bool hiveAdaptersRegistered = false;
setUp(() async {
await setUpTestHive();
if (!hiveAdaptersRegistered) {
hiveAdaptersRegistered = true;
// Registering Lelantus Model Adapters
Hive.registerAdapter(LelantusCoinAdapter());
}
final wallets = await Hive.openBox<dynamic>('wallets');
await wallets.put('currentWalletName', testWalletName);
});
@ -1204,13 +1191,33 @@ void main() {
txHash: BuildMintTxTestParams.utxoInfo["txid"] as String,
coin: Coin.firo,
)).thenAnswer((_) async => BuildMintTxTestParams.cachedClientResponse);
when(cachedClient.getAnonymitySet(
groupId: "1",
coin: Coin.firo,
)).thenAnswer(
(_) async => GetAnonymitySetSampleData.data,
);
when(cachedClient.getAnonymitySet(
groupId: "2",
coin: Coin.firo,
)).thenAnswer(
(_) async => GetAnonymitySetSampleData.data,
);
when(client.getBlockHeadTip()).thenAnswer(
(_) async => {"height": 455873, "hex": "this value not used here"});
when(client.getLatestCoinId()).thenAnswer((_) async => 2);
when(mainDB.getAddress("${testWalletId}buildMintTransaction", any))
.thenAnswer((realInvocation) async => null);
when(mainDB.getHighestUsedMintIndex(
walletId: "${testWalletId}submitHexToNetwork"))
.thenAnswer((_) async => null);
when(mainDB.getHighestUsedMintIndex(
walletId: "testWalletIDbuildMintTransaction"))
.thenAnswer((_) async => null);
final firo = FiroWallet(
walletName: testWalletName,
walletId: "${testWalletId}buildMintTransaction",

View file

@ -1151,4 +1151,14 @@ class MockMainDB extends _i1.Mock implements _i9.MainDB {
returnValue: _i5.Future<void>.value(),
returnValueForMissingStub: _i5.Future<void>.value(),
) as _i5.Future<void>);
@override
_i5.Future<int?> getHighestUsedMintIndex({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#getHighestUsedMintIndex,
[],
{#walletId: walletId},
),
returnValue: _i5.Future<int?>.value(),
) as _i5.Future<int?>);
}

View file

@ -3496,4 +3496,14 @@ class MockMainDB extends _i1.Mock implements _i14.MainDB {
returnValue: _i19.Future<void>.value(),
returnValueForMissingStub: _i19.Future<void>.value(),
) as _i19.Future<void>);
@override
_i19.Future<int?> getHighestUsedMintIndex({required String? walletId}) =>
(super.noSuchMethod(
Invocation.method(
#getHighestUsedMintIndex,
[],
{#walletId: walletId},
),
returnValue: _i19.Future<int?>.value(),
) as _i19.Future<int?>);
}