Skip to content

test: check for importprunedfunds RPC errors - #24510

Merged
maflcko merged 1 commit into
bitcoin:masterfrom
theStack:202203-test-check_for_importprunedfunds_RPC_errors
Mar 15, 2022
Merged

maflcko merged 1 commit into
bitcoin:masterfrom
theStack:202203-test-check_for_importprunedfunds_RPC_errors

Conversation

@theStack

@theStack theStack commented Mar 9, 2022

Copy link
Copy Markdown
Contributor

This PR adds missing test coverage for the following errors of the importprunedfunds RPC:

if (!DecodeHexTx(tx, request.params[0].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
}

if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Something wrong with merkleblock");
}

if (!pwallet->chain().findAncestorByHash(pwallet->GetLastBlockHash(), merkleBlock.header.GetHash(), FoundBlock().height(height))) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
}

if ((it = std::find(vMatch.begin(), vMatch.end(), hashTx)) == vMatch.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction given doesn't exist in proof");
}

@fanquake fanquake added the Tests label Mar 9, 2022
@DrahtBot

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #20892 (tests: Run both descriptor and legacy tests within a single test invocation by achow101)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@maflcko

maflcko commented Mar 15, 2022

Copy link
Copy Markdown
Member

review ACK 7573789

@maflcko
maflcko merged commit 7b83c7d into bitcoin:master Mar 15, 2022
@theStack
theStack deleted the 202203-test-check_for_importprunedfunds_RPC_errors branch March 15, 2022 15:13
@bitcoin bitcoin locked and limited conversation to collaborators Mar 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants