Repository navigation
test: Verify a reorg moves a re-mined payment to its new height - #94
Conversation
| 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
297b343 to
ee90f3f
Compare
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.
ee90f3f to
6afe80f
Compare
rustaceanrob
left a comment
There was a problem hiding this comment.
Tested locally and test logic looks good
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.