Skip to content

Test loadtxoutset RPC method#537

Merged
tcharding merged 1 commit intorust-bitcoin:masterfrom
Abeeujah:test-loadtxoutset
Apr 2, 2026
Merged

Test loadtxoutset RPC method#537
tcharding merged 1 commit intorust-bitcoin:masterfrom
Abeeujah:test-loadtxoutset

Conversation

@Abeeujah
Copy link
Copy Markdown
Contributor

Testing loadtxoutset on regtest requires a deterministic chain that produces a state matching the hardcoded assumeutxo entry in Bitcoin Core’s chainparams . Without this alignment, a standard dump-and-load cycle on a random regtest chain will always be rejected.

Replicate Bitcoin Core's C++ TestChain100Setup deterministic chain (mocktime 1598887952, P2PK coinbase to compressed pubkey of private key 0x01, 110 blocks) so the resulting block hash matches the assumeutxo entry. Dump the UTXO set from the miner node, feed headers to a fresh node via submitheader, then load the snapshot and verify the model.

Wire the load_tx_out_set client macro into v27 through v30, which were missing the call.

closes #313

Comment thread integration_test/tests/blockchain.rs Outdated
Comment on lines +123 to +126
let loaded: LoadTxOutSet =
node_b.client.load_tx_out_set(dump_path).expect("loadtxoutset should succeed");

let model = loaded.into_model().expect("into_model");
Copy link
Copy Markdown
Member

@tcharding tcharding Apr 1, 2026

Choose a reason for hiding this comment

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

    let json: LoadTxOutSet =
        node_b.client.load_tx_out_set(dump_path).expect("loadtxoutset should succeed");

    let model: Result<mtype::LoadTxOutSet, LoadTxOutSetError> = json.into_model();
    let model = model.unwrap();

Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

This is sick bro, top effort!

Reviewed: c33cab7

Testing loadtxoutset on regtest requires a deterministic chain that
produces a state matching the hardcoded assumeutxo entry in Bitcoin
Core’s chainparams. Without this alignment, a standard dump-and-load
cycle on a random regtest chain will always be rejected.

Replicate Bitcoin Core's C++ TestChain100Setup deterministic chain
(mocktime 1598887952, P2PK coinbase to compressed pubkey of private key
0x01, 110 blocks) so the resulting block hash matches the assumeutxo
entry. Dump the UTXO set from the miner node, feed headers to a fresh
node via submitheader, then load the snapshot and verify the model.

Wire the load_tx_out_set client macro into v27 through v30, which were
missing the call.
@Abeeujah Abeeujah force-pushed the test-loadtxoutset branch from c33cab7 to 913d526 Compare April 1, 2026 12:46
Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 913d526

@tcharding tcharding merged commit dfbd013 into rust-bitcoin:master Apr 2, 2026
31 checks passed
@tcharding
Copy link
Copy Markdown
Member

This was nice work bro, keep it coming!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to test loadtxoutset?

2 participants