Commit graph

3447 commits

Author SHA1 Message Date
Dave Collins
8d8fdf4fc1 Add documentation for Db interface. 2013-05-31 15:12:42 -05:00
Dave Collins
5882b3c79a Change Tx to transaction in user facing error. 2013-05-31 14:07:48 -05:00
Dave Collins
64568826f1 Correct spelling of nonexistent. 2013-05-31 14:04:14 -05:00
Dave Collins
b686bbacf5 Update and fix usage example.
This commit updates the usage example as follows:

- Add a defer db.Close since the database should be closed after the
  caller is done with it
- Correct the import path for the btcdb/sqlite3 package
- Add a db extension to the example database name
- Make the error handling and comments match the standard style
2013-05-31 13:57:18 -05:00
Dave Collins
fac055c24e Add comments to clarify interface function caching.
This commit attempts to clarify which functions in the Db interface may be
returning cached data that the InvalidateCache, InvalidateBlockCache, and
InvalidateTxCache functions are used to clear.
2013-05-31 13:40:38 -05:00
John C. Vernaleo
4ab8ca5eef Add code to test for allowable types in json rpc id field along with test code for the new function. 2013-05-31 10:59:46 -04:00
Dave Collins
7416e9a71d Rename funcs and variables for Idx to Height.
The Db interface is intended to work with block heights as opposed to
specific database ids which may or may not be the same as the block
height.  This commits changes the function names to make that distinction
a little more clear.
2013-05-30 17:35:59 -05:00
AndreasM
7b4aeb2353 the JSON-RPC 1.0 spec allows the id to be of any type 2013-05-31 01:23:23 +03:00
Dave Collins
bea4ccbeef Finish incomplete comment. 2013-05-30 17:21:15 -05:00
Dave Collins
684582cde6 Cleanup the Db interface comments a bit. 2013-05-30 17:18:43 -05:00
Dave Collins
e76c83b27f Fix typo in README.md. 2013-05-29 18:11:27 -05:00
Dave Collins
b4e38662ba Update README.md. 2013-05-29 16:43:05 -05:00
Dave Collins
6ac2a9b934 Add note to README.md that Db interface may change. 2013-05-29 16:41:51 -05:00
Dave Collins
f6c3d6d57a Fix typo in README.md. 2013-05-29 16:36:45 -05:00
Dave Collins
c97c8f17a4 Add test coverage report and generate script.
Both of these items were referenced in the README.md, but were not
in the repository.
2013-05-29 16:20:06 -05:00
Dave Collins
e30ceb5947 Cleanup and fix operational tests.
This commit makes several changes to the operation tests as follows:

- Ensure the database is closed between each operational mode test as
  otherwise  the database is locked when trying to reopening it which
  makes it unusable
- Make the insert tests error after a single failure since every test
  afterwards is guaranteed to fail as well
- Remove some of the logging statements which cluttered up the failed test
  prints making it harder to see why a given test failed
- Make a couple of the log messages more descriptive
2013-05-29 16:11:13 -05:00
Dave Collins
9bf708595d Add InsertBlockData needed by tests to interface.
The function is being added back in since the tests rely on it, but it is
marked as DEPRECATED since it really should not be a part of the public
generic db interface.
2013-05-29 15:30:26 -05:00
Dave Collins
21b8011155 Remove log setup from tests as they don't need it. 2013-05-29 14:49:21 -05:00
Dave Collins
1846307821 Use correct import path in btcdb tests. 2013-05-29 14:48:18 -05:00
mischief
7630a95724 fix Stringer interface for ShaHash.
http://golang.org/ref/spec#Method_sets for why this is necessary
2013-05-29 11:51:13 -07:00
Owain G. Ainsworth
a2e3fd92b0 Only try to drop the uniquetx index if it exists.
Solves a corner case after a crash.
2013-05-29 17:54:46 +01:00
Dave Collins
752ca5dfbb Initial implementation. 2013-05-29 10:09:26 -05:00
Dave Collins
a02af039b5 Initial commit. 2013-05-28 19:03:53 -05:00
Dave Collins
14a1da417f Enforce max block payload size of 1MB.
This commit changes MsgBlock to enforce a 1MB max payload per the spec.
Previously it was only limited to the max overall message size.  While
here, also enforce max payloads per message type (instead of only the max
overall message payload) when writing messages.
2013-05-16 09:07:04 -05:00
Dave Collins
c896d61625 Improve examples in package overview documentation.
This commit makes the examples a little more clear by providing complete
examples of the two different types of replies.  These changes were
prompted by PaulCapes on IRC who pointed out the previous example was not
very clear.

