-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit tests for models.rs and lib.rs; integration tests for clients #65
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LeoNero
force-pushed
the
add/tests-for-lib
branch
2 times, most recently
from
July 15, 2022 19:22
05aca62
to
5fd9c4f
Compare
LeoNero
force-pushed
the
add/tests-for-lib
branch
from
July 27, 2022 16:43
ca26567
to
8c7c7e5
Compare
`PartialEq` was derived for the following types: - BlockTemplate - Transaction - SubaddressBalanceData - BalanceData - TransferPriority - SubaddressData - SubaddressIndex - Payment - AddressData - IncomingTransfers - GotAccount - GetAccountsData - GotTransfer - SignedKeyImage - KeyImageImportResponse
Comment is about the possibility of GenerateFromKeysArgs's `password` field being optional, even though Monero docs do not mention it.
… `daemon_rpc_call` method
…height possibly being optional
LeoNero
force-pushed
the
add/tests-for-lib
branch
from
July 27, 2022 16:56
8c7c7e5
to
05e2996
Compare
LeoNero
changed the title
WIP: tests for lib
Unit tests for models.rs and lib.rs; integration tests for clients
Jul 27, 2022
LeoNero
force-pushed
the
add/tests-for-lib
branch
from
July 27, 2022 20:46
87ce9a7
to
e71e4ef
Compare
TheCharlatan
requested changes
Jul 27, 2022
TheCharlatan
approved these changes
Jul 29, 2022
refring
pushed a commit
to refring/monero-rpc-rs
that referenced
this pull request
Oct 16, 2022
…onero-rs#65) * docs(README): improve `Testing` section * feat(models): derive `PartialEq` for some types in src/models.rs `PartialEq` was derived for the following types: - BlockTemplate - Transaction - SubaddressBalanceData - BalanceData - TransferPriority - SubaddressData - SubaddressIndex - Payment - AddressData - IncomingTransfers - GotAccount - GetAccountsData - GotTransfer - SignedKeyImage - KeyImageImportResponse * feat(models): add GenerateBlocksResponseR struct * feat(models): add GenerateBlocksResponse struct * feat(models): add `From<GenerateBlocksResponseR>` for `GenerateBlocksResponse` * fix(models): fix type of TransferData's `tx_key` field * doc(models): add comment about possible optional field Comment is about the possibility of GenerateFromKeysArgs's `password` field being optional, even though Monero docs do not mention it. * test(models): test conversion from GenerateBlocksResponseR to GenerateBlocksResponse * docs(lib): fix small typos and improve wording a little * fix(lib): fix parameter name passed to `get_balance` RPC call * refactor(lib): remove unncessary full type path from `json_params` in `daemon_rpc_call` method * feat(lib): add `all` parameter for `export_key_images` RPC call * docs(lib): add comment about get_bulk_payments's parameter min_block_height possibly being optional * feat(lib): `generate_blocks` method now returns `GenerateBlocksResponse` * fix(lib): fix `submit_block` method and return type * fix(lib): handle `on_get_block_hash` inconsistency on invalid height * fix(lib): fix `get_payments` to make it return a vector of payments * fix(lib): fix type of `check_tx_key` RPC call parameters and return type * test(lib): add unit tests for RpcParams * test(lib): add serialization test for TransferType * test(lib): add serialization and deserialization test for TransferPriority * test(rpc): remove old tests in tests/rpc.rs * test(rpc): add helpers functions to test DaemonRpcClient * test(rpc): add helpers functions to test RegtestDaemonJsonRpcClient * test(rpc): add helpers functions to test WalletClient * test(rpc): add `common::helpers` module * test(rpc): add `basic_wallet` test * test(rpc): add `empty_blockchain` test * test(rpc): add `non_empty_blockchain` test * test(rpc): add `basic_daemon_rpc` test * test(rpc): add tests of interaction between all clients * test(rpc): add `common::main_tests` module * test(rpc): add `common` crate * test(rpc): add code to run all tests in `common::main_tests` * test(rpc): fix the tests * test(rpc): bump to Monero v0.18.0.0 * docs(CHANGELOG): update CHANGELOG to reflect recent changes * refactor(tests): remove `common` folder * refactor(tests): allow a lint on `empty_blockchain`.rs and add explanation * refactor(tests): remove `async` declaration from function that don't need it * fix(lib): fix Rust 1.56.1 format error in on_get_block_hash * docs(rpc): improve test documentation * test(rpc): rename main_tests to clients_tests, and `fn test` to `fn run` * refactor(tests/wallet): fix expected_ naming inconsistency * refactor(rpc): make tests functions more explicit * docs(rpc): fix typo in a comment on rpc.rs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #58
Closes #71
For #58, I decided to to a simple error handling: check if the request returns "000000..." when it should have returned an error, and then return
anyhow::Error::new("msg")
.In case another version of Monero handles it correctly, our tests will fail :) and in such case, we will be able to remove
anyhow::Error::new("msg")
.For proper error types, I think the issue #22 can handle that.
Also, although the files are big, it is relatively easy to follow what is hapenning, since the function names are descriptive.
The tests are structured as follows:
basic_wallet_tests
: tests wallet functionality that does not interact with the daemonempty_blockchain_test
: tests daemon_json_rpc functionaly when the blockchain is empty, ie has only the genesis blocknon_empty_blockchain_test
: tests daemon_json_rpc functionality that changes the blockchain state, but such functionalities are not related to transactions, outputs, etcbasic_daemon_rpc_test
: tests the daemon_rpc when there are no transactions between users in the blockchainall_clients_interaction_test
: tests the functionality of all clients (creates transactions, transfers, blocks, updates balances, etc)A separate test, testing the code in the
README
, was added as wellFinally, you can see the changes made to the code in
src/
atCHANGELOG.md
.