Commit Graph

26 Commits

Author SHA1 Message Date
David Hill
393a95c079 multi: fix some maligned linter warnings 2018-02-13 14:50:33 -06:00
Dave Collins
74735a8fdf multi: Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.
2018-01-28 22:36:34 -06:00
Donald Adu-Poku
0a4e0022db rpctest: Choose flags based on provided params.
This modifies the rpctest framework to start btcd with the appropriate
network flags depending on the provided parameters.

Previously, it always started btcd with --simnet even if other
parameters, such as those for the regression test network, were
provided.
2017-12-05 15:44:01 +00:00
David Hill
b13f5dfbda travis: add ineffassign linter 2017-12-01 09:14:04 -05:00
David Hill
20686cd775 travis: add gosimple linter 2017-11-20 18:49:55 -06:00
Josh Rickmar
65001cd49e hdkeychain: Move to github.com/decred/dcrd/hdkeychain
This change moves the hdkeychain package outside of the dcrutil
directory into its own top-level package.  This change is being made
since hdkeychain only depends on dcrutil's address code, and if the
rpctest integration tests are ever moved outside of the dcrd repo,
hdkeychain will no longer be required to remain in dcrd to avoid a
cyclic dependency.
2017-10-12 08:31:54 -05:00
Josh Rickmar
6842aa006d Merge remaining dcrutil code into a dcrd package.
This merge commit adds the following code from the
github.com/decred/dcrutil package into a new
github.com/decred/dcrd/dcrutil package:

* Address handling
* Amount type
* AppDataDir func
* bitflags functions
* Block wrapper type
* Hash160 func
* Tx wrapper type
* WIF type

as well as all tests for this code.

The old github.com/decred/dcrutil/hdkeychain package has also been
merged and moved to github.com/decred/dcrd/dcrutil/hdkeychain.

