Commit Graph

11 Commits

Author SHA1 Message Date
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
Michal Fousek d09b00cabe [#795] Include sapling-spend file into bundle for tests
Closes #795

- Added structure `SaplingParamsSourceURL` which holds source URLs for
  sapling-spend file and sapling-output file. URLs are ultimately passed
  to `SaplingParameterDownloader`.
- This is done so it's possible to pass different URLs when running
  tests.
- sapling-spend file and sapling-output file are in tests bundle. And
  when running tests these files are loaded from bundle and not from
  network.
2023-02-20 10:03:16 +01:00
Daniel Haight 86d1257ab5 Remove dependecy on rust sources 2022-02-28 17:03:20 +00:00
Francisco Gindre 91bb371f34 add '.vscode' folder to gitignore 2021-04-12 13:11:12 -03:00
Francisco Gindre e0ceae48df patch gitignore 2020-01-15 18:02:46 -03:00
Francisco Gindre 60ea9d6737
Block downloading + storing (#4)
* Initial scaffold for Block Downloader

* (Failing) init Wallet test

* Ignore generated files

* Inject endpoint address on tests

* Simple Downloader + Tests

* CompactBlockDownloader latestBlockHeight, rewind + tests

* remover awful sync functions

* Compact Block processor scaffold

* Block Downloader + tests
[WIP] Block Processor

* Synchronous getBlockRange

* CompactBlock downloading sync + tests

* Sync CompactBlock Storage + Tests

* Rename Storage to FakeStorage

* WIP Blockdownloader test, block storage tests

* Fix carthage import for SQLite.framework

* SQLite Storage implementation for CompactBlocks + Tests

* Housekeeping, TestDbBuilder and other utils to their own place

* Integrated CompactBlockStorage to Downloader Tests

* Get latestBlockHeight from wallet

* move FakeStorage class to test utils

* Add ZcashLightClientKit import to moved file

* data db initialization + test

* ZcashOperation, CompactBlockDownloadOperation + tests. BlockDAO, latestScannedHeight

* Download and scan blocks. Download Operation. Scan Operation. Tests.

* cleanup test

* Updated readme
2019-10-18 15:45:19 -03:00
Francisco Gindre 6d07025483 Carthage Example project 2019-09-10 20:37:53 -03:00
Francisco Gindre 3806526aaf Cocoapods Support + Example Project 2019-09-09 12:30:38 -03:00
Jack Grigg 9ca270ffd8 Empty iOS Framework 2019-06-28 10:09:53 +01:00
Jack Grigg bac9957f2b Initial implementation of account initialization and address fetching
Errors are indicated by returning a NULL-equivalent value, and functions
are provided to query the last error message.
2019-06-28 10:09:35 +01:00
Jack Grigg 3ca39955ea Initial Rust library 2019-06-28 10:06:17 +01:00