Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcserver: Add handleSearchRawTransactions tests. #2330

Merged
merged 5 commits into from
Aug 30, 2020

Conversation

rstaudt2
Copy link
Member

This adds test coverage for handleSearchRawTransactions and fetchMempoolTxnsForAddress.

There is one error case here that is unreachable, and the rest of these functions are covered:

go test -run="TestHandleSearchRawTransactions" -coverprofile=cov.out &&
go tool cover -func=cov.out | grep -E "handleSearchRawTransactions|fetchMempoolTxnsForAddress"

github.com/decred/dcrd/internal/rpcserver/rpcserver.go:3868:		fetchMempoolTxnsForAddress	100.0%
github.com/decred/dcrd/internal/rpcserver/rpcserver.go:3887:		handleSearchRawTransactions	99.2%

Part of #2069.

@davecgh davecgh added the test coverage Discussion and pull requests for improving test coverage. label Aug 16, 2020
Copy link
Member

@dnldd dnldd left a comment

Choose a reason for hiding this comment

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

Looks good, nicely done.

@davecgh davecgh added this to the 1.6.0 milestone Aug 19, 2020
internal/rpcserver/rpcserverhandlers_test.go Outdated Show resolved Hide resolved
internal/rpcserver/rpcserverhandlers_test.go Outdated Show resolved Hide resolved
internal/rpcserver/rpcserverhandlers_test.go Show resolved Hide resolved
@rstaudt2 rstaudt2 force-pushed the search-raw-transactions-tests branch from f6fcb87 to 8721cbf Compare August 21, 2020 10:17
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

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

Overall, this looks great!

internal/rpcserver/rpcserver.go Outdated Show resolved Hide resolved
internal/rpcserver/rpcserver.go Outdated Show resolved Hide resolved
server.go Outdated Show resolved Hide resolved
server.go Outdated Show resolved Hide resolved
@rstaudt2 rstaudt2 force-pushed the search-raw-transactions-tests branch from 8721cbf to 2c286e2 Compare August 29, 2020 11:41
This adds an AddrIndexer interface to rpcserver, which decouples
rpcserver from the implementation of the address index and allows a
mocked version to be provided for testing.
This adds a TxIndexer interface to rpcserver, which decouples rpcserver
from the implementation of the transaction index and allows a mocked
version to be provided for testing.
This adds testDB and testDatabaseTx structs that provide mock
implementations of the database.DB and database.Tx interfaces for
testing purposes.
@rstaudt2 rstaudt2 force-pushed the search-raw-transactions-tests branch from 2c286e2 to 1c4c171 Compare August 29, 2020 12:16
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

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

$ go test -run="TestHandleSearchRawTransactions" -coverprofile=cov.out
$ go tool cover -func=cov.out | grep -E "handleSearchRawTransactions|fetchMempoolTxnsForAddress"
github.com/decred/dcrd/internal/rpcserver/rpcserver.go:3868:            fetchMempoolTxnsForAddress      100.0%
github.com/decred/dcrd/internal/rpcserver/rpcserver.go:3887:            handleSearchRawTransactions     99.2%

I also confirmed that the uncovered branch is not reachable currently.

@davecgh davecgh merged commit fed6edd into decred:master Aug 30, 2020
@rstaudt2 rstaudt2 deleted the search-raw-transactions-tests branch January 15, 2021 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test coverage Discussion and pull requests for improving test coverage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants