sendrawtransaction is expected to fail if the transaction already exists in the mempool or a mined block. dcrd returns two different errors which can indicate this situation. Handling for one of them already existed, and this commit adds handling for the other.
No need to manually construct HTML in this formatting func, it can simply deal with whitespace and then use <pre> tags to display.
Add some tests to validate behaviour.
The "search" input type is functionally the same as "text" but has a nice extra property - most browsers will render it with a "Clear" button to wipe the current input.
Also disable spellchecking on this input.
The client supported overriding the default server signature validation func. This was originally added to facilitate testing, but at the moment only serves to make using the client more clunky and error prone.
The tests are to ensure that vspd errors are correctly wrapped as types.ErrorResponse, and non-vspd errors contain adequate information for debugging.
A small change in the client code itself was required to satisfy these conditions.
Checking this in middleware not only removes duplicated code from each of the handlers, but also makes things more efficient. Previously, dcrd/dcrwallet/database clients were initialized (and could possibly cause errors) **before** checking if the VSP is closed. Now the check happens before those other things.
Also bundled with some improvements to setaltsignaddr_test.go which I implemented along the way.
This check was added preemptively, the error has never actually been observed in dev, testing, or production.
It does not scale well. Its takes almost 500ms to insert into a database containing 100k tickets.
`go test $ROOTPATH/...` runs all tests in the root module, and all tests in
submodules, so there is no need to run `go test` in the loop which
descends into submodule directories. Doing this actually causes each
test file to be run twice because the first iteration of the loop *is* the root
module, and thus all tests.
Only the linter needs to be invoked from each module directory.
This renames the variables in the script that runs tests against all
modules to better reflect reality as of the latest versions of Go.
In particular, instead of referring to `ROOTPATH`, it now uses `ROOTPKG`
to better indicate that it is the name of root package as opposed to a
file path to it.
* Remove helper func getCommitmentAddress.
This function is only used in one place so removing it does not introduce any duplication. Removing the func also removes the need for errors.Is comparison, which will be very useful in upcoming changes.
* Rename apiError to ErrorCode.
* Don't use inline type for API errors.
* Export webapi errors.
* Export webapi request/responses.
* Add types module for API requests/responses/errors
* ci: Update GitHub actions and linter.
* Update go deps.
* Include commit ID in build info.
Introduced in go 1.18, debug.ReadBuildInfo allows a go process to discover the git commit it was built from.
Periodic database backups are no longer started automatically in database.Open(), and the backup written by database.Close() can now be disabled.
Only vspd itself requires backups, they are not useful for test code or future upcoming tools such as vote-validator.
* Update linter to 1.49.0
* Move vspd into cmd directory.
This is standard practise in Decred golang repos. Especially useful when multiple executables are built from a single repo.
* Ignore bins in new dir.