test: Assert getblock core compatible#788
Conversation
|
Marking as draft since it depends on #682 |
4467f93 to
0f0dd5f
Compare
|
Marking as ready to review |
Davidson-Souza
left a comment
There was a problem hiding this comment.
What 781efaf achieves that tests/floresta-cli/getblock.py don't?
|
|
||
| use crate::rpc_types::GetBlockRes; | ||
|
|
||
| pub fn getblock_data(verbose: bool) -> GetBlockRes { |
There was a problem hiding this comment.
verbose is not a bool but a numeric type, I think we need to fix this here.
There was a problem hiding this comment.
This is just a internal helper to return the data, It does not need to be fallible yet neither needs to be api compatible. The bool can express both verbosity we support rn
crates/floresta-rpc/src/lib.rs
Outdated
| use crate::test_data::getblock_data; | ||
|
|
||
| struct Florestad { | ||
| pub struct Florestad { |
There was a problem hiding this comment.
Is there any reason to make this public?
0f0dd5f to
17161d2
Compare
|
Applied suggestions on 17161d2 |
Its easy to run |
|
Really ? Honestly i see value in this, the idea is not to compete or to replace the python tests, as you said and I briefly tried to imply is that the python tests indeed deliver more assertion value but in the cost of having a lot more dependencies, including the environment setup needed. The value i see in this lives in the case where we want to assert that we are not breaking any field and any other test, the older getblock test was doing this and my plan was just to expand it make a direct comparison with a bitcoin core output. Im the "vitcim" of one of these cases, the Even with this i cant run the test, i had the idea to include this and to move it to be a functional test in the server without instantiating a florestad, we can make something similar as done here in extensions.rs... As you said, theres no reason to have two modules doing the same thing and we are investing a lot of time to make the python tests better, and i see these tests in floresta-rpc and indeed trying to compete against our python tests, specially because is a integration test between client and server. If youre willing to accept #787 we wont need to check if we are parsing the arguments correctly because im literally just getting the args from |
That could as well be in the PR description. I did not understand what you were doing here because it just says
so does |
Im well aware of that, Im really focusing on being clear following your suggestion. Sincerely, I was frustrated to be spending more time writing and reviewing my writing than actually coding and contributing, as the time goes im improving that to be more efficient. Thanks for the patience.
Well, I might change that, we can hardcode these same values directly in types(maybe implementing default ?), I used the raw json because its literally a copy-paste from what i got from bitcoin core... regarding having simple and lightweight functional tests server side, are there any cons ? Also, I want to bring up the point that we are doing a lightweight node with the objective to run on constrained devices, I think its important to have tests that people can actually run without much trouble, and that, |
17161d2 to
6a7bcd4
Compare
|
Okay, dropped the commit that was actually extending the tests. Ill present the same changes with different approach later |
Are you planning to do this on this PR or another one? If you want to do it here, please mark it as draft For new approach, I recommend just following the same approach taken by other tests in this file. |
|
Yes, another PR |
Im not sure if i got this correctly. What you mean by "the same approach" ? |
6a7bcd4 to
1aa4c6a
Compare
1aa4c6a to
d36a64d
Compare
| let _ = state | ||
| .get_block(hash, 0) | ||
| .await | ||
| .map(|v| serde_json::to_value(v).unwrap()) | ||
| .map(|v| serde_json::to_value(v).unwrap()); |
There was a problem hiding this comment.
| let _ = state | |
| .get_block(hash, 0) | |
| .await | |
| .map(|v| serde_json::to_value(v).unwrap()) | |
| .map(|v| serde_json::to_value(v).unwrap()); | |
| state.get_block(hash, 0).await.iter().for_each(|v| { | |
| serde_json::to_value(v).unwrap(); | |
| }); |
Description and Notes
This adds more extensive assert data which i retrieved from a local v30 Bitcoin Core...
It asserts that #682 is indeed working and also introduce a new
/test_datadir for floresta-rpc.I did change the type to useAddressed.v30instead ofv29but i expect that to be addressed on #682Also i made
GetBlockReq: PartialReq.Depends on #682
I also added a second commit that present some chores related to match the ignature of the method to its accordingly rpc
How to verify the changes you have done?
check that the data Im including in
test_datais indeed the return ofafter that you just need to run the test for floresta-rpc
cargo build cargo test -p floresta-rpcContributor Checklist
just pcc(recommended but slower)just lint-features '-- -D warnings' && cargo test --releaseFinally, you are encouraged to sign all your commits (it proves authorship and guards against tampering—see How (and why) to sign Git commits and GitHub's guide to signing commits).