ZcashLightClientKit/Tests/OfflineTests
Michal Fousek 2bbc5800bd [#888] Make actor from ZcashRustBackendWelding
Closes #888.

- `ZcashRustBackend` is actor now. So majority of methods in this actor
  are now async.
- Some methods stayed `static` in `ZcashRustBackend`. It would be hard
  to pass instance of the `ZcashRustBackend` to the places where these
  methods are used in static manner. And it would change lot of APIs.
  But it isn't problem from technical perspective because these methods
  would be `nonisolated` otherwise.
- Methods `lastError()` and `getLastError()` in `ZcashRustBackend` are
  now private. This makes sure that ther won't be aby race condition
  between other methods and these two error methods.
- All the methods for which was `lastError()` used in code now throw
  error. So `lastError()` is no longer needed outside of the
  `ZcashRustBackend`.
- There are in the public API related to `DerivationTool`.
- `DerivationTool` now requires instance of the `ZcashRustBackend`. And
  `ZcashRustBackend` isn't public type. So `DerivationTool` doesn't have
  any public constructor now. It can be created only via
  `Initializer.makeDerivationTool()` instance method.
- `deriveUnifiedSpendingKey()` and `deriveUnifiedFullViewingKey()` in
  `DerivationTool` are now async. It is because these are using
  `ZcashRustBackend` inside. `DerivationTool` offers alternative
  (closure and combine) APIs. But downside is that there is no sync API
  to dervie spending key or viewing key.
- Some methods of the `DerivationTool` are now static. These methods
  don't use anything that requires instance of the `DerivationTool`
  inside.

[#888] Use Sourcery to generate mocks

- I wrote mock for `Synchronizer` manually. And it's tedious and long
  and boring work.
- Now `ZcashRustBackendWelding` is changed a lot so it means
  `MockRustBackend` must be changed a lot. So I decided to introduce
  `sourcery` to generate mocks from protocols so we don't have to do it
  manually ever.
- To generate mocks go to `ZcashLightClientKit/Tests/TestUtils/Sourcery`
  directory and run `generateMocks.sh` script.
- Your protocol must be mentioned in `AutoMockable.swift` file.
  Generated mocks are in `AutoMockable.generated.swift` file.

[#888] Fix Offline tests

- Offline tests target now runs and tests are green.
- There is log of changes in tests. But logic is not changed.
- Updated `AutoMockable.stencil` so sourcery is able to generate mock as
  actor when protocol is marked with: `// sourcery: mockActor`.
- Last few updates in `ZcashRustBackendWelding`. In previous PR `rewindCacheToHeight`
  methods was overlooked and it didn't throw error.
- Removed `MockRustBackend` and using generated
  `ZCashRustBackendWeldingMock` instead.
- Using generated `SynchronizerMock`.

[#888] Fix NetworkTests

- Changed a bit how rust backend mock is used in the tests. Introduced
  `RustBackendMockHelper`. There are some state variables that must be
  preserved within one instance of the mock. This helper does exactly
  this. It keeps this state variables in the memory and helping mock to
  work as expected.

[#888] Fix Darkside tests

Create ZcashKeyDeriving internal protocol

Use New DerivationTool that does not require RustBackend

Remove duplicated methods that had been copied over

[#888] Fix potentially broken tests

I broke the tests because I moved `testTempDirectory` from each
`TestCase` to the `Environment`. By this I caused that each tests uses
exactly same URL. Which is directly against purpose of
`testTempDirectory`.

So now each test calls this one and store it to local variable. So each
test has unique URL.

[#888] Add ability to mock nonisolated methods to AutoMockable.stencil

[#888] Add changelog and fix the documentation in ZcashRustBackendWelding

[#888] Rename derivation rust backend protocol and remove static methods

- Renamed `ZcashKeyDeriving` to `ZcashKeyDerivationBackendWelding`. So
  the naming scheme is same as for `ZcashRustBackendWelding`.
- `ZcashKeyDerivationBackend` is now struct instead of enum.
- Methods in `ZcashKeyDerivationBackendWelding` (except one) are no
  longer static. Because of this the respective methods in
  `DerivationTool` aren't also static anymore.
2023-04-11 17:51:28 +02:00
..
DerivationToolTests [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
BirthdayTests.swift [#778] Add swiflint config file only for tests 2023-02-13 13:36:58 +01:00
BlockBatchValidationTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
ClosureSynchronizerOfflineTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
CombineSynchronizerOfflineTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
CompactBlockProcessorOfflineTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
CompactBlockRepositoryTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
ErrorLocalizationTests.swift [#711] Add Swiftlint plug in to SDK (#722) 2023-01-18 17:09:04 +01:00
FsBlockStorageTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
InitializerOfflineTests.swift [#209] Add support for multiple instances of the SDKSynchronizer 2023-03-27 20:42:52 +02:00
InternalSyncProgressTests.swift [#209] Add support for multiple instances of the SDKSynchronizer 2023-03-27 20:42:52 +02:00
MemoTests.swift [#778] Add swiflint config file only for tests 2023-02-13 13:36:58 +01:00
NotesRepositoryTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
NullBytesTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
PagedTransactionRepositoryTests.swift [#484] Use async for TransactionsRepository 2023-03-28 10:17:14 +02:00
PendingTransactionRepositoryTests.swift [#209] Add support for multiple instances of the SDKSynchronizer 2023-03-27 20:42:52 +02:00
RawTransactionTests.swift [#796] Fix tests 2023-02-16 17:14:31 +01:00
RecipientTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
SynchronizerOfflineTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
TransactionRepositoryTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
TxIdTests.swift [#778] Add swiflint config file only for tests 2023-02-13 13:36:58 +01:00
UndescribableTests.swift [#778] Add swiflint config file only for tests 2023-02-13 13:36:58 +01:00
UnifiedTypecodesTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
WalletTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
ZatoshiTests.swift Fix typos 2022-12-31 12:50:16 +02:00
ZcashRustBackendTests.swift [#888] Make actor from ZcashRustBackendWelding 2023-04-11 17:51:28 +02:00
Zip302MemoTests.swift Update code to to comply better with linter rules 2023-02-13 12:18:08 +01:00