Commit Graph

930 Commits

Author SHA1 Message Date
Alex Morcos f41775b2c8
Implement helper class for CTxMemPoolEntry constructor
This is only for unit tests.
2018-02-09 18:35:25 +00:00
Ashley Holman e328fa32b3
TxMemPool: Change mapTx to a boost::multi_index_container
Indexes on:
- Tx Hash
- Fee Rate (fee-per-kb)
2018-02-09 18:35:25 +00:00
Jack Grigg 35d64c1fde
Use JoinSplitTestingSetup for Boost sighash tests
Symptom: When running all tests, the test suite passed. But when running the
sighash tests on their own, the test suite segfaulted.

Cause: The sighash tests depend on the proving parameters being accessible, but
BasicTestingSetup doesn't load them.
2018-01-31 15:31:51 +00:00
Cory Fields 47b71cec5d
chainparams: move CCheckpointData into chainparams.h
This unties CChainParams from its dependency on checkpoints. Instead, now it
only depends on the raw checkpoint data.
2018-01-22 10:30:41 -05:00
Mark Friedenbach fe53749dc9
Explicitly set tx.nVersion for the genesis block and mining tests
If/when CTransaction::CURRENT_VERSION is incremented, this will break CChainParams and the miner tests. This fix sets the transaction version explicitly where we depend on the hash value (genesis block, proof of work checks).
2018-01-22 10:30:41 -05:00
kozyilmaz bf69507cb5 Fix test/gtest bugs caught by latest macOS clang 2017-12-21 12:35:16 +03:00
Cory Fields 4165af1b73
c++11: don't throw from the reverselock destructor
noexcept is default for destructors as of c++11. By throwing in reverselock's
destructor if it's lock has been tampered with, the likely result is
std::terminate being called. Indeed that happened before this change.

