[trello.com/c/dmJg0inY]: DogeWalletService tests #658
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initially open PR to EthWalletService tests branch to minimise diff.
Used only two hacks:
DogeWallet
raw initializer (marked it as deprecated with message "For testing purposes only" and made it available only in DEBUG builds)DogeWalletService.setWalletForTests
- method to set wallet easily for testing purposes, (marked it as deprecated with message "For testing purposes only" and made it available only in DEBUG builds)In tests I caught every custom error thrown by
createTransaction
method, verified that parameters passed toBitcoinKit.Transaction.createTransactions
are expected.PR is very similar to BtcWalletServiceTest but has some unique caveats to workaround:
DogeApiService
protocolDogeApiServiceProtocol
was introduced, but I had to slightly change internals ofDogeApiService
to match protocol requirements (public interface didn't change)DogeApiServiceProtocolMock
redirect all calls to_api
property, alsoapi
property (introduced to match protocol requirement) redirects all calls to_api
, so wheneverDogeWalletService
calls network request using eitherdogeApiService.request
ordogeApiService.api.request
- we don't need extra mocks for each case