-
Notifications
You must be signed in to change notification settings - Fork 288
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
rpcserver: Add handleSearchRawTransactions tests. #2330
Conversation
There was a problem hiding this 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.
f6fcb87
to
8721cbf
Compare
There was a problem hiding this 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!
8721cbf
to
2c286e2
Compare
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.
2c286e2
to
1c4c171
Compare
There was a problem hiding this 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.
This adds test coverage for
handleSearchRawTransactions
andfetchMempoolTxnsForAddress
.There is one error case here that is unreachable, and the rest of these functions are covered:
Part of #2069.