feat: note the canonical bitcoin blocks in the database#1891
Open
feat: note the canonical bitcoin blocks in the database#1891
Conversation
Contributor
Probably test for case when two forks have no common blocks |
djordon
commented
Jan 15, 2026
… specifically for the bitcoin chain tip
…the canonical chain
MCJOHN974
previously approved these changes
Jan 29, 2026
| /// non-canonical if they are part of the chain identified by the given | ||
| /// chain tip. | ||
| #[tokio::test] | ||
| async fn test_set_canonical_bitcoin_blockchain_with_fork_known_later() { |
Contributor
There was a problem hiding this comment.
nit: maybe use something like TestData + get_rng() or so in testing to generate various blockchains (and for example just test that in-memory and postgres canonical-related functions behave similarly)
matteojug
reviewed
Jan 29, 2026
generating a block to a new address
MCJOHN974
reviewed
Feb 5, 2026
This was referenced Feb 6, 2026
matteojug
approved these changes
Feb 9, 2026
Contributor
matteojug
left a comment
There was a problem hiding this comment.
LGTM!
Should we add a PR label for DB migrations? Mostly to then have them easily listed in the release notes
| }; | ||
| let blockchains = TestData::generate(&mut rng, &signer_keys, ¶ms); | ||
|
|
||
| // Insert all blocks from into the database |
| assert_eq!(db.is_block_canonical(&new_block).await.unwrap(), Some(true)); | ||
| } | ||
|
|
||
| // Check that the new blocks have is_canonical = true |
Contributor
There was a problem hiding this comment.
nit: old comment, should probably be moved up in the for
Comment on lines
+8227
to
+8230
| // Create two blockchains, one of length 10 and another of length | ||
| // 20, where one forks the other at height 3 (the block with height | ||
| // 3 differs from one to the other but their earlier blocks are the | ||
| // same) |
Contributor
There was a problem hiding this comment.
nit: now fork chain is 17 blocks long, fork block is at height 2
MCJOHN974
approved these changes
Feb 11, 2026
This file contains hidden or 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
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.
Description
Closes #1889
Changes
Testing Information
I added a few integration tests, let me know if you can think of some scenarios that you want added.
Checklist