test(consensus): test BlockTooBig#867
Conversation
|
Sometimes github is strange, it duplicated my review and now theres only one... The one that I marked as duplicate. |
39bec94 to
dc543b1
Compare
|
ACK dc543b1 |
| fn decode_block(file_path: &str) -> Block { | ||
| let block_file = File::open(file_path).unwrap(); | ||
| let block_bytes = zstd::decode_all(block_file).unwrap(); | ||
| deserialize(&block_bytes).unwrap() |
There was a problem hiding this comment.
Unrelated: Bitcoin Core leaves those test assets in another repo, called qa-assets. Leaving in the same tee has the disadvantage of bloating our tree with those test data, even though some people may not use it. Wdyt about moving these to our own floresta-qa-assets?
There was a problem hiding this comment.
@Davidson-Souza you mean the data under floresta-chain/testdata?
There was a problem hiding this comment.
The idea that i got was is that davidson wants a floresta-qa-assets to gather test utils/data
There was a problem hiding this comment.
oh like a separate test utils crate
There was a problem hiding this comment.
Yes, floresta-qa-assets. Our tree is getting a bit bloated and that makes cloning harder than it needs to be.
dc543b1 to
20eb38b
Compare
|
Pushed 20eb38b
|
20eb38b to
877ddf0
Compare
|
Clippy didn't like the childish seed, fixed |
| /// Modifies historical block at height 866,342 by adding one extra transaction so that the | ||
| /// updated block weight is 4,000,001 WUs. The block merkle roots are updated accordingly. | ||
| fn build_oversized_866_342() -> Block { | ||
| let mut block = decode_block("./testdata/block_866342/raw.zst"); |
There was a problem hiding this comment.
Consider remove hard coded file location to avoid test failures on other machines.
There was a problem hiding this comment.
What do you mean? This unit test is executed with the working directory set to the root of floresta-chain, so the path should always be found correctly.
csgui
left a comment
There was a problem hiding this comment.
Left a few comments. Loved the 0xbebe_cafe
|
Can't |
I've constructed a transaction that, when inserted in block 866,342 makes it have 4,000,001 WUs. Then we update the witness commitment and the merkle root, and then check we get `BlockTooBig`. For this I had to implement the `update_witness_commitment` helper. Note that the block we are testing has witnesses, so the witness commitment is enforced by consensus, and inserting a legacy transaction adds a zero `wtxid` that the commitment must now account for.
877ddf0 to
5bda1d5
Compare
Yes! Pushed 5bda1d5 using it |
|
Btw |
| let mut rng = OsRng; | ||
| /// Modifies a block to have a different output script (txdata is tampered with). | ||
| fn mutate_block(block: &mut Block) { | ||
| let mut rng = StdRng::seed_from_u64(0x_bebe_cafe); |
Description and Notes
First commit adds some test helpers to make them simpler, second adds the test. I recommend review by commit, although this PR is small.
I've constructed a transaction that, when inserted in block 866,342 makes it have 4,000,001 WUs. Then we update the witness commitment and the merkle root, and then check we get
BlockTooBig.For this I had to implement the
update_witness_commitmenthelper. Note that the block we are testing has witnesses, so the witness commitment is enforced by consensus, and inserting a legacy transaction adds a zerowtxidthat the commitment must now account for.How to verify the changes you have done?
Just take a look at
test_block_too_big.