Skip to content

test: Assert getblock core compatible#788

Open
jaoleal wants to merge 1 commit intogetfloresta:masterfrom
jaoleal:assert_getblock_corecompatible
Open

test: Assert getblock core compatible#788
jaoleal wants to merge 1 commit intogetfloresta:masterfrom
jaoleal:assert_getblock_corecompatible

Conversation

@jaoleal
Copy link
Collaborator

@jaoleal jaoleal commented Jan 17, 2026

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_data dir for floresta-rpc.

I did change the type to use v30 instead of v29 but i expect that to be addressed on #682 Addressed.

Also 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_data is indeed the return of

 bitcoin-cli -regtest  getblock 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206

 bitcoin-cli -regtest  getblock 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206 0

after that you just need to run the test for floresta-rpc

cargo build

cargo test -p floresta-rpc

Contributor Checklist

  • I've followed the contribution guidelines
  • I've verified one of the following:
    • Ran just pcc (recommended but slower)
    • Ran just lint-features '-- -D warnings' && cargo test --release
    • Confirmed CI passed on my fork
  • I've linked any related issue(s) in the sections above

Finally, 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).

@jaoleal jaoleal changed the title Assert getblock corecompatible test: Assert getblock corecompatible Jan 17, 2026
@Davidson-Souza Davidson-Souza added the RPC Changes something with our JSON-RPC interface label Jan 17, 2026
@Davidson-Souza Davidson-Souza changed the title test: Assert getblock corecompatible test: Assert getblock core compatible Jan 17, 2026
@Davidson-Souza Davidson-Souza marked this pull request as draft January 17, 2026 18:22
@Davidson-Souza
Copy link
Member

Marking as draft since it depends on #682

@jaoleal jaoleal force-pushed the assert_getblock_corecompatible branch 6 times, most recently from 4467f93 to 0f0dd5f Compare January 21, 2026 14:16
@jaoleal jaoleal marked this pull request as ready for review January 21, 2026 14:17
@jaoleal
Copy link
Collaborator Author

jaoleal commented Jan 21, 2026

Marking as ready to review

cc @Davidson-Souza @moisesPompilio

Copy link
Member

@Davidson-Souza Davidson-Souza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What 781efaf achieves that tests/floresta-cli/getblock.py don't?


use crate::rpc_types::GetBlockRes;

pub fn getblock_data(verbose: bool) -> GetBlockRes {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verbose is not a bool but a numeric type, I think we need to fix this here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

use crate::test_data::getblock_data;

struct Florestad {
pub struct Florestad {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to make this public?

@jaoleal jaoleal force-pushed the assert_getblock_corecompatible branch from 0f0dd5f to 17161d2 Compare January 21, 2026 16:21
@jaoleal
Copy link
Collaborator Author

jaoleal commented Jan 21, 2026

Applied suggestions on 17161d2

@jaoleal
Copy link
Collaborator Author

jaoleal commented Jan 21, 2026

What 781efaf achieves that tests/floresta-cli/getblock.py don't?

Its easy to run

@Davidson-Souza
Copy link
Member

Its easy to run

That's not a reason to have two modules doing the same thing. Specially given that this doesn't test things like chain work and mtp calculation.

I like 17161d2, but NACK c733bbf

@jaoleal
Copy link
Collaborator Author

jaoleal commented Jan 22, 2026

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 floresta-nix packaging have these tests blacklisted exactly because its trying to get instances up and running... I cant do much in the nix part, thats how they achieved packaging determinism, but hear this propose.

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 FlorestaRpc and passing to rust-bitcoin`s jsonrpc... And they already tested their client

@Davidson-Souza
Copy link
Member

Im the "vitcim" of one of these cases, the floresta-nix packaging have these tests blacklisted exactly because its trying to get instances up and running... I cant do much in the nix part, thats how they achieved packaging determinism, but hear this propose.

That could as well be in the PR description. I did not understand what you were doing here because it just says

It asserts that #682 is indeed working

so does getblock.py. Since the goal here is to make it a simple functional test like the others we already have (and have a use-case for it), things are different. Not a big fan of this json approach, tho. All other tests leave the values inside the test itself.

@jaoleal
Copy link
Collaborator Author

jaoleal commented Jan 22, 2026

I did not understand what you were doing here because it just says

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.

so does getblock.py. Since the goal here is to make it a simple functional test like the others we already have (and have a use-case for it), things are different. Not a big fan of this json approach, tho. All other tests leave the values inside the test itself.

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, getblock.py does not achieve... And its fairly easy to have the tests that Im proposing

@jaoleal jaoleal force-pushed the assert_getblock_corecompatible branch from 17161d2 to 6a7bcd4 Compare February 3, 2026 11:51
@jaoleal
Copy link
Collaborator Author

jaoleal commented Feb 3, 2026

Okay, dropped the commit that was actually extending the tests.

Ill present the same changes with different approach later

@Davidson-Souza
Copy link
Member

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.

@jaoleal
Copy link
Collaborator Author

jaoleal commented Feb 3, 2026

Yes, another PR

@jaoleal
Copy link
Collaborator Author

jaoleal commented Feb 3, 2026

For new approach, I recommend just following the same approach taken by other tests in this file.

Im not sure if i got this correctly. What you mean by "the same approach" ?

@jaoleal jaoleal force-pushed the assert_getblock_corecompatible branch from 6a7bcd4 to 1aa4c6a Compare February 4, 2026 15:13
@jaoleal jaoleal force-pushed the assert_getblock_corecompatible branch from 1aa4c6a to d36a64d Compare February 4, 2026 15:19
Copy link
Member

@Davidson-Souza Davidson-Souza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK d36a64d

Comment on lines +291 to +294
let _ = state
.get_block(hash, 0)
.await
.map(|v| serde_json::to_value(v).unwrap())
.map(|v| serde_json::to_value(v).unwrap());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC Changes something with our JSON-RPC interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants