Commit Graph

17 Commits

Author SHA1 Message Date
Aaron Campbell
03678bb754 multi: Correct typos.
Correct typos found by reading code and creative grepping.
2019-08-16 17:37:58 -05:00
Dave Collins
25c14e046a
main: Update to use all new major module versions.
This updates all code in the main module to use the latest major modules
versions to pull in the latest updates.

A more general high level overview of the changes is provided below,
however, there is one semantic change worth calling out independently.

The verifymessage RPC will now return an error when provided with
an address that is not for the current active network and the RPC server
version has been bumped accordingly.

Previously, it would return false which indicated the signature is
invalid, even when the provided signature was actually valid for the
other network.  Said behavior was not really incorrect since the
address, signature, and message combination is in fact invalid for the
current active network, however, that result could be somewhat
misleading since a false result could easily be interpreted to mean the
signature is actually invalid altogether which is distinct from the case
of the address being for a different network.  Therefore, it is
preferable to explicitly return an error in the case of an address on
the wrong network to cleanly separate these cases.

The following is a high level overview of the changes:

- Replace all calls to removed blockchain merkle root, pow, subsidy, and
  coinbase funcs with their standalone module equivalents
  - Introduce a new local func named calcTxTreeMerkleRoot that accepts
    dcrutil.Tx as before and defers to the new standalone func
- Update block locator handling to match the new signature required by
  the peer/v2 module
  - Introduce a new local func named chainBlockLocatorToHashes which
    performs the necessary conversion
- Update all references to old v1 chaincfg params global instances to
  use the new v2 functions
- Modify all cases that parse addresses to provide the now required
  current network params
  - Include address params with the wsClientFilter
- Replace removed v1 chaincfg constants with local constants
- Create subsidy cache during server init and pass it to the relevant
  subsystems
  - blockManagerConfig
  - BlkTmplGenerator
  - rpcServer
  - VotingWallet
- Update mining code that creates the block one coinbase transaction to
  create the output scripts as defined in the v2 params
- Replace old v2 dcrjson constant references with new types module
- Fix various comment typos
- Update fees module to use the latest major module versions and bump it v2
2019-08-13 11:22:37 -05:00
Donald Adu-Poku
8f5019e083 multi: add BgBlkTmplGenerator.
BgBlkTmplGenerator represents the background process that
generates block templates and notifies all subscribed clients
on template regeneration. It generates new templates based
on mempool activity for vote and non-vote transactions and
the time elapsed since last template regeneration.

This also adds a template pool to the background block
generator for recreating submitted blocks.
2019-03-30 16:08:43 -05:00
J Fixby
4896240914 main: move cert tests to a separated file 2018-10-18 20:06:53 +02:00
Dave Collins
5b8450a6e6
multi: Cleanup recent alt DNS names additions.
This cleans up code recently added to support the --altdnsnames flag and
DCRD_ALT_DNSNAMES environment variable to match the project standards,
simplify it, and correct some issues with standalone test binaries.

- Gets rid of the setup func which had several issues:
  - It was creating a file that was not needed (and without even
    checking the error)
  - Since it was parsing flags and missing with os.Args in a func, it
    was not possible to individual run the test funcs without failure
    due to the additional flags
- Performs the flag parsing and removal in an init func that only runs
  once when the tests are run (and before TestMain)
- Avoids creating empty objects when nil will suffice
- Uses full sentences and periods in the comment and properly spaces
  them out so they are consistent with the rest of the code
- Adds comments to all of the added test functions as required by the
  code contribution guidelines
- Closes the create temp files before trying to write to them in the cert
  generation
- Defers the removal of the temp files directly after they are created so
  they are removed properly if the next one fails to create
- Uses consistent camel case in the variable names
2018-10-11 14:16:51 -05:00
Corey Osman
ea54d032df rpcserver: Adds ability to allow alternative dns names for TLS.
- rpcserver: Adds ability to allow alternative dns names for TLS.
- Adds AltDNSNames config for passing additional hostnames to the
  TLS certificate generate method.  Without this change there is no
  way to pass in alternative dns names for the rpc server.
- Additionally this commit allows the user to set 'DCRD_ALT_DNSNAMES'
  as an environment variable when starting dcrd.  This is useful for
  docker and other app runtimes that require apps to be 12 factor.
2018-10-10 23:40:40 -05:00
Dave Collins
6f9b6f1c6e
multi: Use regression test network in unit tests.
This modifies the majority of the tests that make use of chain
parameters and the RPC tests to use the resurrected regression test
network.

It also bumps the affected module versions as follows:

- github.com/decred/dcrd/txscript@v1.0.2
- github.com/decred/dcrd/blockchain/stake@v1.0.3
- github.com/decred/dcrd/mempool@v1.0.2

The blockchain and dcrutil modules are also affected, but since their
version has already been bumped since their last release tags, they are
not bumped again.
2018-10-09 19:40:10 -05:00
Dave Collins
ad21578d2f
rpctest: Gate rpctest-based behind a build tag.
Contains upstream commits:
- 99165eb558
  - This is a NOOP since it was already done in Decred when porting the
    rpctest framework
- 754c4fbe0c

The merge commit also ports the necessary changes to run the tests in
the new Decred build setup.
2017-07-26 12:43:26 -05:00
Dave Collins
823cbedd15
rpctest: Cleanup resources on failed setup.
This contains the following upstream commits:
- 5e93b1664e
  - This commit originated from downstream so it is a NOOP
- 0ddd10add6
  - This commit has been reverted since it has already been done.
- fb90c334df
2017-07-21 17:03:57 -05:00
Dave Collins
6dbb5aa627
config: new flags to accept/reject non-std txns.
This contains the following upstream commits:
- dc5486a579
- 815ded348e
- c6d50b7abf

The merge commit also includes the contains necessary Decred-specific
alterations.
2017-07-21 13:51:47 -05:00
Dave Collins
765e04cb5a
rpctest: prevent process leak due to panics
Upstream commit bfe2ba4191.
2017-07-20 09:16:55 -05:00
Dave Collins
2da4b5f15f
rpcserver: Upstream sync to add basic RPC tests.
Upstream commit 2d86fbface
2017-07-19 16:53:41 -05:00
Dave Collins
754c4fbe0c
rpctest: Gate rpctest-based behind a build tag.
This adds a new build tag named rpctest which must be set in order for
rpctest-based tests to be executed.  The new build tag is also added to
the goclean.sh script which is executed by Travis during continuous
integration builds.

This change is being made because the rpctest framework requires
additional careful user configuration to ensure the version of btcd
under test can be programmatically launched from the system path with
all of the necessary ports open whereas all of the other tests are
self-contained within the test binary itself.

Since said additional configuration is typically not done, it leads to a
lot of false positives.  Putting the tests behind a build tag allows
them to remain to be available and run during continuous integration
without imposing the additional configuration requirements on users.
2016-09-26 01:20:31 -05:00
Dave Collins
fb90c334df
rpctest: Cleanup resources on failed setup.
This modifies the rpctest harness to call the TearDown function in the
SetUp error path.  This ensures any resources, such as temp directories,
that were created during setup before whatever the failure that caused
the error are properly cleaned up.
2016-09-13 17:19:32 -05:00
Olaoluwa Osuntokun
c6d50b7abf
rpctest: ensure the main harness rejects non-standard transactions
This commit modifies the current set of integration tests to ensure
that that the main harness always rejects non-standard transactions.

With this in place, even though we’re using simnet parameters, we
ensure that transaction acceptance/validation is identical to that of
main net.
2016-08-24 15:43:35 -07:00
Olaoluwa Osuntokun
bfe2ba4191
rpctest: prevent leaking processes in tests due to panics
This commit adds a `defer` statement at the top of  `TestRpcServer`
which will attempt a `recover` which tears down all active harnesses in
the event that one of the tests causes a panic in the main goroutine.

Before this commit, if a buggy test caused a panic while all integration
tests were being executed, then any active harnesses would fail to be
properly torn down. This would cause the running btcd processes to be
leaked, possibly interfering with future test runs until the process was
manually killed. This commit fixes such behavior.

In order to aide in debugging, when a test panics, the test number is
printed out along with a full stack-trace from the start of the test to
the panic point.
2016-08-22 17:09:18 -07:00
Olaoluwa Osuntokun
2d86fbface
btcd: add basic RPC tests using the rpctest package
This commit introduces a new file: rpcserver_test.go dedicated for
including integration tests for btcd using the new rpctest package.

The tests are created using a TestMain instance first creates a single
main harness which is intended to be re-used across tests instances.
Afterwards all registered RPC tests are executed, with proper clean up
being executed regardless of the passing state of the tests.

The following RPC calls are excessed by the initial set of tests added:
    * getbestblock
    * getblockcount
    * getblockhash
2016-08-19 17:41:37 -05:00