Commit graph

796 commits

Author SHA1 Message Date
Ross Nicoll f338f2b802 Rename binaries to match Dogecoin 2018-09-23 22:32:23 +01:00
Ross Nicoll e4f734dd40 Update tx output in p2p-fullblocktest.py (#1474)
* Update tx output in `p2p-fullblocktest.py` to match Dogecoin coin reward.
* Disable the re-org test as it disconnects the mini-node before the re-org completes.
2018-09-19 22:11:47 +01:00
Ross Nicoll 9c3a11b248 Clean up RPC tests (#1465)
* Enable full block tests
* Fix invalidblocktest
* Move watch only address funding to immediately before it's used, so node 0 doesn't spend the output before it checks it later.
* Fix `fundrawtransaction` tests and sanitize fee calculation at the same time
* Correct resolution of chain parameters when validating tx inputs, especially from previous coinbase transactions
* Set block versions on full block tests so that the generated blocks are AuxPoW compatible
2018-09-19 22:11:47 +01:00
Ross Nicoll b6b5ee7502 Update RPC tests for Dogecoin (#1431)
* Make most of the RPC tests pass
* Add AUXPoW rpc tests
- Tests the auxpow rpc interface `getauxblock`
- Tests consensus constraints for auxpow:
  - Minimum block height
  - Valid scrypt proof of work
  - Foreign chain ID
2018-09-19 22:11:47 +01:00
Ross Nicoll bc8cca4896 Merge AuxPoW support from Namecore
Changes are as below:

Wrap CBlockHeader::nVersion into a new class (CBlockVersion).  This allows to take care of interpreting the field into a base version, auxpow flag and the chain ID.

Update getauxblock.py for new 'generate' RPC call.

Add 'auxpow' to block JSON.

Accept auxpow as PoW verification.

Add unit tests for auxpow verification.

Add check for memory-layout of CBlockVersion.

Weaken auxpow chain ID checks for the testnet.

Allow Params() to overrule when to check the auxpow chain ID and for legacy blocks.  Use this to disable the checks on testnet.

Introduce CPureBlockHeader.

Split the block header part that is used by auxpow and the "real" block header (that uses auxpow) to resolve the cyclic dependency between the two.

Differentiate between uint256 and arith_uint256.

This change was done upstream, modify the auxpow code.

Add missing lock in auxpow_tests.

Fix REST header check for auxpow headers.

Those can be longer, thus take that into account.  Also perform the check actually on an auxpow header.

Correctly set the coinbase for getauxblock results.

Call IncrementExtraNonce in getauxblock so that the coinbase is actually initialised with the stuff it should be.  (BIP30 block height and COINBASE_FLAGS.)

Implement getauxblock plus regression test.

Turn auxpow test into FIXTURE test.

This allows using of the Params() calls.

Move CMerkleTx code to auxpow.cpp.

Otherwise we get linker errors when building without wallet.

Fix rebase with BIP66.

Update the code to handle BIP66's nVersion=3.

Enforce that auxpow parent blocks have no auxpow block version.

This is for compatibility with namecoind.  See also https://github.com/namecoin/namecoin/pull/199.

Move auxpow-related parameters to Consensus::Params.
2018-09-19 19:22:45 +01:00
Luke Dashjr e05799a381 Merge #10234, #10143 (fixes only), and #9853 via branch 'disconnect_ban_fixes-0.14' into 0.14.2_fixes 2017-06-05 22:57:27 +00:00
John Newbery ee1a60d156 [tests] update disconnect_ban.py test case to work with listbanned
Github-Pull: #10234
Rebased-From: d6732d832a
2017-06-05 22:56:22 +00:00
John Newbery 04226938a3 [tests] disconnect_ban: remove dependency on urllib
Github-Pull: #10143
Rebased-From: 5cc3ee24d2
2017-06-05 22:56:04 +00:00
John Newbery 98bd0c338b [tests] disconnect_ban: use wait_until instead of sleep
Github-Pull: #10143
Rebased-From: 12de2f252c
2017-06-05 22:55:10 +00:00
Luke Dashjr 99e5dbd0aa Merge #9853 via branch 'fixerrorcodes-0.14' into 0.14.2_fixes 2017-06-05 19:33:18 +00:00
Luke Dashjr 74653a41fe Merge #10196 via branch 'prioritisetx_gbtcache-0.14' into 0.14.2_fixes 2017-06-05 19:33:01 +00:00
John Newbery bfd1cf6713 [tests] disconnectban test - only use two nodes
Github-Pull: #10143
Rebased-From: 395561becf
2017-06-05 19:26:13 +00:00
John Newbery 5bc75bb8ee [tests] fix nodehandling.py flake8 warnings
Github-Pull: #10143
Rebased-From: d6564a26f4
2017-06-05 19:26:13 +00:00
John Newbery f5efe82a83 Return correct error codes in fundrawtransaction().
The fundrawtransaction() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when funding the transaction
failed). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

That error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: dab804c18a
2017-06-05 19:01:16 +00:00
John Newbery 4943d7a9fe Return correct error codes in setban().
The setban() RPC was returning misleading or incorrect error
codes (for example RPC_CLIENT_NODE_ALREADY_ADDED when an invalid IP
address was entered). This commit fixes those error codes:

- RPC_CLIENT_INVALID_IP_OR_SUBNET should be returned if the client
  enters an invalid IP address or subnet.

This commit also updates the test cases to explicitly test the error code.

This commit also adds a testcase for trying to setban on an invalid subnet.

Github-Pull: #9853
Rebased-From: a012087667
2017-06-05 19:01:16 +00:00
John Newbery 18c109ddb1 Return correct error codes in removeprunedfunds().
The removeprunedfunds() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when the transaction was
not found in the wallet). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

This error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 960bc7f778
2017-06-05 19:01:16 +00:00
John Newbery fe51c8924e Return correct error codes in blockchain.cpp.
RPCs in blockchain.cpp were returning misleading or incorrect error
codes (for example getblock() returning RPC_INTERNAL_ERROR when the
block had been pruned). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
  errors, only for genuine internal errors such as corrupted data.
- RPC_METHOD_NOT_FOUND should not be returned in response to a
  JSON request for an existing method.

Those error codes have been replaced with RPC_MISC_ERROR or
RPC_INVALID_PARAMETER as appropriate.

Github-Pull: #9853
Rebased-From: c1190963b3
2017-06-05 19:01:16 +00:00
John Newbery 3ad00b4b32 Return correct error codes in bumpfee().
The bumpfee() RPC was returning misleading or incorrect error codes
(for example RPC_INVALID_ADDRESS_OR_KEY when the transaction was not
BIP125 replacable). This commit fixes those error codes:

- RPC_INVALID_ADDRESS_OR_KEY if an invalid address was provided:
    - Invalid change address given
- RPC_INVALID_PARAMETER if a single (non-address/key) parameter is incorrect
    - confTarget and totalFee options should not both be set.
    - Invalid confTarget
    - Insufficient totalFee (cannot be less than required fee)
- RPC_WALLET_ERROR for any other error
    - Transaction has descendants in the wallet
    - Transaction has descendants in the mempool
    - Transaction has been mined, or is conflicted with a mined transaction
    - Transaction is not BIP 125 replaceable
    - Transaction has already been bumped
    - Transaction contains inputs that don't belong to the wallet
    - Transaction has multiple change outputs
    - Transaction does not have a change output
    - Fee is higher than maxTxFee
    - New fee rate is less than the minimum fee rate
    - Change output is too small.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 6d07c62322
2017-06-05 19:01:16 +00:00
Gregory Sanders 18476423fb
[Wallet] unset change position when there is no change on exact match 2017-05-31 10:57:16 +02:00
Suhas Daftuar 71463a7d18 [qa] Test prioritise_transaction / getblocktemplate interaction
Github-Pull: #10196
Rebased-From: 6a61424c9eed072ae8d79d68aac71f525c1608b5
2017-04-21 12:38:23 +00:00
Suhas Daftuar 39febb8c6d [qa] Fix mempool_packages.py for the 0.14 branch
The backport in d947afc0f7 of this
test was incorrect due to an api change in prioritisetransaction.
2017-04-05 08:30:51 -04:00
Suhas Daftuar d947afc0f7
Test prioritisetransaction and ancestor fee state
There is already a similar test for descendant fee state.

Github-Pull: #10144
Rebased-From: ba7dd8bf6f
2017-04-05 08:37:12 +02:00
Suhas Daftuar 2cd2cd51f7 Test transaction selection when gbt called without segwit support
Github-Pull: #9955
Rebased-From: c85ffe6d8d
2017-03-16 10:50:16 -04:00
Suhas Daftuar 569596cc51 Don't require segwit in getblocktemplate for segwit signalling or mining
Segwit's version bit will be signalled for all invocations of CreateNewBlock,
and not specifying segwit only will cause CreateNewBlock to skip transactions
with witness from being selected.

Github-Pull: #9955
Rebased-From: abe7b3d3ab
2017-03-16 10:43:54 -04:00
Russell Yanofsky eddaa6b35d
[qa] Make import-rescan.py watchonly check reliable
Send payments during the test from a different node than the node generating
keys to be imported, so the spending node doesn't create transactions that
inadvertently involve (spend funds from) the imported keys.

Fixes #9826

Github-Pull: #9839
Rebased-From: 864890adf5
2017-02-27 09:03:57 +01:00
MarcoFalke 260c71cbb8
qa: Check return code when stopping nodes
This includes work by jnewbery

Github-Pull: #9824
Rebased-From: fa4cd2e998
2017-02-23 10:40:55 +01:00
Russell Yanofsky 599c69abe3
Fix pruning test broken by 2 hour manual prune window
Regression happened in 91fb506 Add two hour buffer to manual pruning.

Github-Pull: #9820
Rebased-From: 874c7363d7
2017-02-23 10:39:20 +01:00
Luke Dashjr 861cb0c83d
QA: Test GBT size/weight limit values
Github-Pull: #9619
Rebased-From: 279f944e8d
2017-02-20 17:32:59 +01:00
Russell Yanofsky e662af3583 Use 2 hour grace period for key timestamps in importmulti rescans
Gregory Maxwell <greg@xiph.org> pointed out the lack of grace period in
https://github.com/bitcoin/bitcoin/pull/9490#issue-199407998.

The importwallet RPC which uses key timestamps in a similar way already has a 2
hour grace period.
2017-02-16 09:05:55 -05:00
Russell Yanofsky 38d3e9ee59 [qa] Extend import-rescan.py to test imports on pruned nodes. 2017-02-16 09:05:55 -05:00
Russell Yanofsky c28583d062 [qa] Extend import-rescan.py to test specific key timestamps 2017-02-16 09:05:55 -05:00
Russell Yanofsky 8be0866883 [qa] Simplify import-rescan.py
Get rid of partial functions so the test can be more easily extended to add
more variants of imports with options that affect rescanning (e.g. different
key timestamps).

Also change the second half of the test to send /to/ the imported addresses,
instead of /from/ the imported addresses. The goal of this part of the test was
to confirm that the wallet would pick up new transactions after an import
regardless of whether or not a rescan happened during the import. But because
the wallet can only do this reliably for incoming transactions and not outgoing
transactions (which require the wallet to look up transaction inputs) the test
previously was less meaningful than it should have been.
2017-02-16 09:05:55 -05:00
Wladimir J. van der Laan 1e92e041dd
Merge #9765: Harden against mistakes handling invalid blocks
ba803ef Harden against mistakes handling invalid blocks (Suhas Daftuar)
2017-02-16 10:23:41 +01:00
Wladimir J. van der Laan 7a93af8340
Merge #9756: Return error when importmulti called with invalid address.
9acf25c Return error when importmulti called with invalid address. (Russell Yanofsky)
2017-02-15 16:29:16 +01:00
Suhas Daftuar ba803efb68 Harden against mistakes handling invalid blocks
Fixes a bug in AcceptBlock() in invoking CheckBlock() with incorrect
arguments, and restores a call to CheckBlock() from ProcessNewBlock()
as belt-and-suspenders.

Updates the (overspecified) tests to match behavior.
2017-02-15 08:17:57 -05:00
Wladimir J. van der Laan d8e8b06bd0
Merge #9108: Use importmulti timestamp when importing watch only keys (on top of #9682)
a80f98b Use importmulti timestamp when importing watch only keys (Russell Yanofsky)
a58370e Dedup nTimeFirstKey update logic (Russell Yanofsky)
2017-02-15 11:13:48 +01:00
Wladimir J. van der Laan e87ce95fbd
Merge #9720: net: fix banning and disallow sending messages before receiving verack
d943491 qa: add a test to detect leaky p2p messages (Cory Fields)
8650bbb qa: Expose on-connection to mininode listeners (Matt Corallo)
5b5e4f8 qa: mininode learns when a socket connects, not its first action (Matt Corallo)
cbfc5a6 net: require a verack before responding to anything else (Cory Fields)
8502e7a net: parse reject earlier (Cory Fields)
c45b9fb net: correctly ban before the handshake is complete (Cory Fields)
2017-02-14 14:42:29 +01:00
Wladimir J. van der Laan b08656e343
Merge #9715: Disconnect peers which we do not receive VERACKs from within 60 sec
66f861a Add a test for P2P inactivity timeouts (Matt Corallo)
b436f92 qa: Expose on-connection to mininode listeners (Matt Corallo)
8aaba7a qa: mininode learns when a socket connects, not its first action (Matt Corallo)
2cbd119 Disconnect peers which we do not receive VERACKs from within 60 sec (Matt Corallo)
2017-02-14 14:35:15 +01:00
Wladimir J. van der Laan edc9e63c57
Merge #9682: Require timestamps for importmulti keys
266a811 Use MTP for importmulti "now" timestamps (Russell Yanofsky)
3cf9917 Add test to check new importmulti "now" value (Russell Yanofsky)
442887f Require timestamps for importmulti keys (Russell Yanofsky)
2017-02-14 14:32:22 +01:00
Cory Fields d9434918d2 qa: add a test to detect leaky p2p messages
This is certainly not exhaustive, but it's better than nothing. Adds checks
for:

- Any message received before sending a version
- Any message received other than version/reject before sending a verack

It also tries to goad the remote into sending a pong, address, or block
announcement.
2017-02-13 18:56:03 -05:00
Matt Corallo 8650bbb660 qa: Expose on-connection to mininode listeners 2017-02-13 18:56:03 -05:00
Matt Corallo 5b5e4f8330 qa: mininode learns when a socket connects, not its first action 2017-02-13 18:56:03 -05:00
Russell Yanofsky 9acf25cc01 Return error when importmulti called with invalid address.
Lack of error checking noticed by Alex Morcos <morcos@chaincode.com>
2017-02-13 17:54:51 -05:00
Russell Yanofsky a80f98b1c7 Use importmulti timestamp when importing watch only keys
When importing a watch-only address over importmulti with a specific timestamp,
the wallet's nTimeFirstKey is currently set to 1. After this change, the
provided timestamp will be used and stored as metadata associated with
watch-only key. This can improve wallet performance because it can avoid the
need to scan the entire blockchain for watch only addresses when timestamps are
provided.

Also adds timestamp to validateaddress return value (needed for tests).

Fixes #9034.
2017-02-10 16:11:19 -05:00
Russell Yanofsky 266a8114cb Use MTP for importmulti "now" timestamps 2017-02-10 15:40:28 -05:00
Russell Yanofsky 3cf991756c Add test to check new importmulti "now" value
Easiest way to test this was to expose the timestamp via the validateaddress
RPC (which was already looking up and returning key metadata).
2017-02-10 15:40:28 -05:00
Russell Yanofsky 442887f27f Require timestamps for importmulti keys
Additionally, accept a "now" timestamp, to allow avoiding rescans for keys
which are known never to have been used.

Note that the behavior when "now" is specified is slightly different than the
previous behavior when no timestamp was specified at all. Previously, when no
timestamp was specified, it would avoid rescanning during the importmulti call,
but set the key's nCreateTime value to 1, which would not prevent future block
reads in later ScanForWalletTransactions calls. With this change, passing a
"now" timestamp will set the key's nCreateTime to the current block time
instead of 1.

Fixes #9491
2017-02-10 15:40:28 -05:00
MarcoFalke b860915f8b
Merge #9707: Fix RPC failure testing
9db8eec Fix RPC failure testing (John Newbery)
2017-02-10 18:02:56 +01:00
Matt Corallo 66f861ade9 Add a test for P2P inactivity timeouts 2017-02-09 17:34:03 -05:00
Matt Corallo b436f92f72 qa: Expose on-connection to mininode listeners 2017-02-08 12:05:13 -05:00