Commit graph

2556 commits

Author SHA1 Message Date
Dave Collins
9ec86518ac Improve interface test error messages.
This commit changes the interface test errors to all report the block
height and hash prior to the failure.  Test failures that transactions
also now report the transaction number and hash.  The makes it much
easier to track down where a test failure occurs.
2013-10-14 18:27:12 -05:00
Jonathan Gillham
fa1d343430 Removed extra local variable assignment from DoubleSha256. 2013-10-14 23:55:18 +01:00
Owain G. Ainsworth
0536e3104c Don't send messages before handshake.
If we haven't handshaken with a peer don't send messages that are not
the handshake. Additionally don't queue up invs for sending, they'll
find out soon enough when they ask us what we know.
2013-10-14 22:27:48 +01:00
Owain G. Ainsworth
36c429c302 Bump maxpeers to 125 like bitcoind.
It helps a lot if our max peers doesn't equal the max we'll try and open
outbound.
2013-10-14 22:27:39 +01:00
Owain G. Ainsworth
3afdc43e69 Fix reference counting when expiring peers. 2013-10-14 22:27:21 +01:00
Dave Collins
c99416c121 Include db type in interface tests loading message. 2013-10-14 14:35:10 -05:00
Dave Collins
01af05c8ac Add interface tests for FetchUnSpentTxByShaList. 2013-10-14 13:56:21 -05:00
Dave Collins
2ab3e0a382 Add interface tests for FetchTxByShaList. 2013-10-14 13:49:52 -05:00
Josh Rickmar
340e8b999e Switch a log.Error to Debug 2013-10-14 14:04:36 -04:00
Josh Rickmar
a80f9da6c3 Add websocket handlers to the RPC server for wallet connections.
This change adds additional http listeners for websocket connections
on "/wallet".  Websockets are used to provide asynchronous messaging
between wallet daemons (i.e. btcwallet) and btcd as they allow an easy
way for btcd to provide instant notifications (instead of a wallet
polling for updates) and multiple replies to a single request.
Standard RPC commands sent over a websocket connection are handled
just like RPC, returning the same results, the only difference being
that the connection is async.  In cases where the standard RPC
commands fall short of wallet daemons requests, and to request
notifications for addresses and events, extension JSON methods are
used.

Multiple wallets can be connected to the same btcd, and replies to
websocket requests and notifications are properly routed back to the
original requesting wallet.

Due to the nature of turning a synchronous protocol asynchronous, it
is highly recommended to use the JSON id field as a type of sequence
number, so replies from btcd can be routed back to the proper handler
in a wallet daemon.
2013-10-14 13:37:48 -04:00
Dave Collins
fb5f9c0b5a Separate interface tests and add test context.
Rather than having one mammoth interface test function, create a test
context and several helper functions that accept the context.
2013-10-14 12:26:43 -05:00
Dave Collins
06cb2ec817 Add interface test for FetchTxBySha.
This commit adds an interface test for FetchTxBySha to ensure it returns
the same MsgTx that was part of an inserted block.
2013-10-14 12:26:43 -05:00
Dave Collins
6a3824b8aa Add interface test for ExistsTxSha.
This commit adds an interface test for ExistsTxSha to ensure all
transactions inserted as a part of a block are available.
2013-10-14 12:26:42 -05:00
Dave Collins
f37fabb855 Add negative tests for FetchBlockShaByHeight.
This commit adds tests to ensure FetchBlockShaByHeight returns expected
errors when invalid heights are specified.
2013-10-14 12:26:41 -05:00
Dave Collins
06d6e5fce8 Add db type to test error outputs. 2013-10-14 12:26:40 -05:00
Dave Collins
6eebf02183 Add interface test for FetchBlockShaByHeight.
This commit adds an interface test for FetchBlockShaByHeight to ensure it
returns the same expected hash for each block inserted block height.
2013-10-14 12:26:40 -05:00
Dave Collins
670d83a74e Improve error message for FetchBlockBySha test.wq 2013-10-14 12:26:39 -05:00
Dave Collins
396d1b056d Add interface test for FetchBlockBySha.
This commit adds an interface test for FetchBlockBySha to ensure it
returns the same MsgBlock and raw bytes that were inserted.
2013-10-14 12:26:38 -05:00
Dave Collins
2d84623493 Move non-interface specific tests into db_test.go.
The idea here is that interface_test.go will be directly usable in each
implementation to increase test coverage there as well, but also works at
the  top-most level to test arbitrary backends.
2013-10-14 12:26:37 -05:00
Dave Collins
ff429203c4 Start interface tests that require state. 2013-10-14 12:26:37 -05:00
Dave Collins
82d1898b12 Add interface test for unsupported dbtype failures.
This commit adds an interface test to ensure that the interface returns
the expected error when trying to open or create an unsupported database
type.
2013-10-14 12:26:36 -05:00
Dave Collins
d4c1214496 Add interface test for create and open failures.
This commit adds an interface test to ensure that failures which occur
while creating or opening a database are properly handled.
2013-10-14 12:26:35 -05:00
Dave Collins
53ea2cf0ba Add interface test for adding a duplicate driver.
This commit adds an interface test to ensure that attempting to add a
duplicate driver for a given database type does not overwrite an existing
one.
2013-10-14 12:26:34 -05:00
Dave Collins
562294f938 Add loadBlocks infrastructure to interface tests. 2013-10-14 12:26:34 -05:00
Dave Collins
a27c37793b Add basic infrastructure for interface tests.
This is simply at start at providing generic interface tests.  The only
thing is tests so far is the empty database conditions on NewestSha, but
it adds infrastructure for creating and opening databases with special
type handling based on the database and necessary logic to teardown so
multiple backends can be tested simultaneously.

