Closes#1111
- `InternalSyncProgress` has now new disk storage implementation:
`InternalSyncProgressDiskStorage`.
- When then `UserDefaults` was used as disk storage there were no IO errors
to handle. But now the code in `InternalSyncProgressDiskStorage`
writes to files and reads from files. So there are errors to handle.
Because of this protocol `InternalSyncProgressStorage` changed a bit
and API of `InternalSyncProgress` changed a bit. Now all the functions
throws.
- It is possible to make progress storage IO errors silent but I think
that storing of the progress is very essential to the sync process. So
I think that when progress storage fails then the sync process should
fail.
- `Initializer` has new parameter `generalStorageURL`. It is directory
where `InternalSyncProgressDiskStorage` stores progress files. In
future this can be used for storing any data the SDK wants.
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.
Closes#469.
- Methods defined in `ZcashRustBackendWelding` protocol which are doing
some IO operations are now async.
- `Initializer` no longer have methods to get balance. Only
`Synchronizer` now have these methods. These methods are newly async.
And `Initilializer` doesn't have alternative APIs.
- There is lot of changes in tests but those are mostly adding `await`.
No logic is changed.
Closes#209.
[#845] Introduce ZcashSynchronizerAlias enum
Closes#845.
[#852] SDKSynchronizer using queues label based on the alias
Closes#852.
[#847] Remove posibility to use DatabaseStorageManager as singleton
Closes#847.
[#850] Remove synchronizerConnectionStateChanged notification
Closes#850.
[#855] Add check if the Alias is already used
Closes#855
- Added `UsedAliasesChecker` utility which is used to register aliases
that are in use.
- `prepare()` and `wipe()` methods now check if the current alias can't
be used and if not then `InitializerError.aliasAlreadyInUse` is
thrown/emitted.
- Some public methods that could cause harm if used with the Alias that
is already in use now throw `SynchronizerError.notPrepared`. Thanks to
this the client app is forced to call `prepare()` first. And
`prepare()` does check for the Alias.
- Added tests for new conditions.
[#849] Make InternalSyncProgress aware of the Alias
Closes#849.
[#853] Only instance with default Alias migrates legacy cache DB
Closes#853.
[#851] Apply the Alias to the URLs
Closes#851.
- `Initializer` now updates paths according to alias before paths are
used anywhere in the SDK.
- Paths update can fail. It would be incovenient for the client apps to
handle errors thrown from `Initiliazer` constructor. So the error is
then handled in `SDKSynchronizer.prepare()` or `SDKSynchronizer.wipe()`.
[#846] Stop using SDKMetrics as singleton (#862)
- metrics are not longer a singleton
- tests fixed
- metrics outside init of the synchronizer
[#848] Make logger aware of the alias
- logger is now an instance passed throughout the sdk instead of a static proxy
[#848] Make logger aware of the alias (#868)
- comments addressed
[#848] Make logger aware of the alias (#868)
- returning protocol back
Fix typos
[#856] Add possibility to test multiple synchronizers in the sample app
Closes#856.
- Added `alias` property to `Synchronizer`.
- Added `SyncBlocksListViewController` which provides UI to use multiple
synchronizers at once.
[#209] Add changelog
- Add changelog for #209.
- Overall improve readability of the rendered changelog. Tickets
references are now prefixed with `###` instead of `- `.
Fix compilation
Closes#771
- Renamed `cacheDirectory` param in `FSCompactBlockRepository`
constructor to `fsBlockDbRoot`.
- Pass same paths to `FSCompactBlockRepository` and `FSMetadataStore`
from tests.
Closes https://github.com/zcash/ZcashLightClientKit/issues/697
Closes https://github.com/zcash/ZcashLightClientKit/issues/720
Closes https://github.com/zcash/ZcashLightClientKit/issues/587
Closes https://github.com/zcash/ZcashLightClientKit/issues/667
Closes https://github.com/zcash/ZcashLightClientKit/issues/443
Closes https://github.com/zcash/ZcashLightClientKit/issues/754
- [#790] Fix ShieldFundsTests
Closes#790
Removes comments on `ShieldFundsTests` since those issues have been fixed
Depends on zcash-light-client-ffi changes that adopt newer versions of
librustzcash crates `zcash_primitives 0.10`, `zcash_client_backend 0.7`,
`zcash_proofs 0.10`, `zcash_client_sqlite 0.5.0`.
Also allows wallets to define a shielding_threshold and will set
foundations to customize minimum confirmations for balances, spends
and shielding operations.
**Test Bootstrapping**
- `ZcashCompactBlockDescriptor`: struct that holds functions to
describe blocks as filenames and compare those filenames
`ZcashCompactBlockDescriptor.live` has the actual implementation
but it can be replaced by mocks if needed on Tests
main implementations are held under `FSCompactBlockRepository.filenameDescription` and `FSCompactBlockRepository.filenameComparison` on a separate extention
`DirectoryListingProviders` provide two default implementations of listing a
directory deterministically. `FileManager` does not define a sorting and needs to be done in-memory by calling `.sorted()` on the resulting collection. If this
is a big toll on performance it can be changed to a POSIX implementation but
this is good for now.
`ZcashCompactBlockDescriptor` adds a `height` helper function to
turn a filename into the height of the block stored.
Implemented `func latestHeight() throws -> BlockHeight ` that
returns the blockheight by querying the cache directory in a sorted
fashion and getting the last value and turning the filename into a
`BlockHeight`
Added `Meta` struct to ZcashCompactBlock.
Tests implemented:
- `filterBlockFiles`
- `testClearTheCache`
- `testLatestHeightEmptyCacheThrows`
- `testLatestHeightEmptyCacheThrowsAsync`
- `testRewindEmptyCacheDoesNothing`
- `testRewindEmptyCacheDoesNothingAsync`
- `testWhenBlockIsStoredItFollowsTheDescribedFormat`
- `testWhenBlockIsStoredItFollowsTheFilenameConvention`
- `testGetLatestHeight`
- `testRewindDeletesTheRightBlocks` test
- `testPerformanceExample` test. This isn't a real performance test because the API doesn't work with async/await yet
adopts `shield_funds` shielding threshold parameter
Implements `initBlockMetadataDb` and fix tests
Renames dbCache parameter to `fsBlockDbRoot`. Builds but tests don't pass.
Removes cacheDb uses from code. Testing utilities still persist.
Added needed information in MIGRATING and CHANGELOG.
Added helper to perform deletion of legacy db and creation a the
new file system backed cache.
Renames parameters and changes code where needed.
Network Constants turned into `enum` with static methods.
DeletelastDownloadedBlock helper from initializer
Removes CompactBlockStorage and CompactBlockEntity.
Implements `latestCachedBlockHeight` on rustbackend.
*Replaces dependencies on ZcashRustWelding with `FSMetadataStore`*
This allows the tests to not depend in a particular implementation
of either the MockRustBackend of or ZcashRustBackend. Also provides
a way to test errors properly and switch implementations of critical
areas like `writeBlocks`.