ok jcv@
2013-05-15 19:35:36 -05:00
Dave Collins
d8007e9387 Update README to reflect 100% test coverage. 2013-05-15 14:00:06 -05:00
Dave Collins
c164de1692 Fix version typos in README. 2013-05-15 13:57:29 -05:00
John C. Vernaleo
2fc8982be5 Add tests for MarshallAndSend function. 2013-05-15 10:08:05 -04:00
Dave Collins
f8553b4a57 Remove test coverage TODO since it's now 100%. 2013-05-13 13:55:07 -05:00
Dave Collins
648e6317bb Fix comment typo -- implimented -> implemented. 2013-05-13 13:21:01 -05:00
John C. Vernaleo
d0d58c54db Initial implementation. 2013-05-13 12:25:41 -04:00
Dave Collins
a3226897f0 Update package overview Errors section.
Now that all errors are either underlying IO errors or of type
MessageError, update the package overview documentation accordingly.
2013-05-13 02:19:57 -05:00
Dave Collins
5b78dee7e1 Add negative tests for MsgTx.
This commit adds tests for the error paths when encoding and decoding
MsgTx.  This commit also achieves 100% test coverage.
2013-05-13 02:09:55 -05:00
Dave Collins
6f511eb75d Make MsgTx test data available to all funcs.
Rather than having to repeat the same data for positive and negative
tests, make the same test data available to both.
2013-05-13 02:08:14 -05:00
Dave Collins
f9b6375d5b Add negative tests for MsgVersion.
This commit adds tests for the error paths when encoding and decoding
MsgVersion.
2013-05-12 21:47:36 -05:00
Dave Collins
3aef93f442 Make MsgVersion test data available to all funcs.
Rather than having to repeat the same data for positive and negative
tests, make the same test data available to both.
2013-05-12 21:01:40 -05:00
Dave Collins
1bab947596 Remove a few dead error checks.
The functions for generating transaction and block hashes contained a few
error checks for conditions which could never fail without run-time
panics.  This commit removes those superfluous checks and adds explanatory
comments.
2013-05-12 14:01:50 -05:00
Dave Collins
1ca8015ea0 Add negative tests for MsgBlock tx location decode.
This commit adds tests for the error paths when decoding MsgBlock via the
transaction location decode variant.
2013-05-12 12:48:52 -05:00
Dave Collins
0e033023bf Improve MsgBlock negative tests.
Rather than decoding from a zero-filled buffer, use valid block encoded
test data.
2013-05-12 12:43:01 -05:00
Dave Collins
4e16030fe8 Add tests for MsgBlock transaction location decode. 2013-05-12 11:52:35 -05:00
Dave Collins
c9d2dfea3d Add negative tests for WriteMessage.
This commit adds tests for the error paths when writing a message
to the wire.
2013-05-11 23:34:10 -05:00
Dave Collins
0400d0cec3 Remove dead error check in WriteMessage.
The io.Writer.Write function always returns an error if the bytes written
is less than provided, so there is no reason to further check if the
payload length matches after a successful write.
2013-05-11 23:22:09 -05:00
Dave Collins
7385f6ff24 Correct several test error messages. 2013-05-11 12:55:50 -05:00
Dave Collins
93070ef960 Add negative tests for MsgAlert.
This commit adds tests for the error paths when encoding and decoding
MsgAlert.
2013-05-11 12:49:22 -05:00
Dave Collins
3d303feefb Add negative test for NewShaHash.
This commit adds a test to ensure NewShaHash fails as expected when the
passed buffer has too many bytes to be a valid sha hash.
2013-05-11 11:19:46 -05:00
Dave Collins
61b86b1bb5 Add negative tests for MsgGetBlocks.
This commit adds tests for the error paths when encoded and decoding
MsgGetBlocks.
2013-05-11 11:06:52 -05:00
Dave Collins
2a2745d0d3 Add negative tests for MsgGetHeaders.
This commit adds tests for the error paths when encoded and decoding
MsgHeaders.   Also, while here modify the casing of the local vars to be
consistent.
2013-05-11 10:52:22 -05:00
Dave Collins
20bebc13a5 Convert WriteMessage errors to MessgeError type. 2013-05-11 02:29:29 -05:00
Dave Collins
cbcbe5eb43 Convert MsgVersion errors to MessageError type. 2013-05-11 02:23:45 -05:00
Dave Collins
f6cdbd430e Convert MsgMemPool errors to MessageError type. 2013-05-11 02:18:03 -05:00