This and the next series of commits all discussed with drahn@.
2013-10-14 12:26:12 -05:00
Josh Rickmar
31489c15b3 Remove the embedded error and satisify the builtin error interface
This also adds tests to verify that the created error string follows
the expected format of "code: message" and tests to verify that Error
can be used as an error.  Additionally, the idiom

var _, _ error = Error{}, &Error{}

was added so the build will fail if the builtin error interface is
never satisified in the future.
2013-10-14 13:16:37 -04:00
Dave Collins
c88338d227 Slightly optimize GenerateInitialIndex.
Rather than fetching the hash of each block individually 2k+ times, make
use of the FetchHeightRange function so all of the most recent hashes can
be fetched at once.
2013-10-13 16:07:54 -05:00
Dale Rahn
75896b63ec Add Api to fetch potentially fully spent tx (most recent only)
Using FetchUnSpentTxByShaList only API required unexpected contortions
in btcchain.
2013-10-13 14:58:32 -04:00
Dave Collins
2ec9511891 Go fmt. 2013-10-13 13:04:16 -05:00
Dave Collins
d7e057a020 Make use of new spent vs unspent btcdb APIs.
This commit modifies the code to make use of the new btcd APIs that allow
fetching of transaction lists which either do or do not include fully
spent transactions.  It is more efficient to avoid fetching fully spent
transactions from the database when they aren't needed.
2013-10-13 02:40:02 -05:00
Dave Collins
9a29855c16 Convert inability to find input tx to a RuleError.
This commit modifies the errors that result from missing expected input
transactions to a RuleError.  This allows the caller to detect a block was
rejected due to a rule violation as opposed to an unexpected error.
2013-10-13 02:38:46 -05:00
Dave Collins
e5ba199eed Add example to BlockLocator comments. 2013-10-13 02:06:42 -05:00
Dave Collins
44aafcf742 Return on file error in address manager save.
This commit modifies the address manager save code to exit when there is
an error creating the file used to store addresses.  Previously the error
was only logged leaving the invalid file handle to be used later.
2013-10-12 11:49:10 -05:00
Dave Collins
1f87ee217a Move testdata to root btcd directory.
Rather than duplicating the same data, just put it under testsdata at the
root and access it from the modules from the parent directory.
2013-10-12 01:49:57 -05:00
Dale Rahn
b680d3539f Revive old validate Tx in parallel code, faster...
requested by davec, cleanup/polish in-tree.
2013-10-11 18:31:54 -04:00
John C. Vernaleo
6212a7daff Improve rpcserver.
Add getdifficulty command to rpcserver.

Add missing error check in an old bit of rpcserver.

Add getbestblockhash command.
2013-10-11 17:04:18 -04:00
Dave Collins
2a8122ffde Actually check orphan pool for IsOrphanInPool. 2013-10-11 15:46:24 -05:00
Dave Collins
6368d5b170 Respond to getdata requests for transactions.
This commit adds code to properly respond to getdata requests for
transactions by fetching them from the transaction pool.  Previously, we
advertised newly available transactions, but the code to respond with the
actual transaction was not written yet.

Also, fix a couple of comments and make the pushTxMsg and pushBlockMsg
functions consistent.
2013-10-11 14:14:55 -05:00
John C. Vernaleo
7ad6d73416 Add support for recent commands:
getrawchangeaddress and getbestblockhash.
2013-10-11 15:12:27 -04:00
Dave Collins
8be23c89ae Cleanup a few comments. 2013-10-11 10:24:13 -05:00
Dave Collins
39e7e5c4a1 Add minor optimization to transaction store fetch.
This commit adds a quick check to the transaction store fetch code which
simply returns an empty store if no hashes were requested rather than
bothering the db with an empty list.
2013-10-11 10:22:40 -05:00
Dale Rahn
6260dc959d When creating database, set version 1 so the correct options are set. 2013-10-11 09:44:09 -04:00
Dave Collins
10907027b7 Change failure to talk to DNS seeders to debug.
This is just a temporary failure and shouldn't be a warning.  Also,
remove redundant prefix on profile server log print while here.
2013-10-10 20:30:55 -05:00
Dave Collins
24aba3189e Update DISC subsystem log out for consistency. 2013-10-10 18:33:38 -05:00
Dave Collins
3d62b24fe1 Reformat periodic block height ouput and add time.
Closes #9.
2013-10-10 18:24:23 -05:00
Dave Collins
9772626dd8 Improve logging.
This commit is a first pass at improving the logging.  It changes a number
of things to improve the readability of the output.  The biggest addition
is message summaries for each message type when using the debug logging
level.

There is sitll more to do here such as allowing the level of each
subsystem to be independently specified, syslog support, and allowing the
logging level to be changed run-time.
2013-10-10 17:22:19 -05:00
Dave Collins
54b5cb56e7 Move logger code into its own file.
This cleans up btcd.go a bit and consolidates the logging related
functions.  It also paves the way for upcoming message summaries.
2013-10-10 14:36:05 -05:00
David Hill
55b300b6c2 improve addblock 2013-10-10 14:05:54 -04:00
David Hill
8a2299c1e1 improve dropafter as with showblock 2013-10-10 13:58:11 -04:00
David Hill
2231e04e2b improve showblock by setting default datadir and requiring -s 2013-10-10 13:51:20 -04:00