Once reverselock has taken another lock (its ctor didn't throw), it makes no
sense to try to grab or lock the parent lock. That is be broken/undefined
behavior depending on the parent lock's implementation, but it shouldn't cause
the reverselock to fail to re-lock when destroyed.

To avoid those problems, simply swap the parent lock's contents with a dummy
for the duration of the lock. That will ensure that any undefined behavior is
caught at the call-site rather than the reverse lock's destruction.

Barring a failed mutex unlock which would be indicative of a larger problem,
the destructor should now never throw.
2017-11-29 17:24:59 +00:00
syd 6df5f51b7c Update to address @daira comments wrt fixing configure.ac
Since we're enforcing Boost >= 1.62, we no longer need HAVE_WORKING_BOOST_SLEEP_FOR.
2017-11-23 11:58:25 -05:00
Homu 6f9f09dfb0 Auto merge of #2670 - arielgabizon:lowmemprover, r=daira
Low memory prover

This PR integrates @ebfull 's low memory changes:  https://github.com/zcash/zcash/pull/2243/commits
on top of @str4d 's work bringing in libsnark as a subtree
4699d0eb36
2017-11-06 04:22:20 -08:00
Jack Grigg bef1b5ce1b
Fix NPE in rpc_wallet_tests 2017-11-05 12:02:21 -05:00
Simon c5dabd2b66 Closes #2639. Adds optional limit parameter with a default value of 50.
The new parameter is to satisfy the principle of least astonishment
by providing a sensible default for the maximum number of transparent
inputs to shield.  If users do not configure -mempooltxinputlimit
it is possible for them to create transactions with hundreds of
inputs which suffer from mining delay, due to the current state of
the network where some miners have configured -mempooltxinputlimit
as a way to deal with the problem of quadratic hashing.
2017-11-01 10:40:24 -07:00
Sean Bowe 1a9543d064 Remove crusty old "loadVerifyingKey"/"loadProvingKey" APIs and associated invariants. 2017-10-21 15:42:41 +03:00
Simon 06c19063bb Implement RPC shield_coinbase #2448. 2017-09-21 15:04:12 -07:00
Simon b639bb1eef Fixes #2519. When sending from a zaddr, minconf cannot be zero. 2017-07-11 11:29:43 -07:00
Daira Hopwood 00fde35b1c Make transaction test failures print the comments preceding the test JSON.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2017-06-19 16:33:18 +01:00
Daira Hopwood 4a785b0a5b Repair tests for strict DER signatures.
While we're at it, repair a similar test for CLTV, and make the repaired RPC tests run by default.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2017-06-19 16:32:15 +01:00
Daira Hopwood de609b8c54 Strict DER signatures are always enforced; remove the flag and code that used it.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2017-06-17 17:19:08 +01:00
Pieter Wuille 3d02d0f63a
Switch to libsecp256k1-based validation for ECDSA 2017-06-06 17:52:25 +12:00
Jack Grigg 2857f6960d
Regenerate miner tests
Closes #2271.
2017-05-16 22:38:07 +12:00
Homu 01bc99205a Auto merge of #2251 - str4d:2210-tor-quotedstring-escapes, r=nathan-at-least
Handle escapes in Tor QuotedStrings

Also adds a missing copyright header.

Closes #2210.
2017-05-13 15:24:58 -07:00
Jack Grigg 409606118b
Check that >3-digit octals are truncated. 2017-04-21 13:23:29 +12:00
Jack Grigg 8df5fd1116
Correctly handle three-digit octals with leading digit 4-7 2017-04-21 13:22:51 +12:00
Jack Grigg d15cab21bc
Address Daira's further comments 2017-04-21 13:15:39 +12:00
Jack Grigg 0b431fbdb5
Address Daira's comments 2017-04-19 15:23:28 +12:00
Jack Grigg b93cedafe4
torcontrol: Handle escapes in Tor QuotedStrings
https://trac.torproject.org/projects/tor/ticket/14999 is tracking an encoding
bug with the Tor control protocol, where many of the QuotedString instances that
Tor outputs are in fact CStrings, but it is not documented which ones are which.

https://spec.torproject.org/control-spec section 2.1.1 provides a future-proofed
rule for handing QuotedStrings, which this commit implements.
2017-04-18 12:54:16 +12:00
str4d e40180aa0f Update tests to check actual infinity as well as INF_FEERATE 2017-04-13 17:59:36 +01:00
Daira Hopwood 0090c64534 Don't rely on a finite upper bound on fee rate or priority.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2017-04-13 17:59:36 +01:00
Jack Grigg 6dbd95afa1
torcontrol: Add unit tests for Tor reply parsers 2017-03-26 00:34:53 +13:00
zkbot f9f48667be Auto merge of #2176 - str4d:1593-libevent, r=bitcartel
libevent-based http server

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#5677
- bitcoin/bitcoin#6695
- bitcoin/bitcoin#6899
- bitcoin/bitcoin#7016
- bitcoin/bitcoin#7964
- bitcoin/bitcoin#8722
- bitcoin/bitcoin#8730
- bitcoin/bitcoin#9073
- bitcoin/bitcoin#9265
- bitcoin/bitcoin#9387
- bitcoin/bitcoin#9471
- bitcoin/bitcoin#9647
- bitcoin/bitcoin#9903
- bitcoin/bitcoin#6640
- bitcoin/bitcoin#8139
- bitcoin/bitcoin#8839

Closes #1593 and #1856.
2017-03-25 04:52:16 +00:00
zkbot 6344719817 Auto merge of #2052 - str4d:2032-z_importkey-partial-rescan, r=bitcartel
Usability improvements for z_importkey

- Add height parameter to z_importkey to reduce rescan range
- Change semantics of rescan parameter, so users can explicitly force a rescan
  for existing keys.

Closes #2032
2017-03-24 03:47:11 +00:00
Jack Grigg 33589401ba
Require that z_importkey height parameter be in valid range 2017-03-24 16:07:53 +13:00
zkbot 23f792c2f5 Auto merge of #2187 - bitcartel:1.0.7_getblock_by_height, r=bitcartel
Closes #2186. RPC getblock now accepts height or hash.
2017-03-24 02:55:27 +00:00
Simon 7d3b152897 Closes #2186. RPC getblock now accepts height or hash. 2017-03-23 19:25:04 -07:00
Luke Dashjr c65969a5a6
Skip RAII event tests if libevent is built without event_set_mem_functions 2017-03-24 09:03:59 +13:00
Karl-Johan Alm e8b6d84b9f
Added some simple tests for the RAII-style events. 2017-03-24 09:03:59 +13:00
Wladimir J. van der Laan 72f52420ec
Remove rpc_boostasiotocnetaddr test
Dropping all use of boost::asio.
2017-03-24 09:03:59 +13:00
Jack Grigg a31ba7a0cb
Usability improvements for z_importkey
- Add height parameter to z_importkey to reduce rescan range
- Change semantics of rescan parameter, so users can explicitly force a rescan
  for existing keys.

Closes #2032
2017-03-16 19:34:41 +13:00
Pieter Wuille 6bd1d60c97
Separate core memory usage computation in core_memusage.h 2017-03-14 13:45:05 +13:00
zkbot a7cf698873 Auto merge of #2100 - str4d:2074-rpc, r=arcalinea
Bitcoin 0.12 RPC PRs 1

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6266
- bitcoin/bitcoin#6257
- bitcoin/bitcoin#6271
- bitcoin/bitcoin#6158
- bitcoin/bitcoin#6307
- bitcoin/bitcoin#6290
- bitcoin/bitcoin#6262
- bitcoin/bitcoin#6088
- bitcoin/bitcoin#6339
- bitcoin/bitcoin#6299 (partial, remainder in #2099)
- bitcoin/bitcoin#6350
- bitcoin/bitcoin#6247
- bitcoin/bitcoin#6362
- bitcoin/bitcoin#5486
- bitcoin/bitcoin#6417
- bitcoin/bitcoin#6398 (partial, remainder was included in #1950)
- bitcoin/bitcoin#6444
- bitcoin/bitcoin#6456 (partial, remainder was included in #2082)
- bitcoin/bitcoin#6380
- bitcoin/bitcoin#6970

Part of #2074.
2017-03-04 02:57:46 +00:00
zkbot dadb1ab74c Auto merge of #2101 - str4d:2074-tests, r=arcalinea
Bitcoin 0.12 test PRs 1

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6337
- bitcoin/bitcoin#6390
- bitcoin/bitcoin#5515
- bitcoin/bitcoin#6287 (partial, remainder included in bitcoin/bitcoin#6703)
- bitcoin/bitcoin#6465

Part of #2074.
2017-03-03 21:25:03 +00:00
Wladimir J. van der Laan 1eb6654314
tests: Fix bitcoin-tx signing testcase
Fixes wrong scriptPubkey problem, which caused the transaction to
not actually be signed.
2017-03-03 11:47:01 -08:00
Jonas Schnelli 51878774bf
extend bip32 tests to cover Base58c/CExtKey decode 2017-03-03 10:57:25 -08:00
Jorge Timón e079f010bf
Consensus: Refactor: Separate Consensus::CheckTxInputs and GetSpendHeight in CheckInputs
Zcash:
- Replaces some of the refactoring performed in #1017
- Exposed Consensus::CheckTxInputs for testing
2017-03-03 10:57:09 -08:00
Pieter Wuille bfa832c7ed
Reduce checkpoints' effect on consensus.
Instead of only checking height to decide whether to disable script checks,
actually check whether a block is an ancestor of a checkpoint, up to which
headers have been validated. This means that we don't have to prevent
accepting a side branch anymore - it will be safe, just less fast to
do.

We still need to prevent being fed a multitude of low-difficulty headers
filling up our memory. The mechanism for that is unchanged for now: once
a checkpoint is reached with headers, no headers chain branching off before
that point are allowed anymore.
2017-03-03 10:57:07 -08:00
Jack Grigg 14454a3a82
Fix typo in listbanned RPC keys 2017-03-02 13:26:34 -08:00
Jonas Schnelli 5548701eeb
UniValue: don't escape solidus, keep espacing of reverse solidus
Zcash: The UniValue changes are already merged; this updates the test
2017-03-02 13:23:03 -08:00
Matt Corallo 3d8013a01b
Add fundrawtransaction RPC method 2017-03-02 13:23:03 -08:00
Jonas Schnelli fa80be8ff5
setban: add IPv6 tests 2017-03-02 13:23:03 -08:00
Jonas Schnelli fcc8920f36
setban: rewrite to UniValue, allow absolute bantime 2017-03-02 13:23:03 -08:00
Jonas Schnelli e521939942
[RPC] extend setban to allow subnets 2017-03-02 13:23:03 -08:00
Jonas Schnelli 962ec4b5e4
[QA] add setban/listbanned/clearbanned tests 2017-03-02 13:23:03 -08:00
Daniel Kraft e940185294
Fix univalue handling of \u0000 characters.
Univalue's parsing of \u escape sequences did not handle NUL characters
correctly.  They were, effectively, dropped.  The extended test-case
fails with the old code, and is fixed with this patch.
2017-03-02 13:23:03 -08:00
Simon ebe750a882 Part of #1969. Changing min fee calculation also changes the dust threshold. 2017-02-28 11:44:07 -08:00
zkbot eaaa5f625f Auto merge of #2082 - str4d:univalue-subtree, r=bitcartel
Add UniValue as subtree

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6637
- bitcoin/bitcoin#6239
- bitcoin/bitcoin#6379
- bitcoin/bitcoin#6456
- bitcoin/bitcoin#6788
2017-02-10 07:46:58 +00:00
zkbot e51bd1b556 Auto merge of #1990 - str4d:1985-replace-json-spirit-with-univalue, r=str4d
Convert entire source tree from json_spirit to UniValue

This PR cherry-picks bitcoin/bitcoin#6121 and then migrates the Zcash-specific code to UniValue.

Also cherry-picks:
- bitcoin/bitcoin#6241
- bitcoin/bitcoin#6234

Closes #1985.
2017-02-10 05:15:53 +00:00
Wladimir J. van der Laan 2aee461930
univalue: Avoid unnecessary roundtrip through double for numbers
JSON makes no distinction between numbers and reals, and our code
doesn't need to do so either.

This removes VREAL, as well as its specific post-processing in
`UniValue::write`. Non-monetary amounts do not need to be forcibly
formatted with 8 decimals, so the extra roundtrip was unnecessary
(and potentially loses precision).

Zcash: cherry-picked from commit 7650449a6777710cf818d41862626164da0cd412
Dropped changes to qa/rpc-tests/rest.py pending addition of /rest/headers/
2017-02-10 02:19:01 +00:00
Wladimir J. van der Laan d5bf1afae9
rpc: Make ValueFromAmount always return 8 decimals
This is the format that was always returned to JSON clients.
The difference was not noticed before, because VREAL values
are post-processed by univalue.

By implementing the functionality directly it breaks the dependency
of rpcserver on utilmoneystr. FormatMoney is now only used for debugging
purposes.

To test, port over the formatting tests from util_tests.cpp to
rpc_tests.cpp.
2017-02-10 02:18:59 +00:00
Wladimir J. van der Laan fed500e2dd
rpc: Accept scientific notation for monetary amounts in JSON
Add a function `ParseFixedPoint` that parses numbers according
to the JSON number specification and returns a 64-bit integer.

Then this in `AmountFromValue`, rather than `ParseMoney`.

Also add lots of tests (thanks to @jonasschnelli for some of them).

Fixes issue #6297.
2017-02-10 02:18:58 +00:00
Wladimir J. van der Laan e76a3849c6
Changes necessary now that zero values accepted in AmountFromValue
- Add an accept test for zero amounts, and a reject test for negative
  amounts
- Remove ugly hack in `settxfee` that is no longer necessary
- Do explicit zero checks in wallet RPC functions
- Don't add a check for zero amounts in `createrawtransaction` - this
  could be seen as a feature
2017-02-10 02:18:57 +00:00
Wladimir J. van der Laan a5beb3a51b
Get rid of fPlus argument to FormatMoney
It's never used with any other value than false, the default.
2017-02-10 02:18:55 +00:00
Jonas Schnelli a10a6e2a0e
[Univalue] add univalue over subtree
similar to secp256k1 include and compile univalue over a subtree
2017-02-10 02:18:51 +00:00
Jack Grigg cc71666a51
unsigned int -> size_t for comparing with UniValue.size() 2017-02-10 00:53:13 +00:00
Jack Grigg 0d37ae3a59
Migrate Zcash-specific code to UniValue 2017-02-10 00:52:57 +00:00
Jonas Schnelli b60e9f230f
fix util_tests.cpp clang warnings
was introduced with #6121
2017-02-10 00:35:24 +00:00
Jonas Schnelli 6b1e42bbfa
univalue: add type check unit tests 2017-02-10 00:35:24 +00:00
Wladimir J. van der Laan 5960d70002
util: Add ParseInt64 and ParseDouble functions
Strict parsing functions for other numeric types.

- ParseInt64 analogous to ParseInt32, but for 64-bit values.
- ParseDouble for doubles.
- Make all three Parse* functions more strict (e.g. reject whitespace on
  the inside)

Also add tests.
2017-02-10 00:35:24 +00:00
Wladimir J. van der Laan ff67da37cd
Simplify RPCclient, adapt json_parse_error test
# Conflicts:
#	src/test/rpc_tests.cpp
2017-02-10 00:35:24 +00:00
Jonas Schnelli c288192b19
fix univalue json parse tests 2017-02-10 00:35:24 +00:00
Jonas Schnelli d014114d67
Remove JSON Spirit wrapper, remove JSON Spirit leftovers
- implement find_value() function for UniValue
- replace all Array/Value/Object types with UniValues, remove JSON Spirit to UniValue wrapper
- remove JSON Spirit sources
2017-02-10 00:35:24 +00:00
Jonas Schnelli 851f58f94e
remove JSON Spirit UniValue wrapper 2017-02-10 00:35:24 +00:00
Jonas Schnelli 565d26737a
fix rpc unit test, plain numbers are not JSON compatible object
UniValues read() does only read valid json.
2017-02-10 00:35:24 +00:00
Jonas Schnelli 49a5df0ef3
univalue: add support for real, fix percision and make it json_spirit compatible
- avoid breaking the API because of different number/percision handling
2017-02-10 00:35:24 +00:00
Jonas Schnelli 38fc4b7090
expicit set UniValue type to avoid empty values 2017-02-10 00:35:24 +00:00
Jonas Schnelli 9756b7bd29
extend conversion to UniValue 2017-02-10 00:35:24 +00:00
Jeff Garzik ed21d5bd4b
Convert tree to using univalue. Eliminate all json_spirit uses. 2017-02-10 00:35:24 +00:00
Jeff Garzik ec57cc0ffe
UniValue: prefer .size() to .count(), to harmonize w/ existing tree 2017-02-10 00:35:24 +00:00
Simon 6605125d4e Add comment about fix for #2026. 2017-02-09 15:17:21 -08:00
Sean Bowe 05ec7887f1 Fix use after free in transaction_tests. 2017-02-09 14:35:33 -07:00
Jack Grigg 2cc0a252ad
Add compile flag to disable compilation of mining code 2017-01-30 21:14:46 +01:00
Simon 9064d73bf8 Fixes #1497 ZCA-009 by restricting data exporting to user defined folder.
Previously the RPC interface allowed z_exportwallet, backupwallet and
dumpwallet to write data to an arbitrary filename.  ZCA-009 demonstrates
how this is vulnerable.  The resolution is to only allow data to
written when the -exportdir has been configured.  Also filenames are
restricted to alphanumeric characters.
2017-01-16 10:56:06 -08:00
Jack Grigg 6fb8d0c2d6
Skip JoinSplit verification before the last checkpoint
Part of #1749
2016-12-09 21:06:45 +13:00
zkbot a398121503 Auto merge of #1919 - ebfull:abstract-verification, r=str4d
Isolate verification to a ProofVerifier context object that allows verification behavior to be tuned by the caller.

This is an alternative foundation for #1892, i.e., #1892 will have to be changed if this PR is accepted.

I think this is a safer approach because it allows us to isolate verification behavior to a single object. This will come in handy when @arielgabizon finishes the batching code.
2016-12-09 06:22:53 +00:00
zkbot cdbd851417 Auto merge of #1928 - ebfull:fix-anchor-cache-bug, r=str4d
Fix anchor cache bug

Fixes #1912.

If an anchor is removed from the cache, but didn't exist in it beforehand, it will insert a blank tree. If it's reinserted in a child cache, when the child cache flushes it will mark the treestate as entered but won't bring the valid tree with it.

Thankfully, we assert when connecting blocks so that this inconsistency won't cause us to build on a blank tree after a reorg.
2016-12-08 21:22:23 +00:00
Sean Bowe 08de001a25 Regression test. 2016-12-06 12:54:53 -07:00
Sean Bowe bc59f53722 Isolate verification to a `ProofVerifier` context object that allows verification behavior to be tuned by the caller. 2016-12-05 12:40:06 -07:00
Simon af53da0225 Closes #1903. Add fee parameter to z_sendmany. 2016-11-30 14:23:35 -08:00
Sean Bowe f398a94766 Anchors and nullifiers should always be inherited from the parent cache. 2016-11-17 11:43:54 -07:00
Sean Bowe d92bea9888 Add tests for witness `element` and tree `last` methods. Strengthen testing by inserting a different commitment into the tree at each step. 2016-11-14 10:13:06 -07:00
Simon 4e16a7249c Closes #1746. Add rpc call z_validateaddress to validate zaddrs. 2016-10-31 20:05:48 -07:00
Jack Grigg 657bde55ef
Update tests for new genesis blocks
Miner tests have been commented out, and will be regenerated after launch.
2016-10-28 02:56:15 -07:00
Jack Grigg ab32254909
Update tests for new genesis blocks 2016-10-27 02:45:21 -07:00
Jack Grigg 2f5d62fe32
Remove Founders' Reward override from #1398 2016-10-26 21:05:17 -07:00
zkbot 30d3d2dfd4 Auto merge of #1603 - str4d:1556-reject-old-block-versions, r=daira
Reject block versions lower than 4

Includes parts of #1554
Closes #1556
2016-10-22 14:32:40 -04:00
Jack Grigg f4f1b4b097
Update sighash tests for new consensus rule 2016-10-22 11:09:07 -05:00
Daira Hopwood 789914e7b0 Update comments in chainparams.cpp.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2016-10-22 13:46:22 +01:00
Jack Grigg 86d2c90468
Update tests for new genesis blocks 2016-10-22 00:52:58 -05:00
Jack Grigg 8c54e34a68
Use tromp's solver to regenerate miner tests
When using, comment out tromp's solver in miner.cpp to avoid linker errors.
2016-10-22 00:52:56 -05:00
zkbot 7ccbcca62c Auto merge of #1591 - bitcartel:upstream_7933_fix_out_of_memory_deserializing_utxo, r=daira
Upstream: fix out of memory problem when deserializing utxo

bitcoin/bitcoin#7933
2016-10-21 23:32:51 -04:00
zkbot 10ad093bbb Auto merge of #1567 - str4d:rename-binaries, r=daira
Rename binaries

This ensures that our installs don't clash with existing Bitcoin binaries and libraries.

Closes #1563 and #1565
2016-10-21 20:48:11 -04:00
Simon 43f0769cf6 Fix build problem with coins_tests 2016-10-20 23:50:19 -07:00