diff --git a/AlphaWallet/Transactions/Storage/TransactionsStorage.swift b/AlphaWallet/Transactions/Storage/TransactionsStorage.swift index 1ecf25a9c..275841511 100644 --- a/AlphaWallet/Transactions/Storage/TransactionsStorage.swift +++ b/AlphaWallet/Transactions/Storage/TransactionsStorage.swift @@ -283,6 +283,15 @@ class TransactionDataStore { } } + func deleteAllForTestsOnly() { + store.performSync { realm in + try? realm.safeWrite { + realm.delete(realm.objects(LocalizedOperationObject.self)) + realm.delete(realm.objects(Transaction.self)) + } + } + } + func writeJsonForTransactions(toUrl url: URL, server: RPCServer) { do { let data = try functional.generateJsonForTransactions(transactionStorage: self, server: server, toUrl: url) @@ -291,7 +300,7 @@ class TransactionDataStore { } catch { verboseLog("Error writing transactions for \(server) to JSON: \(url.absoluteString) error: \(error)") } - } + } } extension TransactionDataStore: Erc721TokenIdsFetcher { diff --git a/AlphaWalletTests/Coordinators/InCoordinatorTests.swift b/AlphaWalletTests/Coordinators/InCoordinatorTests.swift index f0844cab0..cebfbfbec 100644 --- a/AlphaWalletTests/Coordinators/InCoordinatorTests.swift +++ b/AlphaWalletTests/Coordinators/InCoordinatorTests.swift @@ -124,7 +124,7 @@ class InCoordinatorTests: XCTestCase { c1.start(animated: false) - XCTAssertEqual(c2.keystore.currentWallet, account1) + XCTAssertEqual(c2.keystore.currentWallet, account2) } func testShowSendFlow() { diff --git a/AlphaWalletTests/Settings/Coordinators/SettingsCoordinatorTests.swift b/AlphaWalletTests/Settings/Coordinators/SettingsCoordinatorTests.swift index 127a23521..9aee91e2b 100644 --- a/AlphaWalletTests/Settings/Coordinators/SettingsCoordinatorTests.swift +++ b/AlphaWalletTests/Settings/Coordinators/SettingsCoordinatorTests.swift @@ -34,7 +34,7 @@ class SettingsCoordinatorTests: XCTestCase { .sink { value in deletedWallet = value expectation.fulfill() - storage.deleteAll() + storage.deleteAllForTestsOnly() } walletAddressesStore.removeAddress(wallet) diff --git a/AlphaWalletTests/Transactions/Storage/TransactionsStorageTests.swift b/AlphaWalletTests/Transactions/Storage/TransactionsStorageTests.swift index 50261a982..f797c45a9 100644 --- a/AlphaWalletTests/Transactions/Storage/TransactionsStorageTests.swift +++ b/AlphaWalletTests/Transactions/Storage/TransactionsStorageTests.swift @@ -67,7 +67,7 @@ class TransactionsStorageTests: XCTestCase { XCTAssertEqual(1, storage.count) - XCTAssertEqual(two, storage.transactions(forServer: .main).first) + XCTAssertEqual(two.primaryKey, storage.transactions(forServer: .main).first!.primaryKey) } func testDeleteAll() { @@ -80,7 +80,7 @@ class TransactionsStorageTests: XCTestCase { XCTAssertEqual(2, storage.count) - storage.deleteAll() + storage.deleteAllForTestsOnly() XCTAssertEqual(0, storage.count) }