Commit graph

22 commits

Author SHA1 Message Date
Dave Collins 2eef3720a9 Import btcwire repo into wire directory.
This commit contains the entire btcwire repository along with several
changes needed to move all of the files into the wire directory in
order to prepare it for merging.  This does NOT update btcd or any of the
other packages to use the new location as that will be done separately.

- All import paths in the old btcwire test files have been changed to the
  new location
- All references to btcwire as the package name have been chagned to
  wire
- The coveralls badge has been removed since it unfortunately doesn't
  support coverage of sub-packages

This is ongoing work toward #214.
2015-01-31 14:59:57 -06:00
Dave Collins d3e2947c05 Update btcwire import paths to new location. 2015-01-16 13:54:11 -06:00
Dave Collins 4b6cd17561 Make RandomUint64 block until entropy is available.
This commit modifies the RandomUint64 function so that rather than
returning an io.ErrShortBuffer when the system does not have enough
entropy available, it now blocks until it does have enough.  This means
that RandomUint64 will now always eventually succeed unless the entropy
source is closed (which only really ever happens when the operating system
is shutting down).

The tests have also been updated for the change in semantics to maintain
100% coverage.

Closes #23.
2014-11-14 12:17:18 -06:00
Dave Collins 225248d283 Use byte literals in tests to make go vet happy.
The go vet command complains about untagged struct initializers when
defining a ShaHash directly.  This seems to be a limitation where go vet
does not exclude the warning for types which are a constant size byte array
like it does for normal constant size byte array definition.

This commit simply modifies the tests to use a constant definition cast to a
ShaHash to overcome the limitation of go vet.
2014-09-05 13:58:40 -05:00
Dave Collins 3a1009529f goimports -w . 2014-07-02 19:43:33 -05:00
Dave Collins ee46a0b108 Use bytes.NewReader for deserialize when possible.
Rather than using bytes.NewBuffer, which is a read/write entity
(io.ReadWriter), use bytes.NewReader which is only a read entitiy
(io.Reader) in all cases where it is possible.  Benchmarking shows it's
slightly faster and it's also technically more accurate since it ensures
the data is read-only.

There are a few cases where bytes.NewBuffer must still be used since a
buffer with a known length is required for those instances.
2014-06-04 23:39:03 -05:00
Dave Collins dfdd223223 Move genesis blocks to btcnet package.
The genesis blocks are not really part of the wire protocol rather they
are part of a network parameters.  Thus, this commit moves the all of the
gensis blocks and tests to the btcnet package.

Also, create variables in the test package for the mainnet genesis hash,
merkle root, and coinbase transaction for use throughout the tests since
they the exported values are no longer available.
2014-05-28 09:14:38 -05:00
Dave Collins a98f5ca38e Cleanup a few nitpicks with recent alert additions.
- Group the new read/writeVarBytes functions together to be consistent
  with the existing code
- Modify the comments on the new read/writeVarBytes to be a little more
  descriptive and consistent with existing code
- Use "test payload" for field name in the tests for the
  read/writeVarBytes functions which is more accurate
- Remove reserved param from NewAlert since there is no point is having
  the caller deal with a reserved param
- Various comment tweaks for clarity and consistency
- Use camel case for fuction params for consistency
- Move the NewAlert and NewAlertFromPayload functions after the receiver
  definitions for code layout consistency

Closes #11.
2014-05-07 19:41:04 -05:00
Javed Khan bdec7f8abb Implemented alert message serialize/deserialize
* Introduced common methods readVarBytes, writeVarBytes.
* Added type Alert which knows how to deserialize
the serialized payload and also serialize itself back.
* Updated MsgAlert BtcEncode/BtcDecode methods to handle the
new Alert.
* Sane limits are placed on variable length fields like SetCancel
and SetSubVer
2014-05-05 23:12:28 +05:30
Dave Collins 937374c95a Cleanup and finish relay transaction work.
- Coalesce the new bytes into the max message size constant to stay
  consistent
- Correct optional relay tx field handling
- Rename the relay transactions field to DisableRelayTx so the zero value
  of false has the correct default behavior
- Add tests for new bool fast paths in read/writeElement
- Stay consistent with version order in tests
- Add a single entry to TestVersionWire to test the new functionality
  instead of adding a whole new TextVersionRelayTx function.
- Use BIP0037 in tests instead of hard coding 70001
- Nuke XXX that 70001 is different since this is handled now
- Fix and cleanup some comments
- Update test coverage report
2014-03-31 11:35:36 -05:00
Dave Collins b9c21bd518 Export VarIntSerializeSize function.
This commit exports the VarIntSerializeSize function to provide callers
with an easy method to determine how many bytes it would take to serialize
the passed value as a variable length integer.
2014-03-03 18:43:09 -06:00
David Hill d0dfff8292 fix typo in test: use %s for strings 2014-02-04 14:35:38 -05:00
Dave Collins 6c7f45fdb7 Add 2014 to copyright dates. 2014-01-08 23:44:08 -06:00
Dave Collins 6f61e0acc2 Add negative tests for updated read/writeElement.
This commit adds tests for the error paths in the updated readElement and
writeElement functions.

This brings the test coverage back up to 100%.
2013-11-07 05:37:48 -06:00
Dave Collins 119a2ddc75 Add tests for updated readElement/writeElement.
This commit adds tests to ensure the new "fast" paths in readElement and
writeElement work properly including proper fallback to the slower
reflection based read/write of the binary package.
2013-11-07 05:17:17 -06:00
Dave Collins b7b700fd5a Add tests for the new SerializeSize functions.
This commit adds tests for the new SerializeSize functions for variable
length integers and transactions (and indirectly transaction inputs and
outputs).
2013-10-31 00:20:41 -05:00
Dave Collins bd297491b9 Make var length string overflow tests consistent.
This commit modifies the variable length string overflow tests slight to
make them consistent with the other overflow tests.
2013-10-25 09:55:27 -05:00
Dale Rahn 70aa92bf0d Test some boundary conditions that exercise 'flaws' in the current
btcwire protocol.
2013-10-24 14:39:40 -04:00
Dave Collins 65eae18285 Remove a couple of incorrect comments. 2013-07-24 00:35:16 -05:00
Dave Collins 3cd90355df Correct error output string colon placement. 2013-05-09 11:36:29 -05:00
Dave Collins bf5c0b58d8 Fix a few comment typos. 2013-05-09 00:02:07 -05:00
Dave Collins 69b27dd5d3 Initial implementation. 2013-05-08 18:58:29 -05:00