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
This commit is contained in:
parent
55dc231005
commit
0543f8d2e2
|
@ -47,6 +47,7 @@ before_script:
|
|||
- unset CC; unset CXX
|
||||
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-doc.py; fi
|
||||
- mkdir -p depends/SDKs depends/sdk-sources
|
||||
- if [ "$RUN_TESTS" = "true" ]; then qa/pull-tester/install-deps.sh; fi
|
||||
- if [ -n "$OSX_SDK" -a ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
|
||||
- if [ -n "$OSX_SDK" -a -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
|
||||
- make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS
|
||||
|
|
|
@ -18,11 +18,11 @@ import random
|
|||
from binascii import b2a_hex
|
||||
|
||||
# key types
|
||||
PUBKEY_ADDRESS = 0
|
||||
PUBKEY_ADDRESS = 30
|
||||
SCRIPT_ADDRESS = 5
|
||||
PUBKEY_ADDRESS_TEST = 111
|
||||
SCRIPT_ADDRESS_TEST = 196
|
||||
PRIVKEY = 128
|
||||
PRIVKEY = 158
|
||||
PRIVKEY_TEST = 239
|
||||
|
||||
metadata_keys = ['isPrivkey', 'isTestnet', 'addrType', 'isCompressed']
|
||||
|
|
|
@ -11,15 +11,17 @@ Before running the tests, the following must be installed.
|
|||
|
||||
Unix
|
||||
----
|
||||
The python3-zmq library is required. On Ubuntu or Debian it can be installed via:
|
||||
`python3-zmq` and `litecoin_scrypt` are required. On Ubuntu or Debian they can be installed via:
|
||||
```
|
||||
sudo apt-get install python3-zmq
|
||||
pip3 install litecoin_scrypt
|
||||
```
|
||||
|
||||
OS X
|
||||
------
|
||||
```
|
||||
pip3 install pyzmq
|
||||
pip3 install litecoin_scrypt
|
||||
```
|
||||
|
||||
Running tests
|
||||
|
|
10
qa/pull-tester/install-deps.sh
Executable file
10
qa/pull-tester/install-deps.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# installs test dependencies
|
||||
|
||||
wget https://github.com/langerhans/ltc-scrypt/archive/master.tar.gz
|
||||
echo "ade3cdf498927990b6d153d74f0da104114e838584be5a81bef8972accd03341 master.tar.gz" | sha256sum -c
|
||||
tar zxf master.tar.gz
|
||||
pushd ltc-scrypt-master
|
||||
python3 setup.py install --user
|
||||
popd
|
|
@ -103,30 +103,32 @@ testScripts = [
|
|||
'wallet-hd.py',
|
||||
'walletbackup.py',
|
||||
# vv Tests less than 5m vv
|
||||
'p2p-fullblocktest.py',
|
||||
# 'p2p-fullblocktest.py',
|
||||
'fundrawtransaction.py',
|
||||
'p2p-compactblocks.py',
|
||||
'segwit.py',
|
||||
#'p2p-compactblocks.py',
|
||||
# 'segwit.py',
|
||||
# vv Tests less than 2m vv
|
||||
'auxpow.py',
|
||||
'getauxblock.py',
|
||||
'wallet.py',
|
||||
'wallet-accounts.py',
|
||||
'p2p-segwit.py',
|
||||
# 'p2p-segwit.py',
|
||||
'wallet-dump.py',
|
||||
'listtransactions.py',
|
||||
# vv Tests less than 60s vv
|
||||
'sendheaders.py',
|
||||
# 'sendheaders.py',
|
||||
'zapwallettxes.py',
|
||||
'importmulti.py',
|
||||
'mempool_limit.py',
|
||||
'merkle_blocks.py',
|
||||
'receivedby.py',
|
||||
'abandonconflict.py',
|
||||
'bip68-112-113-p2p.py',
|
||||
# 'bip68-112-113-p2p.py',
|
||||
'rawtransactions.py',
|
||||
'reindex.py',
|
||||
# vv Tests less than 30s vv
|
||||
'mempool_resurrect_test.py',
|
||||
'txn_doublespend.py --mineblock',
|
||||
#'txn_doublespend.py --mineblock',
|
||||
'txn_clone.py',
|
||||
'getchaintips.py',
|
||||
'rest.py',
|
||||
|
@ -143,15 +145,17 @@ testScripts = [
|
|||
'keypool.py',
|
||||
'p2p-mempool.py',
|
||||
'prioritise_transaction.py',
|
||||
'invalidblockrequest.py',
|
||||
'invalidtxrequest.py',
|
||||
'p2p-versionbits-warning.py',
|
||||
# 'invalidblockrequest.py',
|
||||
# 'invalidtxrequest.py',
|
||||
# 'p2p-versionbits-warning.py',
|
||||
'preciousblock.py',
|
||||
'importprunedfunds.py',
|
||||
'signmessages.py',
|
||||
'nulldummy.py',
|
||||
# 'nulldummy.py',
|
||||
'import-rescan.py',
|
||||
'bumpfee.py',
|
||||
# While fee bumping should work in Doge, these tests depend on free transactions, which we don't support.
|
||||
# Disable until we can do a full rewrite of the tests (possibly upstream), or revise fee schedule, or something
|
||||
# 'bumpfee.py',
|
||||
'rpcnamedargs.py',
|
||||
'listsinceblock.py',
|
||||
'p2p-leaktests.py',
|
||||
|
@ -167,17 +171,17 @@ testScriptsExt = [
|
|||
'maxuploadtarget.py',
|
||||
'mempool_packages.py',
|
||||
# vv Tests less than 2m vv
|
||||
'bip68-sequence.py',
|
||||
# 'bip68-sequence.py',
|
||||
'getblocktemplate_longpoll.py',
|
||||
'p2p-timeouts.py',
|
||||
# vv Tests less than 60s vv
|
||||
'bip9-softforks.py',
|
||||
# 'bip9-softforks.py',
|
||||
'p2p-feefilter.py',
|
||||
'rpcbind_test.py',
|
||||
# vv Tests less than 30s vv
|
||||
'bip65-cltv.py',
|
||||
'bip65-cltv-p2p.py',
|
||||
'bipdersig-p2p.py',
|
||||
# 'bip65-cltv-p2p.py',
|
||||
# 'bipdersig-p2p.py',
|
||||
'bipdersig.py',
|
||||
'getblocktemplate_proposals.py',
|
||||
'txn_doublespend.py',
|
||||
|
@ -277,7 +281,7 @@ class RPCTestHandler:
|
|||
log_stderr = tempfile.SpooledTemporaryFile(max_size=2**16)
|
||||
self.jobs.append((t,
|
||||
time.time(),
|
||||
subprocess.Popen((RPC_TESTS_DIR + t).split() + self.flags + port_seed,
|
||||
subprocess.Popen(['python3.6']+(RPC_TESTS_DIR + t).split() + self.flags + port_seed,
|
||||
universal_newlines=True,
|
||||
stdout=log_stdout,
|
||||
stderr=log_stderr),
|
||||
|
|
|
@ -16,7 +16,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|||
|
||||
def setup_network(self):
|
||||
self.nodes = []
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.00001"]))
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=1"]))
|
||||
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-logtimemicros"]))
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
|
||||
|
@ -32,7 +32,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|||
|
||||
sync_blocks(self.nodes)
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
assert(balance - newbalance < Decimal("0.001")) #no more than fees lost
|
||||
assert(balance - newbalance <= Decimal("3")) #no more than fees lost
|
||||
balance = newbalance
|
||||
|
||||
url = urllib.parse.urlparse(self.nodes[1].url)
|
||||
|
@ -49,33 +49,33 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|||
inputs.append({"txid":txB, "vout":nB})
|
||||
outputs = {}
|
||||
|
||||
outputs[self.nodes[0].getnewaddress()] = Decimal("14.99998")
|
||||
outputs[self.nodes[0].getnewaddress()] = Decimal("14")
|
||||
outputs[self.nodes[1].getnewaddress()] = Decimal("5")
|
||||
signed = self.nodes[0].signrawtransaction(self.nodes[0].createrawtransaction(inputs, outputs))
|
||||
txAB1 = self.nodes[0].sendrawtransaction(signed["hex"])
|
||||
|
||||
# Identify the 14.99998btc output
|
||||
nAB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txAB1, 1)["vout"]) if vout["value"] == Decimal("14.99998"))
|
||||
nAB = next(i for i, vout in enumerate(self.nodes[0].getrawtransaction(txAB1, 1)["vout"]) if vout["value"] == Decimal("14"))
|
||||
|
||||
#Create a child tx spending AB1 and C
|
||||
inputs = []
|
||||
inputs.append({"txid":txAB1, "vout":nAB})
|
||||
inputs.append({"txid":txC, "vout":nC})
|
||||
outputs = {}
|
||||
outputs[self.nodes[0].getnewaddress()] = Decimal("24.9996")
|
||||
outputs[self.nodes[0].getnewaddress()] = Decimal("23")
|
||||
signed2 = self.nodes[0].signrawtransaction(self.nodes[0].createrawtransaction(inputs, outputs))
|
||||
txABC2 = self.nodes[0].sendrawtransaction(signed2["hex"])
|
||||
|
||||
# In mempool txs from self should increase balance from change
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
assert_equal(newbalance, balance - Decimal("30") + Decimal("24.9996"))
|
||||
assert_equal(newbalance, balance - Decimal("30") + Decimal("23"))
|
||||
balance = newbalance
|
||||
|
||||
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool
|
||||
# TODO: redo with eviction
|
||||
# Note had to make sure tx did not have AllowFree priority
|
||||
stop_node(self.nodes[0],0)
|
||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.0001"])
|
||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=5"])
|
||||
|
||||
# Verify txs no longer in mempool
|
||||
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
||||
|
@ -83,7 +83,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|||
# Not in mempool txs from self should only reduce balance
|
||||
# inputs are still spent, but change not received
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
assert_equal(newbalance, balance - Decimal("24.9996"))
|
||||
assert_equal(newbalance, balance - Decimal("23"))
|
||||
# Unconfirmed received funds that are not in mempool, also shouldn't show
|
||||
# up in unconfirmed balance
|
||||
unconfbalance = self.nodes[0].getunconfirmedbalance() + self.nodes[0].getbalance()
|
||||
|
@ -101,7 +101,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|||
|
||||
# Verify that even with a low min relay fee, the tx is not reaccepted from wallet on startup once abandoned
|
||||
stop_node(self.nodes[0],0)
|
||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.00001"])
|
||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=1"])
|
||||
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
||||
assert_equal(self.nodes[0].getbalance(), balance)
|
||||
|
||||
|
@ -110,21 +110,21 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|||
# But its child tx remains abandoned
|
||||
self.nodes[0].sendrawtransaction(signed["hex"])
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
assert_equal(newbalance, balance - Decimal("20") + Decimal("14.99998"))
|
||||
assert_equal(newbalance, balance - Decimal("20") + Decimal("14"))
|
||||
balance = newbalance
|
||||
|
||||
# Send child tx again so its unabandoned
|
||||
self.nodes[0].sendrawtransaction(signed2["hex"])
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
assert_equal(newbalance, balance - Decimal("10") - Decimal("14.99998") + Decimal("24.9996"))
|
||||
assert_equal(newbalance, balance - Decimal("10") - Decimal("14") + Decimal("23"))
|
||||
balance = newbalance
|
||||
|
||||
# Remove using high relay fee again
|
||||
stop_node(self.nodes[0],0)
|
||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=0.0001"])
|
||||
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-logtimemicros","-minrelaytxfee=5"])
|
||||
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
assert_equal(newbalance, balance - Decimal("24.9996"))
|
||||
assert_equal(newbalance, balance - Decimal("23"))
|
||||
balance = newbalance
|
||||
|
||||
# Create a double spend of AB1 by spending again from only A's 10 output
|
||||
|
@ -132,7 +132,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
|||
inputs =[]
|
||||
inputs.append({"txid":txA, "vout":nA})
|
||||
outputs = {}
|
||||
outputs[self.nodes[1].getnewaddress()] = Decimal("9.9999")
|
||||
outputs[self.nodes[1].getnewaddress()] = Decimal("9")
|
||||
tx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
signed = self.nodes[0].signrawtransaction(tx)
|
||||
self.nodes[1].sendrawtransaction(signed["hex"])
|
||||
|
|
88
qa/rpc-tests/auxpow.py
Executable file
88
qa/rpc-tests/auxpow.py
Executable file
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015-2018 The Dogecoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#
|
||||
# Test AuxPOW RPC interface and constraints
|
||||
#
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
from test_framework import scrypt_auxpow
|
||||
|
||||
class AuxPOWTest (BitcoinTestFramework):
|
||||
REWARD = 500000 # reward per block
|
||||
CHAIN_ID = "62"
|
||||
DIGISHIELD_START = 10 # nHeight when digishield starts
|
||||
AUXPOW_START = 20 # nHeight when auxpow starts
|
||||
MATURITY_HEIGHT = 60 # number of blocks for mined transactions to mature
|
||||
|
||||
def setup_chain(self):
|
||||
print("Initializing test directory " + self.options.tmpdir)
|
||||
initialize_chain_clean(self.options.tmpdir, 2)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(2, self.options.tmpdir)
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
self.is_network_split=False
|
||||
self.sync_all()
|
||||
|
||||
def run_test(self):
|
||||
print("Mining blocks...")
|
||||
|
||||
# 1. mine an auxpow block before auxpow is allowed, expect: fail
|
||||
try:
|
||||
scrypt_auxpow.mineScryptAux(self.nodes[0], "00", True)
|
||||
except JSONRPCException as ex:
|
||||
if ex.error['message'] == "getauxblock method is not yet available":
|
||||
pass
|
||||
else:
|
||||
raise ex
|
||||
self.sync_all()
|
||||
|
||||
# 2. mine a non-auxpow block, just to ensure that this node
|
||||
# can mine at all, expect: success
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# 3. mine blocks until we're in digishield era
|
||||
self.nodes[1].generate(self.DIGISHIELD_START - 1 - 1)
|
||||
self.sync_all()
|
||||
|
||||
# 4. mine an auxpow block before auxpow is allowed, attempt 2
|
||||
# expect: fail
|
||||
try:
|
||||
scrypt_auxpow.mineScryptAux(self.nodes[0], "00", True)
|
||||
except JSONRPCException as ex:
|
||||
if ex.error['message'] == "getauxblock method is not yet available":
|
||||
pass
|
||||
else:
|
||||
raise ex
|
||||
self.sync_all()
|
||||
|
||||
# 5. mine blocks until we're in in auxpow era
|
||||
self.nodes[1].generate(self.AUXPOW_START - self.DIGISHIELD_START)
|
||||
self.sync_all()
|
||||
|
||||
# 6. mine a valid auxpow block, expect: success
|
||||
assert scrypt_auxpow.mineScryptAux(self.nodes[0], "00", True) is True
|
||||
|
||||
# 7. mine an auxpow block with high pow, expect: fail
|
||||
assert scrypt_auxpow.mineScryptAux(self.nodes[0], "00", False) is False
|
||||
|
||||
# 8. mine a valid auxpow block with the parent chain being us
|
||||
# expect: fail
|
||||
assert scrypt_auxpow.mineScryptAux(self.nodes[0], self.CHAIN_ID, True) is False
|
||||
self.sync_all()
|
||||
|
||||
# 9. mine enough blocks to mature all node 0 rewards
|
||||
self.nodes[1].generate(self.MATURITY_HEIGHT)
|
||||
self.sync_all()
|
||||
|
||||
# node 0 should have block rewards for 2 blocks,
|
||||
# One from step 2 and one from step 6.
|
||||
assert_equal(self.nodes[0].getbalance(), self.REWARD * 2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
AuxPOWTest ().main ()
|
|
@ -19,8 +19,8 @@ class BIP66Test(BitcoinTestFramework):
|
|||
def setup_network(self):
|
||||
self.nodes = []
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, []))
|
||||
self.nodes.append(start_node(1, self.options.tmpdir, ["-blockversion=2"]))
|
||||
self.nodes.append(start_node(2, self.options.tmpdir, ["-blockversion=3"]))
|
||||
self.nodes.append(start_node(1, self.options.tmpdir, ["-blockversion=3"]))
|
||||
self.nodes.append(start_node(2, self.options.tmpdir, ["-blockversion=4"]))
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
connect_nodes(self.nodes[2], 0)
|
||||
self.is_network_split = False
|
||||
|
|
|
@ -51,11 +51,11 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
node = self.nodes[0]
|
||||
res = node.gettxoutsetinfo()
|
||||
|
||||
assert_equal(res['total_amount'], Decimal('8725.00000000'))
|
||||
assert_equal(res['transactions'], 200)
|
||||
assert_equal(res['height'], 200)
|
||||
assert_equal(res['txouts'], 200)
|
||||
assert_equal(res['bytes_serialized'], 13924),
|
||||
assert_equal(res['total_amount'], Decimal('60000000.00000000'))
|
||||
assert_equal(res['transactions'], 120)
|
||||
assert_equal(res['height'], 120)
|
||||
assert_equal(res['txouts'], 120)
|
||||
assert_equal(res['bytes_serialized'], 8520),
|
||||
assert_equal(len(res['bestblock']), 64)
|
||||
assert_equal(len(res['hash_serialized']), 64)
|
||||
|
||||
|
@ -66,11 +66,11 @@ class BlockchainTest(BitcoinTestFramework):
|
|||
JSONRPCException, lambda: node.getblockheader('nonsense'))
|
||||
|
||||
besthash = node.getbestblockhash()
|
||||
secondbesthash = node.getblockhash(199)
|
||||
secondbesthash = node.getblockhash(119)
|
||||
header = node.getblockheader(besthash)
|
||||
|
||||
assert_equal(header['hash'], besthash)
|
||||
assert_equal(header['height'], 200)
|
||||
assert_equal(header['height'], 120)
|
||||
assert_equal(header['confirmations'], 1)
|
||||
assert_equal(header['previousblockhash'], secondbesthash)
|
||||
assert_is_hex_string(header['chainwork'])
|
||||
|
|
|
@ -47,14 +47,14 @@ class BumpFeeTest(BitcoinTestFramework):
|
|||
|
||||
# fund rbf node with 10 coins of 0.001 btc (100,000 satoshis)
|
||||
print("Mining blocks...")
|
||||
peer_node.generate(110)
|
||||
peer_node.generate(70)
|
||||
self.sync_all()
|
||||
for i in range(25):
|
||||
peer_node.sendtoaddress(rbf_node_address, 0.001)
|
||||
peer_node.sendtoaddress(rbf_node_address, 1.0000)
|
||||
self.sync_all()
|
||||
peer_node.generate(1)
|
||||
self.sync_all()
|
||||
assert_equal(rbf_node.getbalance(), Decimal("0.025"))
|
||||
assert_equal(rbf_node.getbalance(), Decimal("25"))
|
||||
|
||||
print("Running tests")
|
||||
dest_address = peer_node.getnewaddress()
|
||||
|
@ -75,7 +75,7 @@ class BumpFeeTest(BitcoinTestFramework):
|
|||
|
||||
|
||||
def test_simple_bumpfee_succeeds(rbf_node, peer_node, dest_address):
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000})
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.90000000})
|
||||
rbftx = rbf_node.gettransaction(rbfid)
|
||||
sync_mempools((rbf_node, peer_node))
|
||||
assert rbfid in rbf_node.getrawmempool() and rbfid in peer_node.getrawmempool()
|
||||
|
@ -128,7 +128,7 @@ def test_segwit_bumpfee_succeeds(rbf_node, dest_address):
|
|||
|
||||
def test_nonrbf_bumpfee_fails(peer_node, dest_address):
|
||||
# cannot replace a non RBF transaction (from node which did not enable RBF)
|
||||
not_rbfid = create_fund_sign_send(peer_node, {dest_address: 0.00090000})
|
||||
not_rbfid = create_fund_sign_send(peer_node, {dest_address: 0.90000000})
|
||||
assert_raises_message(JSONRPCException, "not BIP 125 replaceable", peer_node.bumpfee, not_rbfid)
|
||||
|
||||
|
||||
|
@ -166,27 +166,27 @@ def test_bumpfee_with_descendant_fails(rbf_node, rbf_node_address, dest_address)
|
|||
def test_small_output_fails(rbf_node, dest_address):
|
||||
# cannot bump fee with a too-small output
|
||||
rbfid = spend_one_input(rbf_node,
|
||||
Decimal("0.00100000"),
|
||||
{dest_address: 0.00080000,
|
||||
get_change_address(rbf_node): Decimal("0.00010000")})
|
||||
rbf_node.bumpfee(rbfid, {"totalFee": 20000})
|
||||
Decimal("1.00000000"),
|
||||
{dest_address: 0.80000000,
|
||||
get_change_address(rbf_node): Decimal("0.10000000")})
|
||||
rbf_node.bumpfee(rbfid, {"totalFee": 200000000})
|
||||
|
||||
rbfid = spend_one_input(rbf_node,
|
||||
Decimal("0.00100000"),
|
||||
{dest_address: 0.00080000,
|
||||
get_change_address(rbf_node): Decimal("0.00010000")})
|
||||
assert_raises_message(JSONRPCException, "Change output is too small", rbf_node.bumpfee, rbfid, {"totalFee": 20001})
|
||||
Decimal("1.00000000"),
|
||||
{dest_address: 0.80000000,
|
||||
get_change_address(rbf_node): Decimal("1.00000000")})
|
||||
assert_raises_message(JSONRPCException, "Change output is too small", rbf_node.bumpfee, rbfid, {"totalFee": 200000001})
|
||||
|
||||
|
||||
def test_dust_to_fee(rbf_node, dest_address):
|
||||
# check that if output is reduced to dust, it will be converted to fee
|
||||
# the bumped tx sets fee=9900, but it converts to 10,000
|
||||
rbfid = spend_one_input(rbf_node,
|
||||
Decimal("0.00100000"),
|
||||
{dest_address: 0.00080000,
|
||||
get_change_address(rbf_node): Decimal("0.00010000")})
|
||||
Decimal("1.00000000"),
|
||||
{dest_address: 0.80000000,
|
||||
get_change_address(rbf_node): Decimal("0.10000000")})
|
||||
fulltx = rbf_node.getrawtransaction(rbfid, 1)
|
||||
bumped_tx = rbf_node.bumpfee(rbfid, {"totalFee": 19900})
|
||||
bumped_tx = rbf_node.bumpfee(rbfid, {"totalFee": 19900000})
|
||||
full_bumped_tx = rbf_node.getrawtransaction(bumped_tx["txid"], 1)
|
||||
assert_equal(bumped_tx["fee"], Decimal("0.00020000"))
|
||||
assert_equal(len(fulltx["vout"]), 2)
|
||||
|
@ -196,8 +196,8 @@ def test_dust_to_fee(rbf_node, dest_address):
|
|||
def test_settxfee(rbf_node, dest_address):
|
||||
# check that bumpfee reacts correctly to the use of settxfee (paytxfee)
|
||||
# increase feerate by 2.5x, test that fee increased at least 2x
|
||||
rbf_node.settxfee(Decimal("0.00001000"))
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000})
|
||||
rbf_node.settxfee(Decimal("0.01000000"))
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.90000000})
|
||||
rbftx = rbf_node.gettransaction(rbfid)
|
||||
rbf_node.settxfee(Decimal("0.00002500"))
|
||||
bumped_tx = rbf_node.bumpfee(rbfid)
|
||||
|
@ -207,24 +207,24 @@ def test_settxfee(rbf_node, dest_address):
|
|||
|
||||
def test_rebumping(rbf_node, dest_address):
|
||||
# check that re-bumping the original tx fails, but bumping the bumper succeeds
|
||||
rbf_node.settxfee(Decimal("0.00001000"))
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000})
|
||||
bumped = rbf_node.bumpfee(rbfid, {"totalFee": 1000})
|
||||
rbf_node.settxfee(Decimal("0.01000000"))
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.90000000})
|
||||
bumped = rbf_node.bumpfee(rbfid, {"totalFee": 1000000})
|
||||
assert_raises_message(JSONRPCException, "already bumped", rbf_node.bumpfee, rbfid, {"totalFee": 2000})
|
||||
rbf_node.bumpfee(bumped["txid"], {"totalFee": 2000})
|
||||
rbf_node.bumpfee(bumped["txid"], {"totalFee": 2000000})
|
||||
|
||||
|
||||
def test_rebumping_not_replaceable(rbf_node, dest_address):
|
||||
# check that re-bumping a non-replaceable bump tx fails
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000})
|
||||
bumped = rbf_node.bumpfee(rbfid, {"totalFee": 10000, "replaceable": False})
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.90000000})
|
||||
bumped = rbf_node.bumpfee(rbfid, {"totalFee": 10000000, "replaceable": False})
|
||||
assert_raises_message(JSONRPCException, "Transaction is not BIP 125 replaceable", rbf_node.bumpfee, bumped["txid"],
|
||||
{"totalFee": 20000})
|
||||
{"totalFee": 20000000})
|
||||
|
||||
|
||||
def test_unconfirmed_not_spendable(rbf_node, rbf_node_address):
|
||||
# check that unconfirmed outputs from bumped transactions are not spendable
|
||||
rbfid = create_fund_sign_send(rbf_node, {rbf_node_address: 0.00090000})
|
||||
rbfid = create_fund_sign_send(rbf_node, {rbf_node_address: 0.90000000})
|
||||
rbftx = rbf_node.gettransaction(rbfid)["hex"]
|
||||
assert rbfid in rbf_node.getrawmempool()
|
||||
bumpid = rbf_node.bumpfee(rbfid)["txid"]
|
||||
|
@ -259,7 +259,7 @@ def test_unconfirmed_not_spendable(rbf_node, rbf_node_address):
|
|||
|
||||
|
||||
def test_bumpfee_metadata(rbf_node, dest_address):
|
||||
rbfid = rbf_node.sendtoaddress(dest_address, 0.00090000, "comment value", "to value")
|
||||
rbfid = rbf_node.sendtoaddress(dest_address, 0.90000000, "comment value", "to value")
|
||||
bumped_tx = rbf_node.bumpfee(rbfid)
|
||||
bumped_wtx = rbf_node.gettransaction(bumped_tx["txid"])
|
||||
assert_equal(bumped_wtx["comment"], "comment value")
|
||||
|
@ -267,7 +267,7 @@ def test_bumpfee_metadata(rbf_node, dest_address):
|
|||
|
||||
|
||||
def test_locked_wallet_fails(rbf_node, dest_address):
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000})
|
||||
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.90000000})
|
||||
rbf_node.walletlock()
|
||||
assert_raises_message(JSONRPCException, "Please enter the wallet passphrase with walletpassphrase first.",
|
||||
rbf_node.bumpfee, rbfid)
|
||||
|
|
|
@ -25,21 +25,21 @@ class DisableWalletTest (BitcoinTestFramework):
|
|||
|
||||
def run_test (self):
|
||||
# Check regression: https://github.com/bitcoin/bitcoin/issues/6963#issuecomment-154548880
|
||||
x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
|
||||
x = self.nodes[0].validateaddress('D8dhKpPmW3L86B3Ej1bCuBSLLNN1QWqD2B')
|
||||
assert(x['isvalid'] == False)
|
||||
x = self.nodes[0].validateaddress('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
|
||||
x = self.nodes[0].validateaddress('mnT5rNQSpWrjbFCup6nHKXSYsPsJwq5Ag5')
|
||||
assert(x['isvalid'] == True)
|
||||
|
||||
# Checking mining to an address without a wallet
|
||||
try:
|
||||
self.nodes[0].generatetoaddress(1, 'mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
|
||||
self.nodes[0].generatetoaddress(1, 'mnT5rNQSpWrjbFCup6nHKXSYsPsJwq5Ag5')
|
||||
except JSONRPCException as e:
|
||||
assert("Invalid address" not in e.error['message'])
|
||||
assert("ProcessNewBlock, block not accepted" not in e.error['message'])
|
||||
assert("Couldn't create new block" not in e.error['message'])
|
||||
|
||||
try:
|
||||
self.nodes[0].generatetoaddress(1, '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
|
||||
self.nodes[0].generatetoaddress(1, 'D8dhKpPmW3L86B3Ej1bCuBSLLNN1QWqD2B')
|
||||
raise AssertionError("Must not mine to invalid address!")
|
||||
except JSONRPCException as e:
|
||||
assert("Invalid address" in e.error['message'])
|
||||
|
|
|
@ -154,7 +154,8 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
utx = get_unspent(self.nodes[2].listunspent(), 5)
|
||||
|
||||
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']}]
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal(5.0) - fee - feeTolerance }
|
||||
# Dogecoin: Fee is exact, do not use tolerance
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal(5.0) - fee }
|
||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
|
||||
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])
|
||||
|
@ -212,7 +213,8 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
utx = get_unspent(self.nodes[2].listunspent(), 5)
|
||||
|
||||
inputs = [ {'txid' : utx['txid'], 'vout' : utx['vout']} ]
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal(4.0) }
|
||||
# Dogecoin: Reduce this output so the fee doesn't leave us with no change
|
||||
outputs = { self.nodes[0].getnewaddress() : Decimal(2.5) }
|
||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
|
||||
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])
|
||||
|
@ -524,7 +526,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
# make sure funds are received at node1
|
||||
assert_equal(oldBalance+Decimal('51.10000000'), self.nodes[0].getbalance())
|
||||
assert_equal(oldBalance+Decimal('500001.10000000'), self.nodes[0].getbalance())
|
||||
|
||||
|
||||
###############################################
|
||||
|
@ -538,13 +540,14 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
for i in range(0,20):
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 2)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
#fund a tx with ~20 small inputs
|
||||
inputs = []
|
||||
outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.04}
|
||||
# Dogecoin: TX size rounding gives us a fee of 4 DOGE
|
||||
outputs = {self.nodes[0].getnewaddress():15,self.nodes[0].getnewaddress():4}
|
||||
rawTx = self.nodes[1].createrawtransaction(inputs, outputs)
|
||||
fundedTx = self.nodes[1].fundrawtransaction(rawTx)
|
||||
|
||||
|
@ -568,7 +571,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
for i in range(0,20):
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
|
||||
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 2)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
|
@ -576,7 +579,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
oldBalance = self.nodes[0].getbalance()
|
||||
|
||||
inputs = []
|
||||
outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.04}
|
||||
outputs = {self.nodes[0].getnewaddress():15,self.nodes[0].getnewaddress():4}
|
||||
rawTx = self.nodes[1].createrawtransaction(inputs, outputs)
|
||||
fundedTx = self.nodes[1].fundrawtransaction(rawTx)
|
||||
fundedAndSignedTx = self.nodes[1].signrawtransaction(fundedTx['hex'])
|
||||
|
@ -584,7 +587,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward
|
||||
assert_equal(oldBalance+Decimal('500019.00000000'), self.nodes[0].getbalance()) #19+block reward
|
||||
|
||||
#####################################################
|
||||
# test fundrawtransaction with OP_RETURN and no vin #
|
||||
|
|
|
@ -8,13 +8,11 @@
|
|||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
|
||||
from test_framework import auxpow
|
||||
from test_framework import scrypt_auxpow as auxpow
|
||||
|
||||
class GetAuxBlockTest (BitcoinTestFramework):
|
||||
|
||||
def run_test (self):
|
||||
BitcoinTestFramework.run_test (self)
|
||||
|
||||
# Generate a block so that we are not "downloading blocks".
|
||||
self.nodes[0].generate (1)
|
||||
|
||||
|
@ -32,7 +30,7 @@ class GetAuxBlockTest (BitcoinTestFramework):
|
|||
assert_equal (reversedTarget, blocktemplate['target'])
|
||||
|
||||
# Verify data that can be found in another way.
|
||||
assert_equal (auxblock['chainid'], 1)
|
||||
assert_equal (auxblock['chainid'], 98)
|
||||
assert_equal (auxblock['height'], self.nodes[0].getblockcount () + 1)
|
||||
assert_equal (auxblock['previousblockhash'], self.nodes[0].getblockhash (auxblock['height'] - 1))
|
||||
|
||||
|
@ -71,12 +69,12 @@ class GetAuxBlockTest (BitcoinTestFramework):
|
|||
target = blocktemplate['target']
|
||||
|
||||
# Compute invalid auxpow.
|
||||
apow = auxpow.computeAuxpow (auxblock['hash'], target, False)
|
||||
apow = auxpow.computeAuxpowWithChainId (auxblock['hash'], target, "98", False)
|
||||
res = self.nodes[0].getauxblock (auxblock['hash'], apow)
|
||||
assert not res
|
||||
|
||||
# Compute and submit valid auxpow.
|
||||
apow = auxpow.computeAuxpow (auxblock['hash'], target, True)
|
||||
apow = auxpow.computeAuxpowWithChainId (auxblock['hash'], target, "98", True)
|
||||
res = self.nodes[0].getauxblock (auxblock['hash'], apow)
|
||||
assert res
|
||||
|
||||
|
@ -106,7 +104,7 @@ class GetAuxBlockTest (BitcoinTestFramework):
|
|||
assert_equal (t['category'], "immature")
|
||||
assert_equal (t['blockhash'], auxblock['hash'])
|
||||
assert t['generated']
|
||||
assert t['amount'] >= Decimal ("25")
|
||||
assert t['amount'] >= Decimal ("500000")
|
||||
assert_equal (t['confirmations'], 1)
|
||||
|
||||
# Verify the coinbase script. Ensure that it includes the block height
|
||||
|
@ -117,7 +115,7 @@ class GetAuxBlockTest (BitcoinTestFramework):
|
|||
blk = self.nodes[1].getblock (auxblock['hash'])
|
||||
tx = self.nodes[1].getrawtransaction (blk['tx'][0], 1)
|
||||
coinbase = tx['vin'][0]['coinbase']
|
||||
assert_equal ("02%02x00" % auxblock['height'], coinbase[0 : 6])
|
||||
assert_equal ("01%02x01" % auxblock['height'], coinbase[0 : 6]) # DOGE: We mine less blocks in these tests
|
||||
|
||||
if __name__ == '__main__':
|
||||
GetAuxBlockTest ().main ()
|
||||
|
|
|
@ -21,7 +21,7 @@ class GetChainTipsTest (BitcoinTestFramework):
|
|||
tips = self.nodes[0].getchaintips ()
|
||||
assert_equal (len (tips), 1)
|
||||
assert_equal (tips[0]['branchlen'], 0)
|
||||
assert_equal (tips[0]['height'], 200)
|
||||
assert_equal (tips[0]['height'], 120)
|
||||
assert_equal (tips[0]['status'], 'active')
|
||||
|
||||
# Split the network and build two chains of different lengths.
|
||||
|
@ -34,14 +34,14 @@ class GetChainTipsTest (BitcoinTestFramework):
|
|||
assert_equal (len (tips), 1)
|
||||
shortTip = tips[0]
|
||||
assert_equal (shortTip['branchlen'], 0)
|
||||
assert_equal (shortTip['height'], 210)
|
||||
assert_equal (shortTip['height'], 130)
|
||||
assert_equal (tips[0]['status'], 'active')
|
||||
|
||||
tips = self.nodes[3].getchaintips ()
|
||||
assert_equal (len (tips), 1)
|
||||
longTip = tips[0]
|
||||
assert_equal (longTip['branchlen'], 0)
|
||||
assert_equal (longTip['height'], 220)
|
||||
assert_equal (longTip['height'], 140)
|
||||
assert_equal (tips[0]['status'], 'active')
|
||||
|
||||
# Join the network halves and check that we now have two tips
|
||||
|
|
|
@ -48,7 +48,7 @@ class ListSinceBlockTest (BitcoinTestFramework):
|
|||
|
||||
assert_equal(self.nodes[0].getbalance(), 0)
|
||||
assert_equal(self.nodes[1].getbalance(), 0)
|
||||
assert_equal(self.nodes[2].getbalance(), 50)
|
||||
assert_equal(self.nodes[2].getbalance(), 20500000)
|
||||
assert_equal(self.nodes[3].getbalance(), 0)
|
||||
|
||||
# Split network into two
|
||||
|
|
|
@ -29,63 +29,63 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
# Simple send, 0 to 1:
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 100)
|
||||
self.sync_all()
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"txid":txid},
|
||||
{"category":"send","account":"","amount":Decimal("-0.1"),"confirmations":0})
|
||||
{"category":"send","account":"","amount":Decimal(-100),"confirmations":0})
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"txid":txid},
|
||||
{"category":"receive","account":"","amount":Decimal("0.1"),"confirmations":0})
|
||||
{"category":"receive","account":"","amount":100,"confirmations":0})
|
||||
# mine a block, confirmations should change:
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"txid":txid},
|
||||
{"category":"send","account":"","amount":Decimal("-0.1"),"confirmations":1})
|
||||
{"category":"send","account":"","amount":Decimal(-100),"confirmations":1})
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"txid":txid},
|
||||
{"category":"receive","account":"","amount":Decimal("0.1"),"confirmations":1})
|
||||
{"category":"receive","account":"","amount":100,"confirmations":1})
|
||||
|
||||
# send-to-self:
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.2)
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 200)
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"txid":txid, "category":"send"},
|
||||
{"amount":Decimal("-0.2")})
|
||||
{"amount":Decimal("-200")})
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"txid":txid, "category":"receive"},
|
||||
{"amount":Decimal("0.2")})
|
||||
{"amount":200})
|
||||
|
||||
# sendmany from node1: twice to self, twice to node2:
|
||||
send_to = { self.nodes[0].getnewaddress() : 0.11,
|
||||
self.nodes[1].getnewaddress() : 0.22,
|
||||
self.nodes[0].getaccountaddress("from1") : 0.33,
|
||||
self.nodes[1].getaccountaddress("toself") : 0.44 }
|
||||
send_to = { self.nodes[0].getnewaddress() : 110,
|
||||
self.nodes[1].getnewaddress() : 220,
|
||||
self.nodes[0].getaccountaddress("from1") : 330,
|
||||
self.nodes[1].getaccountaddress("toself") : 440 }
|
||||
txid = self.nodes[1].sendmany("", send_to)
|
||||
self.sync_all()
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"category":"send","amount":Decimal("-0.11")},
|
||||
{"category":"send","amount":Decimal("-110")},
|
||||
{"txid":txid} )
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"category":"receive","amount":Decimal("0.11")},
|
||||
{"category":"receive","amount":Decimal("110")},
|
||||
{"txid":txid} )
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"category":"send","amount":Decimal("-0.22")},
|
||||
{"category":"send","amount":Decimal("-220")},
|
||||
{"txid":txid} )
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"category":"receive","amount":Decimal("0.22")},
|
||||
{"category":"receive","amount":Decimal("220")},
|
||||
{"txid":txid} )
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"category":"send","amount":Decimal("-0.33")},
|
||||
{"category":"send","amount":Decimal("-330")},
|
||||
{"txid":txid} )
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"category":"receive","amount":Decimal("0.33")},
|
||||
{"category":"receive","amount":Decimal("330")},
|
||||
{"txid":txid, "account" : "from1"} )
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"category":"send","amount":Decimal("-0.44")},
|
||||
{"category":"send","amount":Decimal("-440")},
|
||||
{"txid":txid, "account" : ""} )
|
||||
assert_array_result(self.nodes[1].listtransactions(),
|
||||
{"category":"receive","amount":Decimal("0.44")},
|
||||
{"category":"receive","amount":Decimal("440")},
|
||||
{"txid":txid, "account" : "toself"} )
|
||||
|
||||
multisig = self.nodes[1].createmultisig(1, [self.nodes[1].getnewaddress()])
|
||||
|
@ -120,7 +120,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
return None
|
||||
|
||||
# 1. Chain a few transactions that don't opt-in.
|
||||
txid_1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
|
||||
txid_1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 100)
|
||||
assert(not is_opt_in(self.nodes[0], txid_1))
|
||||
assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_1}, {"bip125-replaceable":"no"})
|
||||
sync_mempools(self.nodes)
|
||||
|
@ -131,7 +131,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
# Create tx2 using createrawtransaction
|
||||
inputs = [{"txid":utxo_to_use["txid"], "vout":utxo_to_use["vout"]}]
|
||||
outputs = {self.nodes[0].getnewaddress(): 0.999}
|
||||
outputs = {self.nodes[0].getnewaddress(): 99}
|
||||
tx2 = self.nodes[1].createrawtransaction(inputs, outputs)
|
||||
tx2_signed = self.nodes[1].signrawtransaction(tx2)["hex"]
|
||||
txid_2 = self.nodes[1].sendrawtransaction(tx2_signed)
|
||||
|
@ -145,7 +145,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
# Tx3 will opt-in to RBF
|
||||
utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[0], txid_2)
|
||||
inputs = [{"txid": txid_2, "vout":utxo_to_use["vout"]}]
|
||||
outputs = {self.nodes[1].getnewaddress(): 0.998}
|
||||
outputs = {self.nodes[1].getnewaddress(): 98}
|
||||
tx3 = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
tx3_modified = txFromHex(tx3)
|
||||
tx3_modified.vin[0].nSequence = 0
|
||||
|
@ -162,7 +162,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
# that does.
|
||||
utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[1], txid_3)
|
||||
inputs = [{"txid": txid_3, "vout":utxo_to_use["vout"]}]
|
||||
outputs = {self.nodes[0].getnewaddress(): 0.997}
|
||||
outputs = {self.nodes[0].getnewaddress(): 97}
|
||||
tx4 = self.nodes[1].createrawtransaction(inputs, outputs)
|
||||
tx4_signed = self.nodes[1].signrawtransaction(tx4)["hex"]
|
||||
txid_4 = self.nodes[1].sendrawtransaction(tx4_signed)
|
||||
|
@ -174,7 +174,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
# Replace tx3, and check that tx4 becomes unknown
|
||||
tx3_b = tx3_modified
|
||||
tx3_b.vout[0].nValue -= int(Decimal("0.004") * COIN) # bump the fee
|
||||
tx3_b.vout[0].nValue -= int(Decimal("4") * COIN) # bump the fee
|
||||
tx3_b = bytes_to_hex_str(tx3_b.serialize())
|
||||
tx3_b_signed = self.nodes[0].signrawtransaction(tx3_b)['hex']
|
||||
txid_3b = self.nodes[0].sendrawtransaction(tx3_b_signed, True)
|
||||
|
|
|
@ -31,7 +31,7 @@ class MempoolLimitTest(BitcoinTestFramework):
|
|||
#create a mempool tx that will be evicted
|
||||
us0 = utxos.pop()
|
||||
inputs = [{ "txid" : us0["txid"], "vout" : us0["vout"]}]
|
||||
outputs = {self.nodes[0].getnewaddress() : 0.0001}
|
||||
outputs = {self.nodes[0].getnewaddress() : 1}
|
||||
tx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
self.nodes[0].settxfee(self.relayfee) # specifically fund this tx with low fee
|
||||
txF = self.nodes[0].fundrawtransaction(tx)
|
||||
|
|
|
@ -44,16 +44,16 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
|
|||
# 1. Direct coinbase spend : spend_101
|
||||
# 2. Indirect (coinbase spend in chain, child in mempool) : spend_102 and spend_102_1
|
||||
# 3. Indirect (coinbase and child both in chain) : spend_103 and spend_103_1
|
||||
# Use invalidatblock to make all of the above coinbase spends invalid (immature coinbase),
|
||||
# Use invalidateblock to make all of the above coinbase spends invalid (immature coinbase),
|
||||
# and make sure the mempool code behaves correctly.
|
||||
b = [ self.nodes[0].getblockhash(n) for n in range(101, 105) ]
|
||||
b = [ self.nodes[0].getblockhash(n) for n in range(61, 65) ]
|
||||
coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ]
|
||||
spend_101_raw = create_tx(self.nodes[0], coinbase_txids[1], node1_address, 49.99)
|
||||
spend_102_raw = create_tx(self.nodes[0], coinbase_txids[2], node0_address, 49.99)
|
||||
spend_103_raw = create_tx(self.nodes[0], coinbase_txids[3], node0_address, 49.99)
|
||||
spend_101_raw = create_tx(self.nodes[0], coinbase_txids[1], node1_address, 499998)
|
||||
spend_102_raw = create_tx(self.nodes[0], coinbase_txids[2], node0_address, 500000)
|
||||
spend_103_raw = create_tx(self.nodes[0], coinbase_txids[3], node0_address, 499999)
|
||||
|
||||
# Create a block-height-locked transaction which will be invalid after reorg
|
||||
timelock_tx = self.nodes[0].createrawtransaction([{"txid": coinbase_txids[0], "vout": 0}], {node0_address: 49.99})
|
||||
timelock_tx = self.nodes[0].createrawtransaction([{"txid": coinbase_txids[0], "vout": 0}], {node0_address: 499999})
|
||||
# Set the time lock
|
||||
timelock_tx = timelock_tx.replace("ffffffff", "11111191", 1)
|
||||
timelock_tx = timelock_tx[:-8] + hex(self.nodes[0].getblockcount() + 2)[2:] + "000000"
|
||||
|
@ -67,8 +67,8 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
|
|||
assert_raises(JSONRPCException, self.nodes[0].sendrawtransaction, timelock_tx)
|
||||
|
||||
# Create 102_1 and 103_1:
|
||||
spend_102_1_raw = create_tx(self.nodes[0], spend_102_id, node1_address, 49.98)
|
||||
spend_103_1_raw = create_tx(self.nodes[0], spend_103_id, node1_address, 49.98)
|
||||
spend_102_1_raw = create_tx(self.nodes[0], spend_102_id, node1_address, 499999)
|
||||
spend_103_1_raw = create_tx(self.nodes[0], spend_103_id, node1_address, 499998)
|
||||
|
||||
# Broadcast and mine 103_1:
|
||||
spend_103_1_id = self.nodes[0].sendrawtransaction(spend_103_1_raw)
|
||||
|
|
|
@ -40,13 +40,13 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
|
|||
|
||||
b = [ self.nodes[0].getblockhash(n) for n in range(1, 4) ]
|
||||
coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ]
|
||||
spends1_raw = [ create_tx(self.nodes[0], txid, node0_address, 49.99) for txid in coinbase_txids ]
|
||||
spends1_raw = [ create_tx(self.nodes[0], txid, node0_address, 500000) for txid in coinbase_txids ]
|
||||
spends1_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends1_raw ]
|
||||
|
||||
blocks = []
|
||||
blocks.extend(self.nodes[0].generate(1))
|
||||
|
||||
spends2_raw = [ create_tx(self.nodes[0], txid, node0_address, 49.98) for txid in spends1_id ]
|
||||
spends2_raw = [ create_tx(self.nodes[0], txid, node0_address, 499999) for txid in spends1_id ]
|
||||
spends2_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends2_raw ]
|
||||
|
||||
blocks.extend(self.nodes[0].generate(1))
|
||||
|
|
|
@ -33,15 +33,15 @@ class MempoolSpendCoinbaseTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
chain_height = self.nodes[0].getblockcount()
|
||||
assert_equal(chain_height, 200)
|
||||
assert_equal(chain_height, 120)
|
||||
node0_address = self.nodes[0].getnewaddress()
|
||||
|
||||
# Coinbase at height chain_height-100+1 ok in mempool, should
|
||||
# get mined. Coinbase at height chain_height-100+2 is
|
||||
# Coinbase at height chain_height-60+1 ok in mempool, should
|
||||
# get mined. Coinbase at height chain_height-60+2 is
|
||||
# is too immature to spend.
|
||||
b = [ self.nodes[0].getblockhash(n) for n in range(101, 103) ]
|
||||
b = [ self.nodes[0].getblockhash(n) for n in range(61, 63) ]
|
||||
coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ]
|
||||
spends_raw = [ create_tx(self.nodes[0], txid, node0_address, 49.99) for txid in coinbase_txids ]
|
||||
spends_raw = [ create_tx(self.nodes[0], txid, node0_address, 500000) for txid in coinbase_txids ]
|
||||
|
||||
spend_101_id = self.nodes[0].sendrawtransaction(spends_raw[0])
|
||||
|
||||
|
|
|
@ -34,18 +34,18 @@ class MerkleBlockTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
print("Mining blocks...")
|
||||
self.nodes[0].generate(105)
|
||||
self.nodes[0].generate(65)
|
||||
self.sync_all()
|
||||
|
||||
chain_height = self.nodes[1].getblockcount()
|
||||
assert_equal(chain_height, 105)
|
||||
assert_equal(chain_height, 65)
|
||||
assert_equal(self.nodes[1].getbalance(), 0)
|
||||
assert_equal(self.nodes[2].getbalance(), 0)
|
||||
|
||||
node0utxos = self.nodes[0].listunspent(1)
|
||||
tx1 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99})
|
||||
tx1 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 500000})
|
||||
txid1 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx1)["hex"])
|
||||
tx2 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 49.99})
|
||||
tx2 = self.nodes[0].createrawtransaction([node0utxos.pop()], {self.nodes[1].getnewaddress(): 500000})
|
||||
txid2 = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransaction(tx2)["hex"])
|
||||
assert_raises(JSONRPCException, self.nodes[0].gettxoutproof, [txid1])
|
||||
|
||||
|
@ -63,7 +63,7 @@ class MerkleBlockTest(BitcoinTestFramework):
|
|||
assert_equal(self.nodes[2].verifytxoutproof(self.nodes[2].gettxoutproof([txid1, txid2], blockhash)), txlist)
|
||||
|
||||
txin_spent = self.nodes[1].listunspent(1).pop()
|
||||
tx3 = self.nodes[1].createrawtransaction([txin_spent], {self.nodes[0].getnewaddress(): 49.98})
|
||||
tx3 = self.nodes[1].createrawtransaction([txin_spent], {self.nodes[0].getnewaddress(): 500000})
|
||||
self.nodes[0].sendrawtransaction(self.nodes[1].signrawtransaction(tx3)["hex"])
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
|
|
@ -187,7 +187,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||
|
||||
# Now we need that block to mature so we can spend the coinbase.
|
||||
test = TestInstance(sync_every_block=False)
|
||||
for i in range(99):
|
||||
for i in range(59):
|
||||
block(5000 + i)
|
||||
test.blocks_and_transactions.append([self.tip, True])
|
||||
save_spendable_output()
|
||||
|
@ -662,7 +662,7 @@ class FullBlockTest(ComparisonTestFramework):
|
|||
tip(44)
|
||||
b47 = block(47, solve=False)
|
||||
target = uint256_from_compact(b47.nBits)
|
||||
while b47.sha256 < target: #changed > to <
|
||||
while b47.scrypt256 < target: #changed > to <
|
||||
b47.nNonce += 1
|
||||
b47.rehash()
|
||||
yield rejected(RejectResult(16, b'high-hash'))
|
||||
|
|
|
@ -128,7 +128,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
bal = self.nodes[0].getbalance()
|
||||
inputs = [{ "txid" : txId, "vout" : vout['n'], "scriptPubKey" : vout['scriptPubKey']['hex']}]
|
||||
outputs = { self.nodes[0].getnewaddress() : 2.19 }
|
||||
outputs = { self.nodes[0].getnewaddress() : 1.2 }
|
||||
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
rawTxPartialSigned = self.nodes[1].signrawtransaction(rawTx, inputs)
|
||||
assert_equal(rawTxPartialSigned['complete'], False) #node1 only has one key, can't comp. sign the tx
|
||||
|
@ -140,7 +140,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
assert_equal(self.nodes[0].getbalance(), bal+Decimal('50.00000000')+Decimal('2.19000000')) #block reward + tx
|
||||
assert_equal(self.nodes[0].getbalance(), bal+Decimal('500000.00000000')+Decimal('1.20000000')) #block reward + tx
|
||||
|
||||
# getrawtransaction tests
|
||||
# 1. valid parameters - only supply txid
|
||||
|
|
|
@ -42,7 +42,7 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||
'''
|
||||
# Send from node 0 to 1
|
||||
addr = self.nodes[1].getnewaddress()
|
||||
txid = self.nodes[0].sendtoaddress(addr, 0.1)
|
||||
txid = self.nodes[0].sendtoaddress(addr, 1)
|
||||
self.sync_all()
|
||||
|
||||
#Check not listed in listreceivedbyaddress because has 0 confirmations
|
||||
|
@ -55,11 +55,11 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
assert_array_result(self.nodes[1].listreceivedbyaddress(),
|
||||
{"address":addr},
|
||||
{"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":10, "txids":[txid,]})
|
||||
{"address":addr, "account":"", "amount":Decimal("1.0"), "confirmations":10, "txids":[txid,]})
|
||||
#With min confidence < 10
|
||||
assert_array_result(self.nodes[1].listreceivedbyaddress(5),
|
||||
{"address":addr},
|
||||
{"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":10, "txids":[txid,]})
|
||||
{"address":addr, "account":"", "amount":Decimal("1.0"), "confirmations":10, "txids":[txid,]})
|
||||
#With min confidence > 10, should not find Tx
|
||||
assert_array_result(self.nodes[1].listreceivedbyaddress(11),{"address":addr},{ },True)
|
||||
|
||||
|
@ -74,7 +74,7 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||
'''
|
||||
# Send from node 0 to 1
|
||||
addr = self.nodes[1].getnewaddress()
|
||||
txid = self.nodes[0].sendtoaddress(addr, 0.1)
|
||||
txid = self.nodes[0].sendtoaddress(addr, 1)
|
||||
self.sync_all()
|
||||
|
||||
#Check balance is 0 because of 0 confirmations
|
||||
|
@ -84,14 +84,14 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||
|
||||
#Check balance is 0.1
|
||||
balance = self.nodes[1].getreceivedbyaddress(addr,0)
|
||||
if balance != Decimal("0.1"):
|
||||
if balance != Decimal("1.0"):
|
||||
raise AssertionError("Wrong balance returned by getreceivedbyaddress, %0.2f"%(balance))
|
||||
|
||||
#Bury Tx under 10 block so it will be returned by the default getreceivedbyaddress
|
||||
self.nodes[1].generate(10)
|
||||
self.sync_all()
|
||||
balance = self.nodes[1].getreceivedbyaddress(addr)
|
||||
if balance != Decimal("0.1"):
|
||||
if balance != Decimal("1.0"):
|
||||
raise AssertionError("Wrong balance returned by getreceivedbyaddress, %0.2f"%(balance))
|
||||
|
||||
'''
|
||||
|
@ -105,7 +105,7 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||
raise AssertionError("No accounts found in node")
|
||||
balance_by_account = self.nodes[1].getreceivedbyaccount(account)
|
||||
|
||||
txid = self.nodes[0].sendtoaddress(addr, 0.1)
|
||||
txid = self.nodes[0].sendtoaddress(addr, 1)
|
||||
self.sync_all()
|
||||
|
||||
# listreceivedbyaccount should return received_by_account_json because of 0 confirmations
|
||||
|
@ -123,11 +123,11 @@ class ReceivedByTest(BitcoinTestFramework):
|
|||
# listreceivedbyaccount should return updated account balance
|
||||
assert_array_result(self.nodes[1].listreceivedbyaccount(),
|
||||
{"account":account},
|
||||
{"account":received_by_account_json["account"], "amount":(received_by_account_json["amount"] + Decimal("0.1"))})
|
||||
{"account":received_by_account_json["account"], "amount":(received_by_account_json["amount"] + Decimal("1.0"))})
|
||||
|
||||
# getreceivedbyaddress should return updates balance
|
||||
balance = self.nodes[1].getreceivedbyaccount(account)
|
||||
if balance != balance_by_account + Decimal("0.1"):
|
||||
if balance != balance_by_account + Decimal("1.0"):
|
||||
raise AssertionError("Wrong balance returned by getreceivedbyaccount, %0.2f"%(balance))
|
||||
|
||||
#Create a new account named "mynewaccount" that has a 0 balance
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#
|
||||
|
||||
|
||||
from test_framework import auxpow
|
||||
from test_framework import scrypt_auxpow as auxpow
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
from struct import *
|
||||
|
@ -70,15 +70,15 @@ class RESTTest (BitcoinTestFramework):
|
|||
self.nodes[2].generate(100)
|
||||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 50)
|
||||
assert_equal(self.nodes[0].getbalance(), 500000)
|
||||
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
|
||||
self.sync_all()
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
bb_hash = self.nodes[0].getbestblockhash()
|
||||
|
||||
assert_equal(self.nodes[1].getbalance(), Decimal("0.1")) #balance now should be 0.1 on node 1
|
||||
assert_equal(self.nodes[1].getbalance(), Decimal("1")) #balance now should be 1 on node 1
|
||||
|
||||
# load the latest 0.1 tx over the REST API
|
||||
json_string = http_get_call(url.hostname, url.port, '/rest/tx/'+txid+self.FORMAT_SEPARATOR+"json")
|
||||
|
@ -87,7 +87,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
# get n of 0.1 outpoint
|
||||
n = 0
|
||||
for vout in json_obj['vout']:
|
||||
if vout['value'] == 0.1:
|
||||
if vout['value'] == 1:
|
||||
n = vout['n']
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
|
||||
#make sure there is one utxo
|
||||
assert_equal(len(json_obj['utxos']), 1)
|
||||
assert_equal(json_obj['utxos'][0]['value'], 0.1)
|
||||
assert_equal(json_obj['utxos'][0]['value'], 1)
|
||||
|
||||
|
||||
################################################
|
||||
|
@ -157,14 +157,14 @@ class RESTTest (BitcoinTestFramework):
|
|||
############################
|
||||
|
||||
# do a tx and don't sync
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
|
||||
json_string = http_get_call(url.hostname, url.port, '/rest/tx/'+txid+self.FORMAT_SEPARATOR+"json")
|
||||
json_obj = json.loads(json_string)
|
||||
vintx = json_obj['vin'][0]['txid'] # get the vin to later check for utxo (should be spent by then)
|
||||
# get n of 0.1 outpoint
|
||||
n = 0
|
||||
for vout in json_obj['vout']:
|
||||
if vout['value'] == 0.1:
|
||||
if vout['value'] == 1:
|
||||
n = vout['n']
|
||||
|
||||
json_request = '/'+txid+'-'+str(n)
|
||||
|
@ -205,7 +205,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
assert_equal(response.status, 200) #must be a 200 because we are within the limits
|
||||
|
||||
# Generate a block to not affect upcoming tests.
|
||||
auxpow.mineAuxpowBlock(self.nodes[0]) #generate
|
||||
auxpow.mineScryptAux(self.nodes[0], "98", True) #generate
|
||||
self.sync_all()
|
||||
bb_hash = self.nodes[0].getbestblockhash()
|
||||
|
||||
|
@ -223,7 +223,7 @@ class RESTTest (BitcoinTestFramework):
|
|||
response_header = http_get_call(url.hostname, url.port, '/rest/headers/1/'+bb_hash+self.FORMAT_SEPARATOR+"bin", True)
|
||||
assert_equal(response_header.status, 200)
|
||||
headerLen = int(response_header.getheader('content-length'))
|
||||
assert_greater_than(headerLen, 80)
|
||||
assert_equal(headerLen, 297) # DOGE: AuxPoW makes headers longer
|
||||
response_header_str = response_header.read()
|
||||
assert_equal(response_str[0:headerLen], response_header_str)
|
||||
|
||||
|
|
|
@ -26,17 +26,15 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
|||
|
||||
1) The transaction has a complete set of signatures
|
||||
2) No script verification error occurred"""
|
||||
privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N', 'cVKpPfVKSJxKqVpE9awvXNWuLHCa5j5tiE7K6zbUSptFpTEtiFrA']
|
||||
privKeys = ['cNo1Fekr1kVEWcAw4P2Gg6MXWsRBtYy5W8idzMoJifCgkpPfLMfj']
|
||||
|
||||
inputs = [
|
||||
# Valid pay-to-pubkey scripts
|
||||
{'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 0,
|
||||
'scriptPubKey': '76a91460baa0f494b38ce3c940dea67f3804dc52d1fb9488ac'},
|
||||
{'txid': '83a4f6a6b73660e13ee6cb3c6063fa3759c50c9b7521d0536022961898f4fb02', 'vout': 0,
|
||||
'scriptPubKey': '76a914669b857c03a5ed269d5d85a1ffac9ed5d663072788ac'},
|
||||
{'txid': 'f9951bb9536cdabec3ad1b9ceaf8170051bd80372db22cfb59901036526891b0', 'vout': 0,
|
||||
'scriptPubKey': '2102de5b9a06f9c892706943614ab4c0f29c1b1fb52170aac9c04e8df5266e42e415ac'},
|
||||
]
|
||||
|
||||
outputs = {'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB': 0.1}
|
||||
outputs = {'mwuZbHnDiYNm9gaMhm7vsmHjkLQdTWCGN9': 1}
|
||||
|
||||
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
rawTxSigned = self.nodes[0].signrawtransaction(rawTx, inputs, privKeys)
|
||||
|
@ -73,27 +71,27 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
|||
4) Two script verification errors occurred
|
||||
5) Script verification errors have certain properties ("txid", "vout", "scriptSig", "sequence", "error")
|
||||
6) The verification errors refer to the invalid (vin 1) and missing input (vin 2)"""
|
||||
privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N']
|
||||
privKeys = ['cNo1Fekr1kVEWcAw4P2Gg6MXWsRBtYy5W8idzMoJifCgkpPfLMfj']
|
||||
|
||||
inputs = [
|
||||
# Valid pay-to-pubkey script
|
||||
{'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 0},
|
||||
{'txid': 'f9951bb9536cdabec3ad1b9ceaf8170051bd80372db22cfb59901036526891b0', 'vout': 0},
|
||||
# Invalid script
|
||||
{'txid': '5b8673686910442c644b1f4993d8f7753c7c8fcb5c87ee40d56eaeef25204547', 'vout': 7},
|
||||
# Missing scriptPubKey
|
||||
{'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 1},
|
||||
{'txid': 'e54f117b032e99a62705f4ea52a68ac1bc3585697beed3190486c2b64b94b956', 'vout': 1},
|
||||
]
|
||||
|
||||
scripts = [
|
||||
# Valid pay-to-pubkey script
|
||||
{'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 0,
|
||||
'scriptPubKey': '76a91460baa0f494b38ce3c940dea67f3804dc52d1fb9488ac'},
|
||||
{'txid': 'f9951bb9536cdabec3ad1b9ceaf8170051bd80372db22cfb59901036526891b0', 'vout': 0,
|
||||
'scriptPubKey': '2102de5b9a06f9c892706943614ab4c0f29c1b1fb52170aac9c04e8df5266e42e415ac'},
|
||||
# Invalid script
|
||||
{'txid': '5b8673686910442c644b1f4993d8f7753c7c8fcb5c87ee40d56eaeef25204547', 'vout': 7,
|
||||
'scriptPubKey': 'badbadbadbad'}
|
||||
]
|
||||
|
||||
outputs = {'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB': 0.1}
|
||||
outputs = {'mwuZbHnDiYNm9gaMhm7vsmHjkLQdTWCGN9': 1}
|
||||
|
||||
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2014 Daniel Kraft
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
@ -105,7 +105,7 @@ def reverseHex (data):
|
|||
Flip byte order in the given data (hex string).
|
||||
"""
|
||||
|
||||
b = bytearray (binascii.unhexlify (data))
|
||||
b = bytearray (bytes.fromhex(data))
|
||||
b.reverse ()
|
||||
|
||||
return binascii.hexlify (b)
|
||||
return b.hex()
|
||||
|
|
|
@ -10,6 +10,8 @@ from .script import CScript, OP_TRUE, OP_CHECKSIG, OP_RETURN
|
|||
# Create a block (with regtest difficulty)
|
||||
def create_block(hashprev, coinbase, nTime=None):
|
||||
block = CBlock()
|
||||
# Dogecoin: Create a non-AuxPoW block but include chain ID
|
||||
block.nVersion = 0x620003
|
||||
if nTime is None:
|
||||
import time
|
||||
block.nTime = int(time.time()+600)
|
||||
|
@ -68,7 +70,7 @@ def create_coinbase(height, pubkey = None):
|
|||
coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff),
|
||||
ser_string(serialize_script_num(height)), 0xffffffff))
|
||||
coinbaseoutput = CTxOut()
|
||||
coinbaseoutput.nValue = 50 * COIN
|
||||
coinbaseoutput.nValue = 500000 * COIN
|
||||
halvings = int(height/150) # regtest
|
||||
coinbaseoutput.nValue >>= halvings
|
||||
if (pubkey != None):
|
||||
|
|
|
@ -36,6 +36,7 @@ from threading import RLock
|
|||
from threading import Thread
|
||||
import logging
|
||||
import copy
|
||||
import litecoin_scrypt
|
||||
from test_framework.siphash import siphash256
|
||||
|
||||
BIP0031_VERSION = 60000
|
||||
|
@ -536,6 +537,7 @@ class CBlockHeader(object):
|
|||
self.nNonce = header.nNonce
|
||||
self.sha256 = header.sha256
|
||||
self.hash = header.hash
|
||||
self.scrypt256 = header.scrypt256
|
||||
self.calc_sha256()
|
||||
|
||||
def set_null(self):
|
||||
|
@ -547,6 +549,7 @@ class CBlockHeader(object):
|
|||
self.nNonce = 0
|
||||
self.sha256 = None
|
||||
self.hash = None
|
||||
self.scrypt256 = None
|
||||
|
||||
def deserialize(self, f):
|
||||
self.nVersion = struct.unpack("<i", f.read(4))[0]
|
||||
|
@ -557,6 +560,7 @@ class CBlockHeader(object):
|
|||
self.nNonce = struct.unpack("<I", f.read(4))[0]
|
||||
self.sha256 = None
|
||||
self.hash = None
|
||||
self.scrypt256 = None
|
||||
|
||||
def serialize(self):
|
||||
r = b""
|
||||
|
@ -579,9 +583,11 @@ class CBlockHeader(object):
|
|||
r += struct.pack("<I", self.nNonce)
|
||||
self.sha256 = uint256_from_str(hash256(r))
|
||||
self.hash = encode(hash256(r)[::-1], 'hex_codec').decode('ascii')
|
||||
self.scrypt256 = uint256_from_str(litecoin_scrypt.getPoWHash(r))
|
||||
|
||||
def rehash(self):
|
||||
self.sha256 = None
|
||||
self.scrypt256 = None
|
||||
self.calc_sha256()
|
||||
return self.sha256
|
||||
|
||||
|
@ -640,7 +646,7 @@ class CBlock(CBlockHeader):
|
|||
def is_valid(self):
|
||||
self.calc_sha256()
|
||||
target = uint256_from_compact(self.nBits)
|
||||
if self.sha256 > target:
|
||||
if self.scrypt256 > target:
|
||||
return False
|
||||
for tx in self.vtx:
|
||||
if not tx.is_valid():
|
||||
|
@ -652,7 +658,7 @@ class CBlock(CBlockHeader):
|
|||
def solve(self):
|
||||
self.rehash()
|
||||
target = uint256_from_compact(self.nBits)
|
||||
while self.sha256 > target:
|
||||
while self.scrypt256 > target:
|
||||
self.nNonce += 1
|
||||
self.rehash()
|
||||
|
||||
|
@ -1610,8 +1616,8 @@ class NodeConn(asyncore.dispatcher):
|
|||
b"blocktxn": msg_blocktxn
|
||||
}
|
||||
MAGIC_BYTES = {
|
||||
"mainnet": b"\xf9\xbe\xb4\xd9", # mainnet
|
||||
"testnet3": b"\x0b\x11\x09\x07", # testnet3
|
||||
"mainnet": b"\xc0\xc0\xc0\xc0", # mainnet
|
||||
"testnet3": b"\xfc\xc1\xb7\xdc", # testnet3
|
||||
"regtest": b"\xfa\xbf\xb5\xda", # regtest
|
||||
}
|
||||
|
||||
|
|
104
qa/rpc-tests/test_framework/scrypt_auxpow.py
Normal file
104
qa/rpc-tests/test_framework/scrypt_auxpow.py
Normal file
|
@ -0,0 +1,104 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright (c) 2014 Daniel Kraft
|
||||
# Copyright (c) 2015-2018 The Dogecoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
# General code for scrypt auxpow testing. This includes routines to
|
||||
# solve an auxpow header and to generate auxpow blocks with scrypt.
|
||||
# extends and modifies auxpow module by Daniel Kraft.
|
||||
|
||||
# This module requires a built and installed version of the ltc_scrypt
|
||||
# package, which can be downloaded from:
|
||||
# https://pypi.python.org/packages/source/l/ltc_scrypt/ltc_scrypt-1.0.tar.gz
|
||||
|
||||
from .auxpow import *
|
||||
import ltc_scrypt
|
||||
|
||||
def computeAuxpowWithChainId (block, target, chainid, ok):
|
||||
"""
|
||||
Build an auxpow object (serialised as hex string) that solves the
|
||||
block, for a given chain id.
|
||||
"""
|
||||
|
||||
# Start by building the merge-mining coinbase. The merkle tree
|
||||
# consists only of the block hash as root.
|
||||
coinbase = "fabe" + (b"m" * 2).hex()
|
||||
coinbase += block
|
||||
coinbase += "01000000" + ("00" * 4)
|
||||
|
||||
# Construct "vector" of transaction inputs.
|
||||
vin = "01"
|
||||
vin += ("00" * 32) + ("ff" * 4)
|
||||
vin += ("%02x" % int(len (coinbase) / 2)) + coinbase
|
||||
vin += ("ff" * 4)
|
||||
|
||||
# Build up the full coinbase transaction. It consists only
|
||||
# of the input and has no outputs.
|
||||
tx = "01000000" + vin + "00" + ("00" * 4)
|
||||
txHash = doubleHashHex (tx)
|
||||
|
||||
# Construct the parent block header. It need not be valid, just good
|
||||
# enough for auxpow purposes.
|
||||
header = "0100" + chainid + "00"
|
||||
header += "00" * 32
|
||||
header += reverseHex (txHash)
|
||||
header += "00" * 4
|
||||
header += "00" * 4
|
||||
header += "00" * 4
|
||||
|
||||
# Mine the block.
|
||||
(header, blockhash) = mineScryptBlock (header, target, ok)
|
||||
|
||||
# Build the MerkleTx part of the auxpow.
|
||||
output = tx
|
||||
output += blockhash
|
||||
output += "00"
|
||||
output += "00" * 4
|
||||
|
||||
# Extend to full auxpow.
|
||||
output += "00"
|
||||
output += "00" * 4
|
||||
output += header
|
||||
|
||||
return output
|
||||
|
||||
# for now, just offer hashes to rpc until it matches the work we need
|
||||
def mineScryptAux (node, chainid, ok):
|
||||
"""
|
||||
Mine an auxpow block on the given RPC connection.
|
||||
"""
|
||||
|
||||
auxblock = node.getauxblock ()
|
||||
target = reverseHex (auxblock['_target'])
|
||||
|
||||
apow = computeAuxpowWithChainId (auxblock['hash'], target, chainid, ok)
|
||||
res = node.getauxblock (auxblock['hash'], apow)
|
||||
return res
|
||||
|
||||
def mineScryptBlock (header, target, ok):
|
||||
"""
|
||||
Given a block header, update the nonce until it is ok (or not)
|
||||
for the given target.
|
||||
"""
|
||||
|
||||
data = bytearray (bytes.fromhex(header))
|
||||
while True:
|
||||
assert data[79] < 255
|
||||
data[79] += 1
|
||||
hexData = data.hex()
|
||||
|
||||
scrypt = getScryptPoW(hexData)
|
||||
if (ok and scrypt < target) or ((not ok) and scrypt > target):
|
||||
break
|
||||
|
||||
blockhash = doubleHashHex (hexData)
|
||||
return (hexData, blockhash)
|
||||
|
||||
def getScryptPoW(hexData):
|
||||
"""
|
||||
Actual scrypt pow calculation
|
||||
"""
|
||||
|
||||
data = bytes.fromhex(hexData)
|
||||
return reverseHex(ltc_scrypt.getPoWHash(data).hex())
|
|
@ -8,6 +8,7 @@
|
|||
# Helpful routines for regression testing
|
||||
#
|
||||
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -228,7 +229,7 @@ def wait_for_bitcoind_start(process, url, i):
|
|||
|
||||
def initialize_chain(test_dir, num_nodes, cachedir):
|
||||
"""
|
||||
Create a cache of a 200-block-long chain (with wallet) for MAX_NODES
|
||||
Create a cache of a 120-block-long chain (with wallet) for MAX_NODES
|
||||
Afterward, create num_nodes copies from the cache
|
||||
"""
|
||||
|
||||
|
@ -267,21 +268,21 @@ def initialize_chain(test_dir, num_nodes, cachedir):
|
|||
sys.stderr.write("Error connecting to "+url+"\n")
|
||||
sys.exit(1)
|
||||
|
||||
# Create a 200-block-long chain; each of the 4 first nodes
|
||||
# gets 25 mature blocks and 25 immature.
|
||||
# Create a 120-block-long chain; each of the 4 first nodes
|
||||
# gets 15 mature blocks and 15 immature.
|
||||
# Note: To preserve compatibility with older versions of
|
||||
# initialize_chain, only 4 nodes will generate coins.
|
||||
#
|
||||
# blocks are created with timestamps 10 minutes apart
|
||||
# blocks are created with timestamps 1 minute apart
|
||||
# starting from 2010 minutes in the past
|
||||
enable_mocktime()
|
||||
block_time = get_mocktime() - (201 * 10 * 60)
|
||||
block_time = get_mocktime() - (121 * 60)
|
||||
for i in range(2):
|
||||
for peer in range(4):
|
||||
for j in range(25):
|
||||
for j in range(15):
|
||||
set_node_times(rpcs, block_time)
|
||||
rpcs[peer].generate(1)
|
||||
block_time += 10*60
|
||||
block_time += 60
|
||||
# Must sync before next peer starts generating blocks
|
||||
sync_blocks(rpcs)
|
||||
|
||||
|
@ -508,13 +509,16 @@ def random_transaction(nodes, amount, min_fee, fee_increment, fee_variants):
|
|||
|
||||
def assert_fee_amount(fee, tx_size, fee_per_kB):
|
||||
"""Assert the fee was in range"""
|
||||
target_fee = tx_size * fee_per_kB / 1000
|
||||
target_fee = round_tx_size(tx_size) * fee_per_kB / 1000
|
||||
if fee < target_fee:
|
||||
raise AssertionError("Fee of %s BTC too low! (Should be %s BTC)"%(str(fee), str(target_fee)))
|
||||
# allow the wallet's estimation to be at most 2 bytes off
|
||||
if fee > (tx_size + 2) * fee_per_kB / 1000:
|
||||
if fee > round_tx_size(tx_size + 2) * fee_per_kB / 1000:
|
||||
raise AssertionError("Fee of %s BTC too high! (Should be %s BTC)"%(str(fee), str(target_fee)))
|
||||
|
||||
def round_tx_size(tx_size):
|
||||
return int(math.ceil(tx_size / 1000.0)) * 1000
|
||||
|
||||
def assert_equal(thing1, thing2, *args):
|
||||
if thing1 != thing2 or any(thing1 != arg for arg in args):
|
||||
raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
|
||||
|
@ -622,7 +626,7 @@ def satoshi_round(amount):
|
|||
# Helper to create at least "count" utxos
|
||||
# Pass in a fee that is sufficient for relay and mining new transactions.
|
||||
def create_confirmed_utxos(fee, node, count):
|
||||
node.generate(int(0.5*count)+101)
|
||||
node.generate(int(0.5*count)+61)
|
||||
utxos = node.listunspent()
|
||||
iterations = count - len(utxos)
|
||||
addr1 = node.getnewaddress()
|
||||
|
|
|
@ -27,13 +27,13 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
|
||||
def run_test(self):
|
||||
# All nodes should start with 1,250 BTC:
|
||||
starting_balance = 1250
|
||||
starting_balance = 7500000
|
||||
for i in range(4):
|
||||
assert_equal(self.nodes[i].getbalance(), starting_balance)
|
||||
self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress!
|
||||
|
||||
# Assign coins to foo and bar accounts:
|
||||
self.nodes[0].settxfee(.001)
|
||||
self.nodes[0].settxfee(1)
|
||||
|
||||
node0_address_foo = self.nodes[0].getnewaddress("foo")
|
||||
fund_foo_txid = self.nodes[0].sendfrom("", node0_address_foo, 1219)
|
||||
|
@ -89,7 +89,7 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
# Node0's balance should be starting balance, plus 50BTC for another
|
||||
# matured block, minus tx1 and tx2 amounts, and minus transaction fees:
|
||||
expected = starting_balance + fund_foo_tx["fee"] + fund_bar_tx["fee"]
|
||||
if self.options.mine_block: expected += 50
|
||||
if self.options.mine_block: expected += 500000
|
||||
expected += tx1["amount"] + tx1["fee"]
|
||||
expected += tx2["amount"] + tx2["fee"]
|
||||
assert_equal(self.nodes[0].getbalance(), expected)
|
||||
|
@ -132,9 +132,9 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
|
||||
# Check node0's total balance; should be same as before the clone, + 100 BTC for 2 matured,
|
||||
# less possible orphaned matured subsidy
|
||||
expected += 100
|
||||
expected += 1000000
|
||||
if (self.options.mine_block):
|
||||
expected -= 50
|
||||
expected -= 500000
|
||||
assert_equal(self.nodes[0].getbalance(), expected)
|
||||
assert_equal(self.nodes[0].getbalance("*", 0), expected)
|
||||
|
||||
|
@ -149,7 +149,7 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
+ fund_foo_tx["fee"]
|
||||
- 29
|
||||
+ fund_bar_tx["fee"]
|
||||
+ 100)
|
||||
+ 1000000)
|
||||
|
||||
# Node1's "from0" account balance
|
||||
assert_equal(self.nodes[1].getbalance("from0", 0), -(tx1["amount"] + tx2["amount"]))
|
||||
|
|
|
@ -26,19 +26,19 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
return super(TxnMallTest, self).setup_network(True)
|
||||
|
||||
def run_test(self):
|
||||
# All nodes should start with 1,250 BTC:
|
||||
starting_balance = 1250
|
||||
# All nodes should start with 7,500,000 DOGE:
|
||||
starting_balance = 7500000
|
||||
for i in range(4):
|
||||
assert_equal(self.nodes[i].getbalance(), starting_balance)
|
||||
self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress!
|
||||
|
||||
# Assign coins to foo and bar accounts:
|
||||
node0_address_foo = self.nodes[0].getnewaddress("foo")
|
||||
fund_foo_txid = self.nodes[0].sendfrom("", node0_address_foo, 1219)
|
||||
fund_foo_txid = self.nodes[0].sendfrom("", node0_address_foo, 7499970)
|
||||
fund_foo_tx = self.nodes[0].gettransaction(fund_foo_txid)
|
||||
|
||||
node0_address_bar = self.nodes[0].getnewaddress("bar")
|
||||
fund_bar_txid = self.nodes[0].sendfrom("", node0_address_bar, 29)
|
||||
fund_bar_txid = self.nodes[0].sendfrom("", node0_address_bar, 30)
|
||||
fund_bar_tx = self.nodes[0].gettransaction(fund_bar_txid)
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(""),
|
||||
|
@ -47,9 +47,9 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
# Coins are sent to node1_address
|
||||
node1_address = self.nodes[1].getnewaddress("from0")
|
||||
|
||||
# First: use raw transaction API to send 1240 BTC to node1_address,
|
||||
# First: use raw transaction API to send 7499960 DOGE to node1_address,
|
||||
# but don't broadcast:
|
||||
doublespend_fee = Decimal('-.02')
|
||||
doublespend_fee = Decimal('-2')
|
||||
rawtx_input_0 = {}
|
||||
rawtx_input_0["txid"] = fund_foo_txid
|
||||
rawtx_input_0["vout"] = find_output(self.nodes[0], fund_foo_txid, 1219)
|
||||
|
@ -59,14 +59,14 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
inputs = [rawtx_input_0, rawtx_input_1]
|
||||
change_address = self.nodes[0].getnewaddress()
|
||||
outputs = {}
|
||||
outputs[node1_address] = 1240
|
||||
outputs[change_address] = 1248 - 1240 + doublespend_fee
|
||||
outputs[node1_address] = 7499960
|
||||
outputs[change_address] = 7499998 - 1219 + doublespend_fee
|
||||
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
doublespend = self.nodes[0].signrawtransaction(rawtx)
|
||||
assert_equal(doublespend["complete"], True)
|
||||
|
||||
# Create two spends using 1 50 BTC coin each
|
||||
txid1 = self.nodes[0].sendfrom("foo", node1_address, 40, 0)
|
||||
txid1 = self.nodes[0].sendfrom("foo", node1_address, 7499960, 0)
|
||||
txid2 = self.nodes[0].sendfrom("bar", node1_address, 20, 0)
|
||||
|
||||
# Have node0 mine a block:
|
||||
|
@ -77,17 +77,17 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
tx1 = self.nodes[0].gettransaction(txid1)
|
||||
tx2 = self.nodes[0].gettransaction(txid2)
|
||||
|
||||
# Node0's balance should be starting balance, plus 50BTC for another
|
||||
# matured block, minus 40, minus 20, and minus transaction fees:
|
||||
# Node0's balance should be starting balance, plus 500,000 DOGE for another
|
||||
# matured block, minus 7499960, minus 20, and minus transaction fees:
|
||||
expected = starting_balance + fund_foo_tx["fee"] + fund_bar_tx["fee"]
|
||||
if self.options.mine_block: expected += 50
|
||||
if self.options.mine_block: expected += 500000
|
||||
expected += tx1["amount"] + tx1["fee"]
|
||||
expected += tx2["amount"] + tx2["fee"]
|
||||
assert_equal(self.nodes[0].getbalance(), expected)
|
||||
|
||||
# foo and bar accounts should be debited:
|
||||
assert_equal(self.nodes[0].getbalance("foo", 0), 1219+tx1["amount"]+tx1["fee"])
|
||||
assert_equal(self.nodes[0].getbalance("bar", 0), 29+tx2["amount"]+tx2["fee"])
|
||||
assert_equal(self.nodes[0].getbalance("foo", 0), 7499970+tx1["amount"]+tx1["fee"])
|
||||
assert_equal(self.nodes[0].getbalance("bar", 0), 30+tx2["amount"]+tx2["fee"])
|
||||
|
||||
if self.options.mine_block:
|
||||
assert_equal(tx1["confirmations"], 1)
|
||||
|
@ -122,14 +122,14 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
# Node0's total balance should be starting balance, plus 100BTC for
|
||||
# two more matured blocks, minus 1240 for the double-spend, plus fees (which are
|
||||
# negative):
|
||||
expected = starting_balance + 100 - 1240 + fund_foo_tx["fee"] + fund_bar_tx["fee"] + doublespend_fee
|
||||
expected = starting_balance + 1000000 - 7499960 + fund_foo_tx["fee"] + fund_bar_tx["fee"] + doublespend_fee
|
||||
assert_equal(self.nodes[0].getbalance(), expected)
|
||||
assert_equal(self.nodes[0].getbalance("*"), expected)
|
||||
|
||||
# Final "" balance is starting_balance - amount moved to accounts - doublespend + subsidies +
|
||||
# fees (which are negative)
|
||||
assert_equal(self.nodes[0].getbalance("foo"), 1219)
|
||||
assert_equal(self.nodes[0].getbalance("bar"), 29)
|
||||
assert_equal(self.nodes[0].getbalance("foo"), 7499970-7499960)
|
||||
assert_equal(self.nodes[0].getbalance("bar"), 30)
|
||||
assert_equal(self.nodes[0].getbalance(""), starting_balance
|
||||
-1219
|
||||
- 29
|
||||
|
@ -140,7 +140,7 @@ class TxnMallTest(BitcoinTestFramework):
|
|||
+ doublespend_fee)
|
||||
|
||||
# Node1's "from0" account balance should be just the doublespend:
|
||||
assert_equal(self.nodes[1].getbalance("from0"), 1240)
|
||||
assert_equal(self.nodes[1].getbalance("from0"), 7499960)
|
||||
|
||||
if __name__ == '__main__':
|
||||
TxnMallTest().main()
|
||||
|
|
|
@ -31,10 +31,10 @@ class WalletAccountsTest(BitcoinTestFramework):
|
|||
|
||||
node.generate(101)
|
||||
|
||||
assert_equal(node.getbalance(), 50)
|
||||
assert_equal(node.getbalance(), 20500000)
|
||||
|
||||
accounts = ["a","b","c","d","e"]
|
||||
amount_to_send = 1.0
|
||||
amount_to_send = 1000000
|
||||
account_addresses = dict()
|
||||
for account in accounts:
|
||||
address = node.getaccountaddress(account)
|
||||
|
@ -59,18 +59,18 @@ class WalletAccountsTest(BitcoinTestFramework):
|
|||
for account in accounts:
|
||||
address = node.getaccountaddress(account)
|
||||
assert(address != account_addresses[account])
|
||||
assert_equal(node.getreceivedbyaccount(account), 2)
|
||||
assert_equal(node.getreceivedbyaccount(account), 2000000)
|
||||
node.move(account, "", node.getbalance(account))
|
||||
|
||||
node.generate(101)
|
||||
|
||||
expected_account_balances = {"": 5200}
|
||||
expected_account_balances = {"": 72000000}
|
||||
for account in accounts:
|
||||
expected_account_balances[account] = 0
|
||||
|
||||
assert_equal(node.listaccounts(), expected_account_balances)
|
||||
|
||||
assert_equal(node.getbalance(""), 5200)
|
||||
assert_equal(node.getbalance(""), 72000000)
|
||||
|
||||
for account in accounts:
|
||||
address = node.getaccountaddress("")
|
||||
|
@ -83,12 +83,12 @@ class WalletAccountsTest(BitcoinTestFramework):
|
|||
for x in range(10):
|
||||
addresses.append(node.getnewaddress())
|
||||
multisig_address = node.addmultisigaddress(5, addresses, account)
|
||||
node.sendfrom("", multisig_address, 50)
|
||||
node.sendfrom("", multisig_address, 500000)
|
||||
|
||||
node.generate(101)
|
||||
|
||||
for account in accounts:
|
||||
assert_equal(node.getbalance(account), 50)
|
||||
assert_equal(node.getbalance(account), 500000)
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletAccountsTest().main ()
|
||||
|
|
|
@ -86,7 +86,7 @@ class WalletDumpTest(BitcoinTestFramework):
|
|||
found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_unenc = \
|
||||
read_dump(tmpdir + "/node0/wallet.unencrypted.dump", addrs, None)
|
||||
assert_equal(found_addr, test_addr_count) # all keys must be in the dump
|
||||
assert_equal(found_addr_chg, 50) # 50 blocks where mined
|
||||
assert_equal(found_addr_chg, 30) # 30 blocks where mined
|
||||
assert_equal(found_addr_rsv, 90 + 1) # keypool size (TODO: fix off-by-one)
|
||||
|
||||
#encrypt wallet, restart, unlock and dump
|
||||
|
@ -101,7 +101,7 @@ class WalletDumpTest(BitcoinTestFramework):
|
|||
found_addr, found_addr_chg, found_addr_rsv, hd_master_addr_enc = \
|
||||
read_dump(tmpdir + "/node0/wallet.encrypted.dump", addrs, hd_master_addr_unenc)
|
||||
assert_equal(found_addr, test_addr_count)
|
||||
assert_equal(found_addr_chg, 90 + 1 + 50) # old reserve keys are marked as change now
|
||||
assert_equal(found_addr_chg, 90 + 1 + 30) # old reserve keys are marked as change now
|
||||
assert_equal(found_addr_rsv, 90 + 1) # keypool size (TODO: fix off-by-one)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
|
||||
|
@ -40,15 +41,15 @@ class WalletTest (BitcoinTestFramework):
|
|||
self.nodes[0].generate(1)
|
||||
|
||||
walletinfo = self.nodes[0].getwalletinfo()
|
||||
assert_equal(walletinfo['immature_balance'], 50)
|
||||
assert_equal(walletinfo['immature_balance'], 500000)
|
||||
assert_equal(walletinfo['balance'], 0)
|
||||
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(101)
|
||||
self.nodes[1].generate(61)
|
||||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 50)
|
||||
assert_equal(self.nodes[1].getbalance(), 50)
|
||||
assert_equal(self.nodes[0].getbalance(), 500000)
|
||||
assert_equal(self.nodes[1].getbalance(), 500000)
|
||||
assert_equal(self.nodes[2].getbalance(), 0)
|
||||
|
||||
# Check that only first and second nodes have UTXOs
|
||||
|
@ -56,9 +57,9 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert_equal(len(self.nodes[1].listunspent()), 1)
|
||||
assert_equal(len(self.nodes[2].listunspent()), 0)
|
||||
|
||||
# Send 21 BTC from 0 to 2 using sendtoaddress call.
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
|
||||
# Send 210.000 DOGE from 0 to 2 using sendtoaddress call.
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 110000)
|
||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 100000)
|
||||
|
||||
walletinfo = self.nodes[0].getwalletinfo()
|
||||
assert_equal(walletinfo['immature_balance'], 0)
|
||||
|
@ -71,19 +72,19 @@ class WalletTest (BitcoinTestFramework):
|
|||
unspent_0 = self.nodes[2].listunspent()[0]
|
||||
unspent_0 = {"txid": unspent_0["txid"], "vout": unspent_0["vout"]}
|
||||
self.nodes[2].lockunspent(False, [unspent_0])
|
||||
assert_raises_message(JSONRPCException, "Insufficient funds", self.nodes[2].sendtoaddress, self.nodes[2].getnewaddress(), 20)
|
||||
assert_raises_message(JSONRPCException, "Insufficient funds", self.nodes[2].sendtoaddress, self.nodes[2].getnewaddress(), 200000)
|
||||
assert_equal([unspent_0], self.nodes[2].listlockunspent())
|
||||
self.nodes[2].lockunspent(True, [unspent_0])
|
||||
assert_equal(len(self.nodes[2].listlockunspent()), 0)
|
||||
|
||||
# Have node1 generate 100 blocks (so node0 can recover the fee)
|
||||
self.nodes[1].generate(100)
|
||||
# Have node1 generate 60 blocks (so node0 can recover the fee)
|
||||
self.nodes[1].generate(60)
|
||||
self.sync_all()
|
||||
|
||||
# node0 should end up with 100 btc in block rewards plus fees, but
|
||||
# minus the 21 plus fees sent to node2
|
||||
assert_equal(self.nodes[0].getbalance(), 100-21)
|
||||
assert_equal(self.nodes[2].getbalance(), 21)
|
||||
# node0 should end up with 1.000.000 doge in block rewards plus fees, but
|
||||
# minus the 210.000 plus fees sent to node2
|
||||
assert_equal(self.nodes[0].getbalance(), 1000000-210000)
|
||||
assert_equal(self.nodes[2].getbalance(), 210000)
|
||||
|
||||
# Node0 should have two unspent outputs.
|
||||
# Create a couple of transactions to send them to node2, submit them through
|
||||
|
@ -110,49 +111,49 @@ class WalletTest (BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 0)
|
||||
assert_equal(self.nodes[2].getbalance(), 94)
|
||||
assert_equal(self.nodes[2].getbalance("from1"), 94-21)
|
||||
assert_equal(self.nodes[2].getbalance(), 999994)
|
||||
assert_equal(self.nodes[2].getbalance("from1"), 999994-210000)
|
||||
|
||||
# Send 10 BTC normal
|
||||
# Send 100000 DOGE normal
|
||||
address = self.nodes[0].getnewaddress("test")
|
||||
fee_per_byte = Decimal('0.001') / 1000
|
||||
fee_per_byte = Decimal('1') / 1000
|
||||
self.nodes[2].settxfee(fee_per_byte * 1000)
|
||||
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
|
||||
txid = self.nodes[2].sendtoaddress(address, 100000, "", "", False)
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('84'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
assert_equal(self.nodes[0].getbalance(), Decimal('10'))
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('899994'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
assert_equal(self.nodes[0].getbalance(), Decimal('100000'))
|
||||
|
||||
# Send 10 BTC with subtract fee from amount
|
||||
txid = self.nodes[2].sendtoaddress(address, 10, "", "", True)
|
||||
# Send 100000 DOGE with subtract fee from amount
|
||||
txid = self.nodes[2].sendtoaddress(address, 100000, "", "", True)
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
node_2_bal -= Decimal('10')
|
||||
node_2_bal -= Decimal('100000')
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('20'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('200000'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
|
||||
# Sendmany 10 BTC
|
||||
txid = self.nodes[2].sendmany('from1', {address: 10}, 0, "", [])
|
||||
# Sendmany 100000 DOGE
|
||||
txid = self.nodes[2].sendmany('from1', {address: 100000}, 0, "", [])
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
node_0_bal += Decimal('10')
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('10'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
node_0_bal += Decimal('100000')
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('100000'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
assert_equal(self.nodes[0].getbalance(), node_0_bal)
|
||||
|
||||
# Sendmany 10 BTC with subtract fee from amount
|
||||
txid = self.nodes[2].sendmany('from1', {address: 10}, 0, "", [address])
|
||||
# Sendmany 100000 with subtract fee from amount
|
||||
txid = self.nodes[2].sendmany('from1', {address: 100000}, 0, "", [address])
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
node_2_bal -= Decimal('10')
|
||||
node_2_bal -= Decimal('100000')
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('100000'), fee_per_byte, count_bytes(self.nodes[2].getrawtransaction(txid)))
|
||||
|
||||
# Test ResendWalletTransactions:
|
||||
# Create a couple of transactions, then start up a fourth
|
||||
# node (nodes[3]) and ask nodes[0] to rebroadcast.
|
||||
# EXPECT: nodes[3] should have those transactions in its mempool.
|
||||
txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
|
||||
txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||
txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 100000)
|
||||
txid2 = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 100000)
|
||||
sync_mempools(self.nodes)
|
||||
|
||||
self.nodes.append(start_node(3, self.options.tmpdir, self.extra_args[3]))
|
||||
|
@ -166,8 +167,8 @@ class WalletTest (BitcoinTestFramework):
|
|||
assert(txid1 in self.nodes[3].getrawmempool())
|
||||
|
||||
# Exercise balance rpcs
|
||||
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], 1)
|
||||
assert_equal(self.nodes[0].getunconfirmedbalance(), 1)
|
||||
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], 100000)
|
||||
assert_equal(self.nodes[0].getunconfirmedbalance(), 100000)
|
||||
|
||||
#check if we can list zero value tx as available coins
|
||||
#1. create rawtx
|
||||
|
@ -176,7 +177,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
#4. check if recipient (node0) can list the zero value tx
|
||||
usp = self.nodes[1].listunspent()
|
||||
inputs = [{"txid":usp[0]['txid'], "vout":usp[0]['vout']}]
|
||||
outputs = {self.nodes[1].getnewaddress(): 49.998, self.nodes[0].getnewaddress(): 11.11}
|
||||
outputs = {self.nodes[1].getnewaddress(): 499998, self.nodes[0].getnewaddress(): 11.11}
|
||||
|
||||
rawTx = self.nodes[1].createrawtransaction(inputs, outputs).replace("c0833842", "00000000") #replace 11.11 with 0.0 (int32)
|
||||
decRawTx = self.nodes[1].decoderawtransaction(rawTx)
|
||||
|
@ -205,7 +206,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
connect_nodes_bi(self.nodes,0,2)
|
||||
self.sync_all()
|
||||
|
||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
|
||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 20000)
|
||||
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
||||
self.nodes[1].generate(1) #mine a block, tx should not be in there
|
||||
self.sync_all()
|
||||
|
@ -215,12 +216,12 @@ class WalletTest (BitcoinTestFramework):
|
|||
self.nodes[1].sendrawtransaction(txObjNotBroadcasted['hex'])
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
node_2_bal += 2
|
||||
node_2_bal += 20000
|
||||
txObjNotBroadcasted = self.nodes[0].gettransaction(txIdNotBroadcasted)
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
|
||||
#create another tx
|
||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
|
||||
txIdNotBroadcasted = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 20000)
|
||||
|
||||
#restart the nodes with -walletbroadcast=1
|
||||
stop_nodes(self.nodes)
|
||||
|
@ -232,24 +233,24 @@ class WalletTest (BitcoinTestFramework):
|
|||
|
||||
self.nodes[0].generate(1)
|
||||
sync_blocks(self.nodes)
|
||||
node_2_bal += 2
|
||||
node_2_bal += 20000
|
||||
|
||||
#tx should be added to balance because after restarting the nodes tx should be broadcastet
|
||||
#tx should be added to balance because after restarting the nodes tx should be broadcasted
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
|
||||
#send a tx with value in a string (PR#6380 +)
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "2")
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "20000")
|
||||
txObj = self.nodes[0].gettransaction(txId)
|
||||
assert_equal(txObj['amount'], Decimal('-2'))
|
||||
assert_equal(txObj['amount'], Decimal('-20000'))
|
||||
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "0.0001")
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "1")
|
||||
txObj = self.nodes[0].gettransaction(txId)
|
||||
assert_equal(txObj['amount'], Decimal('-0.0001'))
|
||||
assert_equal(txObj['amount'], Decimal('-1'))
|
||||
|
||||
#check if JSON parser can handle scientific notation in strings
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "1e-4")
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "10000e-4")
|
||||
txObj = self.nodes[0].gettransaction(txId)
|
||||
assert_equal(txObj['amount'], Decimal('-0.0001'))
|
||||
assert_equal(txObj['amount'], Decimal('-1'))
|
||||
|
||||
try:
|
||||
txId = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), "1f-4")
|
||||
|
@ -368,13 +369,13 @@ class WalletTest (BitcoinTestFramework):
|
|||
sending_addr = self.nodes[1].getnewaddress()
|
||||
txid_list = []
|
||||
for i in range(chainlimit*2):
|
||||
txid_list.append(self.nodes[0].sendtoaddress(sending_addr, Decimal('0.0001')))
|
||||
txid_list.append(self.nodes[0].sendtoaddress(sending_addr, Decimal('1')))
|
||||
assert_equal(self.nodes[0].getmempoolinfo()['size'], chainlimit*2)
|
||||
assert_equal(len(txid_list), chainlimit*2)
|
||||
|
||||
# Without walletrejectlongchains, we will still generate a txid
|
||||
# The tx will be stored in the wallet but not accepted to the mempool
|
||||
extra_txid = self.nodes[0].sendtoaddress(sending_addr, Decimal('0.0001'))
|
||||
extra_txid = self.nodes[0].sendtoaddress(sending_addr, Decimal('1'))
|
||||
assert(extra_txid not in self.nodes[0].getrawmempool())
|
||||
assert(extra_txid in [tx["txid"] for tx in self.nodes[0].listtransactions()])
|
||||
self.nodes[0].abandontransaction(extra_txid)
|
||||
|
@ -394,7 +395,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
|
||||
node0_balance = self.nodes[0].getbalance()
|
||||
# With walletrejectlongchains we will not create the tx and store it in our wallet.
|
||||
assert_raises_message(JSONRPCException, "mempool chain", self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('0.01'))
|
||||
assert_raises_message(JSONRPCException, "mempool chain", self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('1'))
|
||||
|
||||
# Verify nothing new in wallet
|
||||
assert_equal(total_txs, len(self.nodes[0].listtransactions("*",99999)))
|
||||
|
|
|
@ -60,7 +60,7 @@ class WalletBackupTest(BitcoinTestFramework):
|
|||
|
||||
def one_send(self, from_node, to_address):
|
||||
if (randint(1,2) == 1):
|
||||
amount = Decimal(randint(1,10)) / Decimal(10)
|
||||
amount = Decimal(randint(1,10))
|
||||
self.nodes[from_node].sendtoaddress(to_address, amount)
|
||||
|
||||
def do_one_round(self):
|
||||
|
@ -109,12 +109,12 @@ class WalletBackupTest(BitcoinTestFramework):
|
|||
sync_blocks(self.nodes)
|
||||
self.nodes[2].generate(1)
|
||||
sync_blocks(self.nodes)
|
||||
self.nodes[3].generate(100)
|
||||
self.nodes[3].generate(60)
|
||||
sync_blocks(self.nodes)
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 50)
|
||||
assert_equal(self.nodes[1].getbalance(), 50)
|
||||
assert_equal(self.nodes[2].getbalance(), 50)
|
||||
assert_equal(self.nodes[0].getbalance(), 500000)
|
||||
assert_equal(self.nodes[1].getbalance(), 500000)
|
||||
assert_equal(self.nodes[2].getbalance(), 500000)
|
||||
assert_equal(self.nodes[3].getbalance(), 0)
|
||||
|
||||
logging.info("Creating transactions")
|
||||
|
@ -135,8 +135,8 @@ class WalletBackupTest(BitcoinTestFramework):
|
|||
for i in range(5):
|
||||
self.do_one_round()
|
||||
|
||||
# Generate 101 more blocks, so any fees paid mature
|
||||
self.nodes[3].generate(101)
|
||||
# Generate 61 more blocks, so any fees paid mature
|
||||
self.nodes[3].generate(61)
|
||||
self.sync_all()
|
||||
|
||||
balance0 = self.nodes[0].getbalance()
|
||||
|
@ -145,9 +145,9 @@ class WalletBackupTest(BitcoinTestFramework):
|
|||
balance3 = self.nodes[3].getbalance()
|
||||
total = balance0 + balance1 + balance2 + balance3
|
||||
|
||||
# At this point, there are 214 blocks (103 for setup, then 10 rounds, then 101.)
|
||||
# 114 are mature, so the sum of all wallets should be 114 * 50 = 5700.
|
||||
assert_equal(total, 5700)
|
||||
# At this point, there are 134 blocks (63 for setup, then 10 rounds, then 61.)
|
||||
# 74 are mature, so the sum of all wallets should be 74 * 500000 = 37000000.
|
||||
assert_equal(total, 37000000)
|
||||
|
||||
##
|
||||
# Test restoring spender wallets from backups
|
||||
|
|
|
@ -26,10 +26,10 @@ class ZapWalletTXesTest (BitcoinTestFramework):
|
|||
print("Mining blocks...")
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(101)
|
||||
self.nodes[1].generate(61)
|
||||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 50)
|
||||
assert_equal(self.nodes[0].getbalance(), 500000)
|
||||
|
||||
txid0 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
|
||||
txid1 = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
|
||||
|
|
|
@ -369,6 +369,7 @@ public:
|
|||
consensus.powLimit = uint256S("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1;
|
||||
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
|
||||
consensus.nPowTargetSpacing = 1; // regtest: 1 second blocks
|
||||
consensus.fDigishieldDifficultyCalculation = false;
|
||||
consensus.fPowAllowMinDifficultyBlocks = true;
|
||||
consensus.fPowNoRetargeting = true;
|
||||
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
|
||||
|
|
|
@ -124,16 +124,17 @@ UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nG
|
|||
LOCK(cs_main);
|
||||
IncrementExtraNonce(pblock, chainActive.Tip(), nExtraNonce);
|
||||
}
|
||||
CAuxPow::initAuxPow(*pblock);
|
||||
CPureBlockHeader& miningHeader = pblock->auxpow->parentBlock;
|
||||
while (nMaxTries > 0 && miningHeader.nNonce < nInnerLoopCount && !CheckProofOfWork(miningHeader.GetHash(), pblock->nBits, Params().GetConsensus(nHeight))) {
|
||||
++miningHeader.nNonce;
|
||||
// Dogecoin: Don't mine Aux blocks in regtest
|
||||
//CAuxPow::initAuxPow(*pblock);
|
||||
//CPureBlockHeader& miningHeader = pblock->auxpow->parentBlock;
|
||||
while (nMaxTries > 0 && pblock->nNonce < nInnerLoopCount && !CheckProofOfWork(pblock->GetPoWHash(), pblock->nBits, Params().GetConsensus(nHeight))) {
|
||||
++pblock->nNonce;
|
||||
--nMaxTries;
|
||||
}
|
||||
if (nMaxTries == 0) {
|
||||
break;
|
||||
}
|
||||
if (miningHeader.nNonce == nInnerLoopCount) {
|
||||
if (pblock->nNonce == nInnerLoopCount) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
|
||||
|
|
Loading…
Reference in a new issue