dcrd packages have been updated to use the new packages and the dep
files have been updated for this change.
2017-10-11 22:06:36 -04:00
Dave Collins
a4d4179143
rpcclient: Merge dcrrpcclient repo. 2017-10-11 14:25:50 -05:00
Josh Rickmar
27981a5a7d Move self signed certificate code into certgen package.
Use this package instead of relying on dcrutil certificate generation
functions.
2017-10-10 17:23:38 -04:00
David Hill
81e3f0983d gometalinter: run on subpkgs too (#878) 2017-10-10 17:20:40 -04:00
Donald Adu-Poku
18ca7bb19d rpctest: Store logs and data in same path.
logs and data directories are subdirs
of the harness dir, the node dcrd
process is also run in the working dir
which is the harness dir
2017-08-04 02:18:58 -05:00
Donald Adu-Poku
863496e427 rpctest: fix a harness range bug in syncMempools 2017-08-01 23:15:51 +00: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
214408a7ff
rpctest/deps: Update dependencies and API.
Upstream commit 5ec83d23f3.

The merge commit modifies the dependency hash updates in glide.lock to
the correct commits.
2017-07-26 12:18:24 -05:00
Dave Collins
b661265c5b
rpctest: Use ports based on the process id.
This contains the following upstream commits:
- c20db1cf14
  - This is commented out in the Decred tests, so merged with the
    commented code
- daac24626e
  - This has been reverted since the Decred build system is different
    and it therefore does not apply
- 7cf9ec8190
2017-07-21 22:28:59 -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
310f9b9667
rpctest: Correct several issues in tests and joins.
Contains the following upstream commits:
- c3d5371615
  - Reverted since Travis is already at a more recent version
- 7c4b169faa
  - Reverted since this is already done via the Decred docker setup
- 47ced81d44
  - Reverted since it has already been fixed by connmanager sync
- 6cf60b5fae

Also, the merge commit contains the necessary Decred-specific alterations.
2017-07-19 18:16:18 -05:00
Dave Collins
d337038a8d
rpctest: Upstream create new rpctest package sync.
Upstream commit b86df0ba91.

The merge commit contains necessary Decred-specific alterations and also
removes the code that is related to generating and submitting a new
block.

While the block generation functionality is useful, the specific method
used in the upstream code will not work in Decred because of the
additional state needed for voting and the fact the difficulty
adjustment period is much more frequent which prevents just using the
pow limit.

Future commits can remedy this situation by making use of block
templates provided by the daemon and allowing the rpc test code to
modify the template accordingly.
2017-07-19 14:24:27 -05:00
Dave Collins
da04285e0d
rpctest: Choose flags based on provided params.
This modifies the rpctest framework to start btcd with the appropriate
network flags depending on the provided parameters.

Previously, it always started btcd with --simnet even if other
parameters, such as those for the regression test network, were
provided.
2016-10-20 12:19:58 -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
David Hill
99165eb558 rpctest: Fix typo
Use os.Getpid() to get the process ID, not os.Getppid(), which returns
the parent process ID.  This resulted in multiple calls to
generateListeningAddresses() getting the same listening ports.
2016-09-22 00:14:51 -04:00
David Hill
5ec83d23f3 Update dependencies and API usage. 2016-09-21 20:50:55 -04:00
Dave Collins
7cf9ec8190
rpctest: Use ports based on the process id.
This modifies the ports that are selected for use for the p2p and rpc
ports to start with a port that is based on the process id instead of a
hard-coded value.  The chosen ports are incremented for each running
instance similar to the previous code except the p2p and rpc ports and
now split into ranges instead of being 2 apart.

This is being done because the previous code only worked for a single
process which means it prevented the ability to run tests in parallel.

The new approach will work with multiple processes, however it must be
stated that there is still a very small probability that the stars could
align resulting in the same ports being selected.

Finally, this also reverts the recent change to run tests serially since
this fixes the underlying cause for that change.
2016-09-20 16:59:37 -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
Dave Collins
6cf60b5fae
rpctest: Correct several issues in tests and joins.
This corrects several issues with the new rpctest package.

The following is an overview of the issues that have been corrected:

- The JoinNodes code was incorrect for both mempool and blocks.
  - For mempool it was only checking the first node against itself
  - For blocks it was only testing the height instead of hash and height
    which means the chains could be different and it would claim they're
    synced
- The test for mempool joins was inaccurate in a few ways:
  - It was generating separate chains such that the generated
    transaction was invalid (an orphan) on one chain, but not
    the other
  - Mempools are not automatically synced when nodes are connected and
    there is a large random delay before any transaction rebroadcast
    happens, so it can't be relied on for the purposes of this test
- The test for block joins was generating two independent chains of the
  same height with the same difficulty and was only passing due to the
  aforementioned bug in JoinNodes
- All of the ConnectNode calls were connecting the main harness outbound
  to the local test harness instances
  - This is not correct because ConnectNode makes the outbound
    connection persistent, which means once the local test harness is
    gone, it would keep trying to connect for the remainder of the tests
    to a node that is never coming back and instead ends up connecting to
    an independent test harness.
2016-08-21 15:10:23 -05:00
Olaoluwa Osuntokun
b86df0ba91
rpctest: create new rpctest package
This commit adds a new package (rpctest) which provides functionality
for writing automated black box tests to exercise the RPC interface.

An instance of a rpctest consists of an active btcd process running in
(typically) --simnet mode, a btcrpcclient instance connected to said
node, and finally an embedded in-memory wallet instance (the memWallet)
which manages any created coinbase outputs created by the mining btcd
node.

As part of the SetUp process for an RPC test, a test author can
optionally opt to have a test blockchain created. The second argument
to SetUp dictates the number of mature coinbase outputs desired. The
btcd process will then be directed to generate a test chain of length:
100 + numMatureOutputs.

The embedded memWallet instance acts as a minimal, simple wallet for
each Harness instance. The memWallet itself is a BIP 32 HD wallet
capable of creating new addresses, creating fully signed transactions,
creating+broadcasting a transaction paying to an arbitrary set of
outputs, and querying the currently confirmed balance.

In order to test various scenarios of blocks containing arbitrary
transactions, one can use the Generate rpc call via the exposed
btcrpcclient connected to the active btcd node. Additionally, the
Harness also exposes a secondary block generation API allowing callers
to create blocks with a set of hand-selected transactions, and an
arbitrary BlockVersion or Timestamp.

After execution of test logic TearDown should be called, allowing the
test instance to clean up created temporary directories, and shut down
the running processes.

Running multiple concurrent rpctest.Harness instances is supported in
order to allow for test authors to exercise complex scenarios. As a
result, the primary interface to create, and initialize an
rpctest.Harness instance is concurrent safe, with shared package level
private global variables protected by a sync.Mutex.

Fixes #116.
2016-08-19 17:37:08 -05:00