Commit graph

15 commits

Author SHA1 Message Date
Dave Collins
ae51c3e6e0 Update test coverage report. 2014-06-27 00:01:33 -05:00
Dave Collins
0550bbbdc5 Add tests for new RuleError and ErrorCode types. 2014-06-24 19:14:30 -05:00
Dave Collins
f37a5e76b5 Update tests for recent API changes. 2014-05-27 10:15:35 -05:00
David Hill
0cdaefd4cc export HashMerkleBranches
ok @davecgh
2014-05-22 13:29:39 -04:00
David Hill
936b4eaa2d add unit testing for BigToCompact, CompactToBig, and CalcWork 2014-03-11 22:33:56 -04:00
Dave Collins
1676ecd7a6 Export CheckConnectBlock function.
This commit makes a slight variant of the existing checkConnectBlock
function available to external callers.  The new exported version checks
if the passed block will connect to the end of the current main chain.

In order to support this, a few other small modifications have been made
to the initial index generation and the existing checkConnectBlock since
it previously made some assumptions about the state of genesis block which
can no longer be assumed due accepting blocks from callers directly.

Also, add a quick test to ensure the new function fails when checking if
the genesis block will connect again when it's already inserted.
2014-03-11 13:18:27 -05:00
Dave Collins
1c052a01d8 Reject blocks with high precision timestamps.
This commit adds an additional sanity check to ensure the block that is
being processed does not contain a timestamp with a precision higher than
one second.  This is necessary because the consensus rules only deal with
whole seconds in the time comparisons whereas the internal data structures
make use of Go time.Time values which support up to nanosecond precision.

Also, add a test to ensure the new functionality works as expected.

ok @owainga
2014-02-24 10:42:50 -06:00
Dave Collins
e888372019 Optimize transaction lookups.
This commit modifies the transaction lookup code to use a set instead of a
slice (list).  This allows the lookup to automatically prevent duplicate
requests to the database.

Previously, the code simply added every referenced transaction to a list
without checking for duplicates, which led to multiple requests against
the database for the same transaction.  It also meant the request list
could grow quite large with all of the duplicates using far more memory
than required.

While the end result was accurate, operating that way is not as efficient
as only requesting unique transactions.
2013-10-10 12:23:46 -05:00
Dave Collins
32790d52d8 Add tests for HaveBlock.
This commit adds tests to ensure HaveBlock works properly with blocks on
the main chain, a side chain, orphans, and missing blocks.
2013-10-09 18:43:22 -05:00
Dave Collins
0b334bc841 Correct reading of serialized height in coinbase.
This commit corrects the reading of the serialized height in coinbase
transactions for block height of version 2 or greater.  On mainnet, the
serialized height is always 3 bytes and will continue to be so for
something like  another ~159 years, so there was no issue with mainnet.
However on testnet, there are some version 2 blocks which are low enough
in the chain to only take 2 bytes to serialize.

In addition, this commit adds a full tests for the relavant function
including negative tests and variable length serialized lengths for block
heights.

Closes #1.
2013-10-06 14:27:53 -05:00
Dave Collins
bce548cb99 Update reorg test to insert genesis block first.
btcdb was changed a while back to not insert the genesis block by default.
This commit modifies the reorg test to insert it as required so not all
blocks are orphans.
2013-10-06 14:23:09 -05:00
Dave Collins
9787f46f6a Implement testnet specific rules.
This commit adds support for testnet specific rules when a new BlockChain
is created against testnet.
2013-07-24 17:03:29 -05:00
Dave Collins
f219ed5baf Add support for params based on active network.
This commit modifies the code to use params based on the active network
which paves the way for supporting the special rules and different genesis
blocks used by the test networks.
2013-07-24 12:26:17 -05:00
Dave Collins
f3e542ff92 Add negative test for duplicate block.
This commit adds tests for the error path when processing a block that is
already in the main chain.
2013-07-22 01:06:53 -05:00
Dave Collins
aa5847f3cc Initial implementation. 2013-07-19 08:50:13 -05:00