← 输入框|github.com|刷新
Skip to content

test: Verify a reorg moves a re-mined payment to its new height - #94

Merged
rustaceanrob merged 1 commit into
kernel-node:masterfrom
pzafonte:itest-wallet-reorg-remine
Sep 4, 2026
Merged

rustaceanrob merged 1 commit into
kernel-node:masterfrom
pzafonte:itest-wallet-reorg-remine

Conversation

@pzafonte

Copy link
Copy Markdown
Collaborator

Invalidate a block holding a silent payment and re-mine the transaction one block up on a longer branch. The balance should stay the same and the coin reports the new height after the node reorgs.

let miner = core.client.new_address().unwrap().to_string();
core.client.generate_block(&miner, &[], true).unwrap();
core.client
.generate_block(&miner, &[funding_txid.to_string()], true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We mine a block here that both creates a new most-work chain and confirms our transaction. I wonder if we can instead: mine the first block then mine another block without the transaction relevant to our wallet that creates a new most-work chain. That should make our balance zero, and we can assert the balance is zero after that step. Next, we can mine a third block with the transaction and assert our balance is reset to PAYMENT.

This would allow us to avoid introducing string parsing for history, which can be inherently brittle. For instance we may want to change how history is printed in the future. That way the new history APIs in test/common can be omitted here

@pzafonte pzafonte Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done. Two blocks reorg the payment out so the balance goes to zero, then a third re-mines it and the balance returns to PAYMENT. Now uses wait_for_balance_of instead of parsing history, which polls the wallet's balance until it equals an exact expected Amount.

@pzafonte
pzafonte force-pushed the itest-wallet-reorg-remine branch from 297b343 to ee90f3f Compare September 4, 2026 13:23
Invalidate the block holding a silent payment, then extend the chain with empty blocks so the node reorgs onto a branch without the payment and the balance falls to zero. Re-mine the payment and the balance returns.
@pzafonte
pzafonte force-pushed the itest-wallet-reorg-remine branch from ee90f3f to 6afe80f Compare September 4, 2026 13:54

@rustaceanrob rustaceanrob left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested locally and test logic looks good

@rustaceanrob
rustaceanrob merged commit 07f03b7 into kernel-node:master Sep 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants