mirror of https://github.com/zcash/zcash.git
test: Update RPC tests to use a minimum of Sapling
The p2p_nu_peer_management and rewind_index RPC tests still start from Sprout, because they are explicitly (and only) testing network behaviour across network upgrades. The mempool_tx_input_limit test is removed because the flag has been ignored since Sapling activation, and will be removed at some point in the near future.
This commit is contained in:
parent
d7d4dd8a0f
commit
8669cb692d
|
@ -43,7 +43,6 @@ testScripts=(
|
|||
'rest.py'
|
||||
'mempool_spendcoinbase.py'
|
||||
'mempool_reorg.py'
|
||||
'mempool_tx_input_limit.py'
|
||||
'mempool_nu_activation.py'
|
||||
'mempool_tx_expiry.py'
|
||||
'httpbasics.py'
|
||||
|
|
|
@ -66,7 +66,9 @@ class BIP65Test(ComparisonTestFramework):
|
|||
def get_tests(self):
|
||||
self.coinbase_blocks = self.nodes[0].generate(1)
|
||||
self.nodes[0].generate(100)
|
||||
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
|
||||
hashTip = self.nodes[0].getbestblockhash()
|
||||
hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'] + "L", 0)
|
||||
self.tip = int ("0x" + hashTip + "L", 0)
|
||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||
|
||||
'''Check that the rules are enforced.'''
|
||||
|
@ -83,7 +85,8 @@ class BIP65Test(ComparisonTestFramework):
|
|||
self.block_bits = int("0x" + gbt["bits"], 0)
|
||||
|
||||
block = create_block(self.tip, create_coinbase(101),
|
||||
self.block_time, self.block_bits)
|
||||
self.block_time, self.block_bits,
|
||||
hashFinalSaplingRoot)
|
||||
block.nVersion = 4
|
||||
block.vtx.append(spendtx)
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
|
|
|
@ -73,7 +73,9 @@ class BIP66Test(ComparisonTestFramework):
|
|||
def get_tests(self):
|
||||
self.coinbase_blocks = self.nodes[0].generate(1)
|
||||
self.nodes[0].generate(100)
|
||||
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
|
||||
hashTip = self.nodes[0].getbestblockhash()
|
||||
hashFinalSaplingRoot = int("0x" + self.nodes[0].getblock(hashTip)['finalsaplingroot'] + "L", 0)
|
||||
self.tip = int ("0x" + hashTip + "L", 0)
|
||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||
|
||||
'''Check that the rules are enforced.'''
|
||||
|
@ -90,7 +92,8 @@ class BIP66Test(ComparisonTestFramework):
|
|||
self.block_bits = int("0x" + gbt["bits"], 0)
|
||||
|
||||
block = create_block(self.tip, create_coinbase(101),
|
||||
self.block_time, self.block_bits)
|
||||
self.block_time, self.block_bits,
|
||||
hashFinalSaplingRoot)
|
||||
block.nVersion = 4
|
||||
block.vtx.append(spendtx)
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
|
|
|
@ -30,8 +30,6 @@ class FinalSaplingRootTest(BitcoinTestFramework):
|
|||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[[
|
||||
'-nuparams=5ba81b19:100', # Overwinter
|
||||
'-nuparams=76b809bb:200', # Sapling
|
||||
'-txindex' # Avoid JSONRPC error: No information available about transaction
|
||||
]] * 4 )
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
|
@ -42,7 +40,6 @@ class FinalSaplingRootTest(BitcoinTestFramework):
|
|||
self.sync_all()
|
||||
|
||||
def run_test(self):
|
||||
# Activate Overwinter and Sapling
|
||||
self.nodes[0].generate(200)
|
||||
self.sync_all()
|
||||
|
||||
|
|
|
@ -180,8 +180,8 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
outputs = { self.nodes[0].getnewaddress() : 1.0 }
|
||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
|
||||
# 4-byte version + 1-byte vin count + 36-byte prevout then script_len
|
||||
rawtx = rawtx[:82] + "0100" + rawtx[84:]
|
||||
# 4-byte version + 4-byte versionGroupId + 1-byte vin count + 36-byte prevout then script_len
|
||||
rawtx = rawtx[:90] + "0100" + rawtx[92:]
|
||||
|
||||
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
|
||||
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])
|
||||
|
|
|
@ -11,7 +11,6 @@ from test_framework.util import (
|
|||
start_node, connect_nodes, wait_and_assert_operationid_status,
|
||||
get_coinbase_address
|
||||
)
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
|
@ -22,9 +21,7 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
|
||||
def setup_network(self):
|
||||
args = ["-checkmempool", "-debug=mempool", "-blockmaxsize=4000",
|
||||
"-nuparams=5ba81b19:200", # Overwinter
|
||||
"-nuparams=76b809bb:210", # Sapling
|
||||
"-nuparams=2bb40e60:220", # Blossom
|
||||
"-nuparams=2bb40e60:200", # Blossom
|
||||
]
|
||||
self.nodes = []
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, args))
|
||||
|
@ -43,23 +40,24 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
|
||||
# Mine 97 blocks. After this, nodes[1] blocks
|
||||
# 1 to 97 are spend-able.
|
||||
self.nodes[0].generate(97)
|
||||
self.nodes[0].generate(94)
|
||||
self.sync_all()
|
||||
|
||||
# Shield some ZEC
|
||||
node1_taddr = get_coinbase_address(self.nodes[1])
|
||||
node0_zaddr = self.nodes[0].z_getnewaddress('sprout')
|
||||
node0_zaddr = self.nodes[0].z_getnewaddress('sapling')
|
||||
recipients = [{'address': node0_zaddr, 'amount': Decimal('10')}]
|
||||
myopid = self.nodes[1].z_sendmany(node1_taddr, recipients, 1, Decimal('0'))
|
||||
print wait_and_assert_operationid_status(self.nodes[1], myopid)
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Mempool checks for activation of upgrade Y at height H on base X
|
||||
def nu_activation_checks():
|
||||
# Mine block H - 2. After this, the mempool expects
|
||||
# block H - 1, which is the last X block.
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
# Start at block H - 5. After this, the mempool expects block H - 4, which is
|
||||
# the last height at which we can create transactions for X blocks (due to the
|
||||
# expiring-soon restrictions).
|
||||
|
||||
# Mempool should be empty.
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
|
@ -67,39 +65,64 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
# Check node 0 shielded balance
|
||||
assert_equal(self.nodes[0].z_getbalance(node0_zaddr), Decimal('10'))
|
||||
|
||||
# Fill the mempool with twice as many transactions as can fit into blocks
|
||||
# Fill the mempool with more transactions than can fit into 4 blocks
|
||||
node0_taddr = self.nodes[0].getnewaddress()
|
||||
x_txids = []
|
||||
info = self.nodes[0].getblockchaininfo()
|
||||
chaintip_branchid = info["consensus"]["chaintip"]
|
||||
while self.nodes[1].getmempoolinfo()['bytes'] < 2 * 4000:
|
||||
try:
|
||||
x_txids.append(self.nodes[1].sendtoaddress(node0_taddr, Decimal('0.001')))
|
||||
except JSONRPCException:
|
||||
# This fails due to expiring soon threshold, which applies from Overwinter onwards.
|
||||
upgrade_name = info["upgrades"][chaintip_branchid]["name"]
|
||||
assert_true(upgrade_name in ("Overwinter", "Sapling"), upgrade_name)
|
||||
break
|
||||
while self.nodes[1].getmempoolinfo()['bytes'] < 8 * 4000:
|
||||
x_txids.append(self.nodes[1].sendtoaddress(node0_taddr, Decimal('0.001')))
|
||||
self.sync_all()
|
||||
|
||||
# Spends should be in the mempool
|
||||
x_mempool = set(self.nodes[0].getrawmempool())
|
||||
assert_equal(x_mempool, set(x_txids))
|
||||
assert_equal(set(self.nodes[1].getrawmempool()), set(x_txids))
|
||||
|
||||
blocks = []
|
||||
|
||||
# Mine block H - 4. After this, the mempool expects
|
||||
# block H - 3, which is an X block.
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx'])
|
||||
|
||||
# mempool should not be empty.
|
||||
assert_true(len(set(self.nodes[0].getrawmempool())) > 0)
|
||||
assert_true(len(set(self.nodes[1].getrawmempool())) > 0)
|
||||
|
||||
# Mine block H - 3. After this, the mempool expects
|
||||
# block H - 2, which is an X block.
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx'])
|
||||
|
||||
# mempool should not be empty.
|
||||
assert_true(len(set(self.nodes[0].getrawmempool())) > 0)
|
||||
assert_true(len(set(self.nodes[1].getrawmempool())) > 0)
|
||||
|
||||
# Mine block H - 2. After this, the mempool expects
|
||||
# block H - 1, which is an X block.
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx'])
|
||||
|
||||
# mempool should not be empty.
|
||||
assert_true(len(set(self.nodes[0].getrawmempool())) > 0)
|
||||
assert_true(len(set(self.nodes[1].getrawmempool())) > 0)
|
||||
|
||||
# Mine block H - 1. After this, the mempool expects
|
||||
# block H, which is the first Y block.
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
blocks.append(self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx'])
|
||||
|
||||
# mempool should be empty.
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
assert_equal(set(self.nodes[1].getrawmempool()), set())
|
||||
|
||||
# When transitioning from Sprout to Overwinter, where expiring soon threshold does not apply:
|
||||
# Block H - 1 should contain a subset of the original mempool
|
||||
# Blocks [H - 4..H - 1] should contain a subset of the original mempool
|
||||
# (with all other transactions having been dropped)
|
||||
block_txids = self.nodes[0].getblock(self.nodes[0].getbestblockhash())['tx']
|
||||
if chaintip_branchid is "00000000":
|
||||
assert(len(block_txids) < len(x_txids))
|
||||
assert(sum([len(block_txids) for block_txids in blocks]) < len(x_txids))
|
||||
for block_txids in blocks:
|
||||
for txid in block_txids[1:]: # Exclude coinbase
|
||||
assert(txid in x_txids)
|
||||
|
||||
|
@ -117,6 +140,7 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
|
||||
# Spends should be in the mempool
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set(y_txids))
|
||||
assert_equal(set(self.nodes[1].getrawmempool()), set(y_txids))
|
||||
|
||||
# Node 0 note should be unspendable
|
||||
assert_equal(self.nodes[0].z_getbalance(node0_zaddr), Decimal('0'))
|
||||
|
@ -135,6 +159,9 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
#assert_equal(set(self.nodes[0].getrawmempool()), set(block_txids[1:]))
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
|
||||
# Node 1's mempool is unaffected because it still considers block H - 1 valid.
|
||||
assert_equal(set(self.nodes[1].getrawmempool()), set(y_txids))
|
||||
|
||||
# Node 0 note should be spendable again
|
||||
assert_equal(self.nodes[0].z_getbalance(node0_zaddr), Decimal('10'))
|
||||
|
||||
|
@ -146,26 +173,10 @@ class MempoolUpgradeActivationTest(BitcoinTestFramework):
|
|||
self.nodes[1].generate(6)
|
||||
self.sync_all()
|
||||
|
||||
print('Testing Sprout -> Overwinter activation boundary')
|
||||
# Current height = 197
|
||||
print('Testing Sapling -> Blossom activation boundary')
|
||||
# Current height = 195
|
||||
nu_activation_checks()
|
||||
# Current height = 205
|
||||
|
||||
self.nodes[0].generate(2)
|
||||
self.sync_all()
|
||||
|
||||
print('Testing Overwinter -> Sapling activation boundary')
|
||||
# Current height = 207
|
||||
nu_activation_checks()
|
||||
# Current height = 215
|
||||
|
||||
self.nodes[0].generate(2)
|
||||
self.sync_all()
|
||||
|
||||
print('Testing Sapling -> Blossom activation boundary')
|
||||
# Current height = 217
|
||||
nu_activation_checks()
|
||||
# Current height = 225
|
||||
|
||||
if __name__ == '__main__':
|
||||
MempoolUpgradeActivationTest().main()
|
||||
|
|
|
@ -60,9 +60,9 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
|
|||
|
||||
# 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: 10})
|
||||
# Set the time lock
|
||||
# Set the time lock, ensuring we don't clobber the rest of the Sapling v4 tx format
|
||||
timelock_tx = timelock_tx.replace("ffffffff", "11111111", 1)
|
||||
timelock_tx = timelock_tx[:-8] + hex(self.nodes[0].getblockcount() + 2)[2:] + "000000"
|
||||
timelock_tx = timelock_tx[:-38] + hex(self.nodes[0].getblockcount() + 2)[2:] + "000000" + timelock_tx[-30:]
|
||||
timelock_tx = self.nodes[0].signrawtransaction(timelock_tx)["hex"]
|
||||
assert_raises(JSONRPCException, self.nodes[0].sendrawtransaction, timelock_tx)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
#
|
||||
# Test proper expiry for transactions >= version 3
|
||||
# Test proper expiry for transactions >= version 4
|
||||
#
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
@ -17,7 +17,6 @@ from test_framework.util import assert_equal, \
|
|||
|
||||
from decimal import Decimal
|
||||
|
||||
SAPLING_ACTIVATION_HEIGHT = 300
|
||||
TX_EXPIRING_SOON_THRESHOLD = 3
|
||||
TX_EXPIRY_DELTA = 10
|
||||
|
||||
|
@ -26,8 +25,6 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir,
|
||||
[[
|
||||
"-nuparams=5ba81b19:205", # Overwinter
|
||||
"-nuparams=76b809bb:%d" % SAPLING_ACTIVATION_HEIGHT, # Sapling
|
||||
"-txexpirydelta=%d" % TX_EXPIRY_DELTA,
|
||||
"-debug=mempool"
|
||||
]] * 4)
|
||||
|
@ -40,22 +37,13 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
bob = self.nodes[2].getnewaddress()
|
||||
z_bob = self.nodes[2].z_getnewaddress('sapling')
|
||||
|
||||
# When Overwinter not yet activated, no expiryheight in tx
|
||||
tx = self.nodes[0].sendtoaddress(bob, 0.01)
|
||||
rawtx = self.nodes[0].getrawtransaction(tx, 1)
|
||||
assert_equal(rawtx["overwintered"], False)
|
||||
assert("expiryheight" not in rawtx)
|
||||
|
||||
self.nodes[0].generate(6)
|
||||
self.sync_all()
|
||||
|
||||
print "Splitting network..."
|
||||
self.split_network()
|
||||
|
||||
# When Overwinter is activated, test dependent txs
|
||||
# Test dependent txs
|
||||
firstTx = self.nodes[0].sendtoaddress(alice, 0.1)
|
||||
firstTxInfo = self.nodes[0].getrawtransaction(firstTx, 1)
|
||||
assert_equal(firstTxInfo["version"], 3)
|
||||
assert_equal(firstTxInfo["version"], 4)
|
||||
assert_equal(firstTxInfo["overwintered"], True)
|
||||
assert("expiryheight" in firstTxInfo)
|
||||
print "First tx expiry height:", firstTxInfo['expiryheight']
|
||||
|
@ -88,12 +76,6 @@ class MempoolTxExpiryTest(BitcoinTestFramework):
|
|||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
assert_equal(set(self.nodes[2].getrawmempool()), set())
|
||||
|
||||
# Activate Sapling
|
||||
n = SAPLING_ACTIVATION_HEIGHT - self.nodes[0].getblockcount()
|
||||
assert(n > 0)
|
||||
self.nodes[0].generate(n)
|
||||
self.sync_all()
|
||||
|
||||
## Shield one of Alice's coinbase funds to her zaddr
|
||||
res = self.nodes[0].z_shieldcoinbase("*", z_alice, 0.0001, 1)
|
||||
wait_and_assert_operationid_status(self.nodes[0], res['opid'])
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright (c) 2017 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_node, connect_nodes, wait_and_assert_operationid_status, \
|
||||
get_coinbase_address
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
# Test -mempooltxinputlimit
|
||||
class MempoolTxInputLimitTest(BitcoinTestFramework):
|
||||
|
||||
alert_filename = None # Set by setup_network
|
||||
|
||||
def setup_network(self):
|
||||
args = ["-checkmempool", "-debug=mempool", "-mempooltxinputlimit=2", "-nuparams=5ba81b19:110"]
|
||||
self.nodes = []
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, args))
|
||||
self.nodes.append(start_node(1, self.options.tmpdir, args))
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
self.is_network_split = False
|
||||
self.sync_all
|
||||
|
||||
def setup_chain(self):
|
||||
print "Initializing test directory "+self.options.tmpdir
|
||||
initialize_chain_clean(self.options.tmpdir, 2)
|
||||
|
||||
def call_z_sendmany(self, from_addr, to_addr, amount):
|
||||
recipients = []
|
||||
recipients.append({"address": to_addr, "amount": amount})
|
||||
myopid = self.nodes[0].z_sendmany(from_addr, recipients)
|
||||
return wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
def run_test(self):
|
||||
self.nodes[0].generate(100)
|
||||
self.sync_all()
|
||||
# Mine three blocks. After this, nodes[0] blocks
|
||||
# 1, 2, and 3 are spend-able.
|
||||
self.nodes[1].generate(3)
|
||||
self.sync_all()
|
||||
|
||||
# Check 1: z_sendmany is limited by -mempooltxinputlimit
|
||||
|
||||
# Add zaddr to node 0
|
||||
node0_zaddr = self.nodes[0].z_getnewaddress('sprout')
|
||||
|
||||
# Send three inputs from node 0 taddr to zaddr to get out of coinbase
|
||||
node0_taddr = get_coinbase_address(self.nodes[0])
|
||||
recipients = []
|
||||
recipients.append({"address":node0_zaddr, "amount":Decimal('30.0')-Decimal('0.0001')}) # utxo amount less fee
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients)
|
||||
|
||||
# Spend should fail due to -mempooltxinputlimit
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid, "failed", "Too many transparent inputs 3 > limit 2", 120)
|
||||
|
||||
# Mempool should be empty.
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
|
||||
# Reduce amount to only use two inputs
|
||||
spend_zaddr_amount = Decimal('20.0') - Decimal('0.0001')
|
||||
spend_zaddr_id = self.call_z_sendmany(node0_taddr, node0_zaddr, spend_zaddr_amount) # utxo amount less fee
|
||||
self.sync_all()
|
||||
|
||||
# Spend should be in the mempool
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set([ spend_zaddr_id ]))
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# mempool should be empty.
|
||||
assert_equal(set(self.nodes[0].getrawmempool()), set())
|
||||
|
||||
# Check 2: sendfrom is limited by -mempooltxinputlimit
|
||||
recipients = []
|
||||
spend_taddr_amount = spend_zaddr_amount - Decimal('0.0001')
|
||||
spend_taddr_output = Decimal('8')
|
||||
|
||||
# Create three outputs
|
||||
recipients.append({"address":self.nodes[1].getnewaddress(), "amount": spend_taddr_output})
|
||||
recipients.append({"address":self.nodes[1].getnewaddress(), "amount": spend_taddr_output})
|
||||
recipients.append({"address":self.nodes[1].getnewaddress(), "amount": spend_taddr_amount - spend_taddr_output - spend_taddr_output})
|
||||
|
||||
myopid = self.nodes[0].z_sendmany(node0_zaddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Should use three UTXOs and fail
|
||||
try:
|
||||
self.nodes[1].sendfrom("", node0_taddr, spend_taddr_amount - Decimal('1'))
|
||||
assert(False)
|
||||
except JSONRPCException,e:
|
||||
msg = e.error['message']
|
||||
assert_equal("Too many transparent inputs 3 > limit 2", msg)
|
||||
|
||||
# mempool should be empty.
|
||||
assert_equal(set(self.nodes[1].getrawmempool()), set())
|
||||
|
||||
# Should use two UTXOs and succeed
|
||||
spend_taddr_id2 = self.nodes[1].sendfrom("", node0_taddr, spend_taddr_output + spend_taddr_output - Decimal('1'))
|
||||
|
||||
# Spend should be in the mempool
|
||||
assert_equal(set(self.nodes[1].getrawmempool()), set([ spend_taddr_id2 ]))
|
||||
|
||||
# Mine three blocks
|
||||
self.nodes[1].generate(3)
|
||||
self.sync_all()
|
||||
# The next block to be mined, 109, is the last Sprout block
|
||||
bci = self.nodes[0].getblockchaininfo()
|
||||
assert_equal(bci['consensus']['chaintip'], '00000000')
|
||||
assert_equal(bci['consensus']['nextblock'], '00000000')
|
||||
|
||||
# z_sendmany should be limited by -mempooltxinputlimit
|
||||
recipients = []
|
||||
recipients.append({"address":node0_zaddr, "amount":Decimal('30.0')-Decimal('0.0001')}) # utxo amount less fee
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid, 'failed', 'Too many transparent inputs 3 > limit 2')
|
||||
|
||||
# Mine one block
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
# The next block to be mined, 110, is the first Overwinter block
|
||||
bci = self.nodes[0].getblockchaininfo()
|
||||
assert_equal(bci['consensus']['chaintip'], '00000000')
|
||||
assert_equal(bci['consensus']['nextblock'], '5ba81b19')
|
||||
|
||||
# z_sendmany should no longer be limited by -mempooltxinputlimit
|
||||
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients)
|
||||
wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
if __name__ == '__main__':
|
||||
MempoolTxInputLimitTest().main()
|
|
@ -27,7 +27,7 @@ def assert_mergetoaddress_exception(expected_error_msg, merge_to_address_lambda)
|
|||
|
||||
class MergeToAddressHelper:
|
||||
|
||||
def __init__(self, addr_type, any_zaddr, utxos_to_generate, utxos_in_tx1, utxos_in_tx2, test_mempooltxinputlimit):
|
||||
def __init__(self, addr_type, any_zaddr, utxos_to_generate, utxos_in_tx1, utxos_in_tx2):
|
||||
self.addr_type = addr_type
|
||||
self.any_zaddr = [any_zaddr]
|
||||
self.any_zaddr_or_utxo = [any_zaddr, "ANY_TADDR"]
|
||||
|
@ -35,7 +35,6 @@ class MergeToAddressHelper:
|
|||
self.utxos_to_generate = utxos_to_generate
|
||||
self.utxos_in_tx1 = utxos_in_tx1
|
||||
self.utxos_in_tx2 = utxos_in_tx2
|
||||
self.test_mempooltxinputlimit = test_mempooltxinputlimit
|
||||
|
||||
def setup_chain(self, test):
|
||||
print("Initializing test directory "+test.options.tmpdir)
|
||||
|
@ -282,16 +281,10 @@ class MergeToAddressHelper:
|
|||
test.nodes[1].generate(1)
|
||||
test.sync_all()
|
||||
|
||||
# Verify maximum number of UTXOs which node 2 can shield is limited by option -mempooltxinputlimit
|
||||
# This option is used when the limit parameter is set to 0.
|
||||
|
||||
# -mempooltxinputlimit is not used after overwinter activation
|
||||
if self.test_mempooltxinputlimit:
|
||||
expected_to_merge = 7
|
||||
expected_remaining = 13
|
||||
else:
|
||||
expected_to_merge = 20
|
||||
expected_remaining = 0
|
||||
# Verify maximum number of UTXOs which node 2 can shield is not limited
|
||||
# when the limit parameter is set to 0.
|
||||
expected_to_merge = 20
|
||||
expected_remaining = 0
|
||||
|
||||
result = test.nodes[2].z_mergetoaddress([n2taddr], myzaddr, Decimal('0.0001'), 0)
|
||||
assert_equal(result["mergingUTXOs"], expected_to_merge)
|
||||
|
|
|
@ -15,8 +15,6 @@ from mergetoaddress_helper import assert_mergetoaddress_exception
|
|||
class MergeToAddressMixedNotes(BitcoinTestFramework):
|
||||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir, [[
|
||||
'-nuparams=5ba81b19:100', # Overwinter
|
||||
'-nuparams=76b809bb:100', # Sapling
|
||||
'-experimentalfeatures', '-zmergetoaddress'
|
||||
]] * 4)
|
||||
|
||||
|
|
|
@ -12,16 +12,13 @@ from mergetoaddress_helper import MergeToAddressHelper
|
|||
class MergeToAddressSapling (BitcoinTestFramework):
|
||||
# 13505 would be the maximum number of utxos based on the transaction size limits for Sapling
|
||||
# but testing this causes the test to take an indeterminately long time to run.
|
||||
helper = MergeToAddressHelper('sapling', 'ANY_SAPLING', 800, 800, 0, False)
|
||||
helper = MergeToAddressHelper('sapling', 'ANY_SAPLING', 800, 800, 0)
|
||||
|
||||
def setup_chain(self):
|
||||
self.helper.setup_chain(self)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.helper.setup_network(self, [
|
||||
'-nuparams=5ba81b19:100', # Overwinter
|
||||
'-nuparams=76b809bb:100', # Sapling
|
||||
])
|
||||
self.helper.setup_network(self)
|
||||
|
||||
def run_test(self):
|
||||
self.helper.run_test(self)
|
||||
|
|
|
@ -10,7 +10,9 @@ from mergetoaddress_helper import MergeToAddressHelper
|
|||
|
||||
|
||||
class MergeToAddressSprout (BitcoinTestFramework):
|
||||
helper = MergeToAddressHelper('sprout', 'ANY_SPROUT', 800, 662, 138, True)
|
||||
# 13505 would be the maximum number of utxos based on the transaction size limits for Sapling
|
||||
# but testing this causes the test to take an indeterminately long time to run.
|
||||
helper = MergeToAddressHelper('sprout', 'ANY_SPROUT', 800, 800, 0)
|
||||
|
||||
def setup_chain(self):
|
||||
self.helper.setup_chain(self)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \
|
||||
msg_filteradd, msg_filterclear, mininode_lock, SPROUT_PROTO_VERSION
|
||||
msg_filteradd, msg_filterclear, mininode_lock, SAPLING_PROTO_VERSION
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import initialize_chain_clean, start_nodes, \
|
||||
p2p_port, assert_equal
|
||||
|
@ -74,10 +74,10 @@ class NodeBloomTest(BitcoinTestFramework):
|
|||
# Verify mininodes are connected to zcashd nodes
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
peerinfo = self.nodes[1].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
# Mininodes send filterclear message to zcashd node.
|
||||
nobf_node.send_message(msg_filterclear())
|
||||
|
@ -88,10 +88,10 @@ class NodeBloomTest(BitcoinTestFramework):
|
|||
# Verify mininodes are still connected to zcashd nodes
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
peerinfo = self.nodes[1].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
# Mininodes send filteradd message to zcashd node.
|
||||
nobf_node.send_message(msg_filteradd())
|
||||
|
@ -102,10 +102,10 @@ class NodeBloomTest(BitcoinTestFramework):
|
|||
# Verify NoBF mininode has been dropped, and BF mininode is still connected.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(0, versions.count(SAPLING_PROTO_VERSION))
|
||||
peerinfo = self.nodes[1].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(SPROUT_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
|
||||
[ c.disconnect_node() for c in connections ]
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import sys; assert sys.version_info < (3,), ur"This script does not run under Py
|
|||
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.mininode import NodeConn, NetworkThread, CInv, \
|
||||
msg_mempool, msg_getdata, msg_tx, mininode_lock, OVERWINTER_PROTO_VERSION
|
||||
msg_mempool, msg_getdata, msg_tx, mininode_lock, SAPLING_PROTO_VERSION
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, connect_nodes_bi, fail, \
|
||||
initialize_chain_clean, p2p_port, start_nodes, sync_blocks, sync_mempools
|
||||
|
@ -23,8 +23,7 @@ class TxExpiringSoonTest(BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 3)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = start_nodes(3, self.options.tmpdir,
|
||||
extra_args=[['-nuparams=5ba81b19:10']] * 3)
|
||||
self.nodes = start_nodes(3, self.options.tmpdir)
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
# We don't connect node 2
|
||||
|
||||
|
@ -85,7 +84,7 @@ class TxExpiringSoonTest(BitcoinTestFramework):
|
|||
testnode0 = TestNode()
|
||||
connections = []
|
||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
testnode0, "regtest", OVERWINTER_PROTO_VERSION))
|
||||
testnode0, "regtest", SAPLING_PROTO_VERSION))
|
||||
testnode0.add_connection(connections[0])
|
||||
|
||||
# Start up network handling in another thread
|
||||
|
@ -95,7 +94,7 @@ class TxExpiringSoonTest(BitcoinTestFramework):
|
|||
# Verify mininodes are connected to zcashd nodes
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
assert_equal(0, peerinfo[0]["banscore"])
|
||||
|
||||
# Mine some blocks so we can spend
|
||||
|
@ -150,7 +149,7 @@ class TxExpiringSoonTest(BitcoinTestFramework):
|
|||
# Set up test node for node 2
|
||||
testnode2 = TestNode()
|
||||
connections.append(NodeConn('127.0.0.1', p2p_port(2), self.nodes[2],
|
||||
testnode2, "regtest", OVERWINTER_PROTO_VERSION))
|
||||
testnode2, "regtest", SAPLING_PROTO_VERSION))
|
||||
testnode2.add_connection(connections[-1])
|
||||
|
||||
# Verify block count
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.mininode import NodeConn, NetworkThread, \
|
||||
msg_tx, OVERWINTER_PROTO_VERSION
|
||||
msg_tx, SAPLING_PROTO_VERSION
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import initialize_chain_clean, start_nodes, \
|
||||
p2p_port, assert_equal
|
||||
|
@ -22,15 +22,14 @@ class TxExpiryDoSTest(BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 1)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = start_nodes(1, self.options.tmpdir,
|
||||
extra_args=[['-nuparams=5ba81b19:10']])
|
||||
self.nodes = start_nodes(1, self.options.tmpdir)
|
||||
|
||||
def run_test(self):
|
||||
test_node = TestNode()
|
||||
|
||||
connections = []
|
||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
||||
test_node, "regtest", OVERWINTER_PROTO_VERSION))
|
||||
test_node, "regtest", SAPLING_PROTO_VERSION))
|
||||
test_node.add_connection(connections[0])
|
||||
|
||||
# Start up network handling in another thread
|
||||
|
@ -41,7 +40,7 @@ class TxExpiryDoSTest(BitcoinTestFramework):
|
|||
# Verify mininodes are connected to zcashd nodes
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
assert_equal(0, peerinfo[0]["banscore"])
|
||||
|
||||
coinbase_blocks = self.nodes[0].generate(1)
|
||||
|
@ -62,7 +61,7 @@ class TxExpiryDoSTest(BitcoinTestFramework):
|
|||
# and still has a banscore of 0.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
assert_equal(0, peerinfo[0]["banscore"])
|
||||
|
||||
# Mine a block and resend the transaction
|
||||
|
@ -75,7 +74,7 @@ class TxExpiryDoSTest(BitcoinTestFramework):
|
|||
# but has a banscore of 10.
|
||||
peerinfo = self.nodes[0].getpeerinfo()
|
||||
versions = [x["version"] for x in peerinfo]
|
||||
assert_equal(1, versions.count(OVERWINTER_PROTO_VERSION))
|
||||
assert_equal(1, versions.count(SAPLING_PROTO_VERSION))
|
||||
assert_equal(10, peerinfo[0]["banscore"])
|
||||
|
||||
[c.disconnect_node() for c in connections]
|
||||
|
|
|
@ -132,7 +132,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
break;
|
||||
|
||||
bal = self.nodes[0].getbalance()
|
||||
inputs = [{ "txid" : txId, "vout" : vout['n'], "scriptPubKey" : vout['scriptPubKey']['hex']}]
|
||||
inputs = [{ "txid" : txId, "vout" : vout['n'], "scriptPubKey" : vout['scriptPubKey']['hex'], "amount" : vout['value']}]
|
||||
outputs = { self.nodes[0].getnewaddress() : 2.199 }
|
||||
rawTx = self.nodes[2].createrawtransaction(inputs, outputs)
|
||||
rawTxPartialSigned = self.nodes[1].signrawtransaction(rawTx, inputs)
|
||||
|
|
|
@ -6,16 +6,10 @@
|
|||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import start_nodes, wait_and_assert_operationid_status
|
||||
from test_framework.util import wait_and_assert_operationid_status
|
||||
|
||||
class RegtestSignrawtransactionTest (BitcoinTestFramework):
|
||||
|
||||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir, [[
|
||||
"-nuparams=5ba81b19:200", # Overwinter
|
||||
"-nuparams=76b809bb:206", # Sapling
|
||||
]] * 4)
|
||||
|
||||
def run_test(self):
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -26,7 +20,7 @@ class RegtestSignrawtransactionTest (BitcoinTestFramework):
|
|||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Create and sign Overwinter transaction.
|
||||
# Create and sign Sapling transaction.
|
||||
# If the incorrect consensus branch id is selected, there will be a signing error.
|
||||
opid = self.nodes[1].z_sendmany(taddr,
|
||||
[{'address': zaddr1, 'amount': 1}])
|
||||
|
|
|
@ -11,6 +11,8 @@ from test_framework.util import assert_equal, initialize_chain_clean, \
|
|||
|
||||
import time
|
||||
|
||||
FAKE_SPROUT = ['-nuparams=5ba81b19:210', '-nuparams=76b809bb:220']
|
||||
FAKE_OVERWINTER = ['-nuparams=5ba81b19:10', '-nuparams=76b809bb:220']
|
||||
|
||||
class RewindBlockIndexTest (BitcoinTestFramework):
|
||||
|
||||
|
@ -22,7 +24,11 @@ class RewindBlockIndexTest (BitcoinTestFramework):
|
|||
# Node 0 - Overwinter, then Sprout, then Overwinter again
|
||||
# Node 1 - Sprout
|
||||
# Node 2 - Overwinter
|
||||
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[['-nuparams=5ba81b19:10'], [], ['-nuparams=5ba81b19:10']])
|
||||
self.nodes = start_nodes(3, self.options.tmpdir, extra_args=[
|
||||
FAKE_OVERWINTER,
|
||||
FAKE_SPROUT,
|
||||
FAKE_OVERWINTER,
|
||||
])
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
|
@ -52,7 +58,7 @@ class RewindBlockIndexTest (BitcoinTestFramework):
|
|||
print("Switching node 0 from Overwinter to Sprout")
|
||||
self.nodes[0].stop()
|
||||
bitcoind_processes[0].wait()
|
||||
self.nodes[0] = start_node(0,self.options.tmpdir)
|
||||
self.nodes[0] = start_node(0, self.options.tmpdir, extra_args=FAKE_SPROUT)
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
|
@ -69,7 +75,7 @@ class RewindBlockIndexTest (BitcoinTestFramework):
|
|||
print("Switching node 0 from Sprout to Overwinter")
|
||||
self.nodes[0].stop()
|
||||
bitcoind_processes[0].wait()
|
||||
self.nodes[0] = start_node(0,self.options.tmpdir, extra_args=['-nuparams=5ba81b19:10'])
|
||||
self.nodes[0] = start_node(0, self.options.tmpdir, extra_args=FAKE_OVERWINTER)
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
|
|
|
@ -13,7 +13,7 @@ class SignOfflineTest (BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 2)
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = [ start_node(0, self.options.tmpdir, ["-nuparams=5ba81b19:10"]) ]
|
||||
self.nodes = [ start_node(0, self.options.tmpdir, ["-nuparams=2bb40e60:10"]) ]
|
||||
self.is_network_split = False
|
||||
self.sync_all()
|
||||
|
||||
|
@ -22,7 +22,7 @@ class SignOfflineTest (BitcoinTestFramework):
|
|||
print "Mining blocks..."
|
||||
self.nodes[0].generate(101)
|
||||
|
||||
offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=5ba81b19:10"])
|
||||
offline_node = start_node(1, self.options.tmpdir, ["-maxconnections=0", "-nuparams=2bb40e60:10"])
|
||||
self.nodes.append(offline_node)
|
||||
|
||||
assert_equal(0, len(offline_node.getpeerinfo())) # make sure node 1 has no peers
|
||||
|
@ -49,7 +49,7 @@ class SignOfflineTest (BitcoinTestFramework):
|
|||
pass
|
||||
|
||||
# Passing in the consensus branch id resolves the issue for offline regtest nodes.
|
||||
signed_tx = offline_node.signrawtransaction(create_hex, sign_inputs, privkeys, "ALL", "5ba81b19")
|
||||
signed_tx = offline_node.signrawtransaction(create_hex, sign_inputs, privkeys, "ALL", "2bb40e60")
|
||||
|
||||
# If we return the transaction hash, then we have have not thrown an error (success)
|
||||
online_tx_hash = self.nodes[0].sendrawtransaction(signed_tx['hex'])
|
||||
|
|
|
@ -52,10 +52,7 @@ def check_migration_status(node, destination_address, migration_state):
|
|||
|
||||
class SproutSaplingMigration(BitcoinTestFramework):
|
||||
def setup_nodes(self):
|
||||
# Activate overwinter/sapling on all nodes
|
||||
extra_args = [[
|
||||
'-nuparams=5ba81b19:100', # Overwinter
|
||||
'-nuparams=76b809bb:100', # Sapling
|
||||
]] * 4
|
||||
# Add migration parameters to nodes[0]
|
||||
extra_args[0] = extra_args[0] + [
|
||||
|
@ -63,8 +60,8 @@ class SproutSaplingMigration(BitcoinTestFramework):
|
|||
'-migrationdestaddress=' + SAPLING_ADDR,
|
||||
'-debug=zrpcunsafe'
|
||||
]
|
||||
assert_equal(5, len(extra_args[0]))
|
||||
assert_equal(2, len(extra_args[1]))
|
||||
assert_equal(3, len(extra_args[0]))
|
||||
assert_equal(0, len(extra_args[1]))
|
||||
return start_nodes(4, self.options.tmpdir, extra_args)
|
||||
|
||||
def setup_chain(self):
|
||||
|
|
|
@ -642,9 +642,9 @@ class CTxOut(object):
|
|||
class CTransaction(object):
|
||||
def __init__(self, tx=None):
|
||||
if tx is None:
|
||||
self.fOverwintered = False
|
||||
self.nVersion = 1
|
||||
self.nVersionGroupId = 0
|
||||
self.fOverwintered = True
|
||||
self.nVersion = 4
|
||||
self.nVersionGroupId = SAPLING_VERSION_GROUP_ID
|
||||
self.vin = []
|
||||
self.vout = []
|
||||
self.nLockTime = 0
|
||||
|
@ -1517,7 +1517,7 @@ class NodeConn(asyncore.dispatcher):
|
|||
"regtest": "\xaa\xe8\x3f\x5f" # regtest
|
||||
}
|
||||
|
||||
def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", protocol_version=SPROUT_PROTO_VERSION):
|
||||
def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", protocol_version=SAPLING_PROTO_VERSION):
|
||||
asyncore.dispatcher.__init__(self, map=mininode_socket_map)
|
||||
self.log = logging.getLogger("NodeConn(%s:%d)" % (dstaddr, dstport))
|
||||
self.dstaddr = dstaddr
|
||||
|
|
|
@ -40,8 +40,6 @@ from test_framework.util import (
|
|||
)
|
||||
from decimal import Decimal
|
||||
|
||||
NUPARAMS_ARGS = ['-nuparams=5ba81b19:100', # Overwinter
|
||||
'-nuparams=76b809bb:101'] # Sapling
|
||||
TURNSTILE_ARGS = ['-experimentalfeatures',
|
||||
'-developersetpoolsizezero']
|
||||
|
||||
|
@ -52,8 +50,7 @@ class TurnstileTest (BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 3)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(3, self.options.tmpdir,
|
||||
extra_args=[NUPARAMS_ARGS] * 3)
|
||||
self.nodes = start_nodes(3, self.options.tmpdir)
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
self.is_network_split=False
|
||||
|
@ -70,7 +67,7 @@ class TurnstileTest (BitcoinTestFramework):
|
|||
|
||||
# Helper method to start a single node with extra args and sync to the network
|
||||
def start_and_sync_node(self, index, args=[]):
|
||||
self.nodes[index] = start_node(index, self.options.tmpdir, extra_args=NUPARAMS_ARGS + args)
|
||||
self.nodes[index] = start_node(index, self.options.tmpdir, extra_args=args)
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
|
|
|
@ -92,7 +92,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
|
||||
# Catch an attempt to send a transaction with an absurdly high fee.
|
||||
# Send 1.0 from an utxo of value 10.0 but don't specify a change output, so then
|
||||
# the change of 9.0 becomes the fee, which is greater than estimated fee of 0.0019.
|
||||
# the change of 9.0 becomes the fee, which is greater than estimated fee of 0.0021.
|
||||
inputs = []
|
||||
outputs = {}
|
||||
for utxo in node2utxos:
|
||||
|
@ -108,7 +108,7 @@ class WalletTest (BitcoinTestFramework):
|
|||
except JSONRPCException,e:
|
||||
errorString = e.error['message']
|
||||
assert("absurdly high fees" in errorString)
|
||||
assert("900000000 > 190000" in errorString)
|
||||
assert("900000000 > 210000" in errorString)
|
||||
|
||||
# create both transactions
|
||||
txns_to_send = []
|
||||
|
@ -286,12 +286,16 @@ class WalletTest (BitcoinTestFramework):
|
|||
myzaddr = self.nodes[0].z_getnewaddress('sprout')
|
||||
|
||||
recipients = []
|
||||
num_t_recipients = 3000
|
||||
num_t_recipients = 1000
|
||||
num_z_recipients = 2100
|
||||
amount_per_recipient = Decimal('0.00000001')
|
||||
errorString = ''
|
||||
for i in xrange(0,num_t_recipients):
|
||||
newtaddr = self.nodes[2].getnewaddress()
|
||||
recipients.append({"address":newtaddr, "amount":amount_per_recipient})
|
||||
for i in xrange(0,num_z_recipients):
|
||||
newzaddr = self.nodes[2].z_getnewaddress('sprout')
|
||||
recipients.append({"address":newzaddr, "amount":amount_per_recipient})
|
||||
|
||||
# Issue #2759 Workaround START
|
||||
# HTTP connection to node 0 may fall into a state, during the few minutes it takes to process
|
||||
|
@ -302,47 +306,12 @@ class WalletTest (BitcoinTestFramework):
|
|||
self.nodes[0].getinfo()
|
||||
# Issue #2759 Workaround END
|
||||
|
||||
try:
|
||||
self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
except JSONRPCException,e:
|
||||
errorString = e.error['message']
|
||||
assert("Too many outputs, size of raw transaction" in errorString)
|
||||
|
||||
recipients = []
|
||||
num_t_recipients = 2000
|
||||
num_z_recipients = 50
|
||||
amount_per_recipient = Decimal('0.00000001')
|
||||
errorString = ''
|
||||
for i in xrange(0,num_t_recipients):
|
||||
newtaddr = self.nodes[2].getnewaddress()
|
||||
recipients.append({"address":newtaddr, "amount":amount_per_recipient})
|
||||
for i in xrange(0,num_z_recipients):
|
||||
newzaddr = self.nodes[2].z_getnewaddress('sprout')
|
||||
recipients.append({"address":newzaddr, "amount":amount_per_recipient})
|
||||
|
||||
# Issue #2759 Workaround START
|
||||
self.nodes[0].getinfo()
|
||||
# Issue #2759 Workaround END
|
||||
|
||||
try:
|
||||
self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
except JSONRPCException,e:
|
||||
errorString = e.error['message']
|
||||
assert("size of raw transaction would be larger than limit" in errorString)
|
||||
|
||||
recipients = []
|
||||
num_z_recipients = 100
|
||||
amount_per_recipient = Decimal('0.00000001')
|
||||
errorString = ''
|
||||
for i in xrange(0,num_z_recipients):
|
||||
newzaddr = self.nodes[2].z_getnewaddress('sprout')
|
||||
recipients.append({"address":newzaddr, "amount":amount_per_recipient})
|
||||
try:
|
||||
self.nodes[0].z_sendmany(myzaddr, recipients)
|
||||
except JSONRPCException,e:
|
||||
errorString = e.error['message']
|
||||
assert("Invalid parameter, too many zaddr outputs" in errorString)
|
||||
|
||||
# add zaddr to node 2
|
||||
myzaddr = self.nodes[2].z_getnewaddress('sprout')
|
||||
|
||||
|
|
|
@ -6,17 +6,11 @@
|
|||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, start_nodes
|
||||
from test_framework.util import assert_equal
|
||||
|
||||
# Test wallet address behaviour across network upgradesa\
|
||||
class WalletAddressesTest(BitcoinTestFramework):
|
||||
|
||||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir, [[
|
||||
'-nuparams=5ba81b19:202', # Overwinter
|
||||
'-nuparams=76b809bb:204', # Sapling
|
||||
]] * 4)
|
||||
|
||||
def run_test(self):
|
||||
def addr_checks(default_type):
|
||||
# Check default type, as well as explicit types
|
||||
|
@ -38,41 +32,17 @@ class WalletAddressesTest(BitcoinTestFramework):
|
|||
# Sanity-check the test harness
|
||||
assert_equal(self.nodes[0].getblockcount(), 200)
|
||||
|
||||
# Current height = 200 -> Sprout
|
||||
# Current height = 200 -> Sapling
|
||||
# Default address type is Sapling
|
||||
print "Testing height 200 (Sprout)"
|
||||
print "Testing height 200 (Sapling)"
|
||||
addr_checks('sapling')
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Current height = 201 -> Sprout
|
||||
# Current height = 201 -> Sapling
|
||||
# Default address type is Sapling
|
||||
print "Testing height 201 (Sprout)"
|
||||
addr_checks('sapling')
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Current height = 202 -> Overwinter
|
||||
# Default address type is Sapling
|
||||
print "Testing height 202 (Overwinter)"
|
||||
addr_checks('sapling')
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Current height = 203 -> Overwinter
|
||||
# Default address type is Sapling
|
||||
print "Testing height 203 (Overwinter)"
|
||||
addr_checks('sapling')
|
||||
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Current height = 204 -> Sapling
|
||||
# Default address type is Sapling
|
||||
print "Testing height 204 (Sapling)"
|
||||
print "Testing height 201 (Sapling)"
|
||||
addr_checks('sapling')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -9,7 +9,6 @@ from test_framework.test_framework import BitcoinTestFramework
|
|||
from test_framework.util import (
|
||||
assert_equal,
|
||||
get_coinbase_address,
|
||||
start_nodes,
|
||||
wait_and_assert_operationid_status,
|
||||
)
|
||||
|
||||
|
@ -18,29 +17,21 @@ from decimal import Decimal
|
|||
# Test wallet z_listunspent behaviour across network upgrades
|
||||
class WalletListNotes(BitcoinTestFramework):
|
||||
|
||||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir, [[
|
||||
'-nuparams=5ba81b19:202', # Overwinter
|
||||
'-nuparams=76b809bb:214', # Sapling
|
||||
]] * 4)
|
||||
|
||||
def run_test(self):
|
||||
# Current height = 200 -> Sprout
|
||||
# Current height = 200
|
||||
assert_equal(200, self.nodes[0].getblockcount())
|
||||
sproutzaddr = self.nodes[0].z_getnewaddress('sprout')
|
||||
|
||||
# test that we can create a sapling zaddr before sapling activates
|
||||
saplingzaddr = self.nodes[0].z_getnewaddress('sapling')
|
||||
|
||||
# we've got lots of coinbase (taddr) but no shielded funds yet
|
||||
assert_equal(0, Decimal(self.nodes[0].z_gettotalbalance()['private']))
|
||||
|
||||
# Set current height to 201 -> Sprout
|
||||
|
||||
# Set current height to 201
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
assert_equal(201, self.nodes[0].getblockcount())
|
||||
|
||||
# Shield coinbase funds (must be a multiple of 10, no change allowed pre-sapling)
|
||||
# Shield coinbase funds (must be a multiple of 10, no change allowed)
|
||||
receive_amount_10 = Decimal('10.0') - Decimal('0.0001')
|
||||
recipients = [{"address":sproutzaddr, "amount":receive_amount_10}]
|
||||
myopid = self.nodes[0].z_sendmany(get_coinbase_address(self.nodes[0]), recipients)
|
||||
|
@ -70,8 +61,8 @@ class WalletListNotes(BitcoinTestFramework):
|
|||
# Generate a block to confirm shield coinbase tx
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Current height = 202 -> Overwinter. Default address type remains Sprout
|
||||
|
||||
# Current height = 202
|
||||
assert_equal(202, self.nodes[0].getblockcount())
|
||||
|
||||
# Send 1.0 (actually 0.9999) from sproutzaddr to a new zaddr
|
||||
|
@ -108,12 +99,7 @@ class WalletListNotes(BitcoinTestFramework):
|
|||
unspent_tx_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr])
|
||||
assert_equal(1, len(unspent_tx_filter))
|
||||
assert_equal(unspent_tx[1], unspent_tx_filter[0])
|
||||
|
||||
# Set current height to 204 -> Sapling
|
||||
self.nodes[0].generate(12)
|
||||
self.sync_all()
|
||||
assert_equal(214, self.nodes[0].getblockcount())
|
||||
|
||||
|
||||
# No funds in saplingzaddr yet
|
||||
assert_equal(0, len(self.nodes[0].z_listunspent(0, 9999, False, [saplingzaddr])))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import sys; assert sys.version_info < (3,), ur"This script does not run under Py
|
|||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_true, assert_false
|
||||
from test_framework.util import start_nodes, wait_and_assert_operationid_status
|
||||
from test_framework.util import wait_and_assert_operationid_status
|
||||
from decimal import Decimal
|
||||
|
||||
my_memo = 'c0ffee' # stay awake
|
||||
|
@ -19,12 +19,6 @@ fee = Decimal('0.0001')
|
|||
|
||||
class ListReceivedTest (BitcoinTestFramework):
|
||||
|
||||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir, [[
|
||||
"-nuparams=5ba81b19:201", # Overwinter
|
||||
"-nuparams=76b809bb:214", # Sapling
|
||||
]] * 4)
|
||||
|
||||
def generate_and_sync(self, new_height):
|
||||
current_height = self.nodes[0].getblockcount()
|
||||
assert(new_height > current_height)
|
||||
|
|
|
@ -6,9 +6,15 @@
|
|||
import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x."
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, initialize_chain_clean, \
|
||||
start_nodes, connect_nodes_bi, wait_and_assert_operationid_status, \
|
||||
assert_greater_than, get_coinbase_address
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_greater_than,
|
||||
connect_nodes_bi,
|
||||
get_coinbase_address,
|
||||
initialize_chain_clean,
|
||||
start_nodes,
|
||||
wait_and_assert_operationid_status,
|
||||
)
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
|
||||
from decimal import Decimal
|
||||
|
@ -20,7 +26,11 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 4)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[["-nuparams=5ba81b19:200", "-debug=zrpcunsafe", "-txindex"]] * 4 )
|
||||
self.nodes = start_nodes(4, self.options.tmpdir, extra_args=[[
|
||||
"-nuparams=2bb40e60:200",
|
||||
"-debug=zrpcunsafe",
|
||||
"-txindex",
|
||||
]] * 4 )
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
|
@ -31,9 +41,9 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
def run_test (self):
|
||||
self.nodes[0].generate(100)
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(98)
|
||||
self.nodes[1].generate(95)
|
||||
self.sync_all()
|
||||
# Node 0 has reward from blocks 1 to 98 which are spendable.
|
||||
# Node 0 has reward from blocks 1 to 95 which are spendable.
|
||||
|
||||
taddr0 = get_coinbase_address(self.nodes[0])
|
||||
taddr1 = self.nodes[1].getnewaddress()
|
||||
|
@ -43,19 +53,12 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
zaddr3 = self.nodes[3].z_getnewaddress('sprout')
|
||||
|
||||
#
|
||||
# Currently at block 198. The next block to be mined 199 is a Sprout block
|
||||
# Currently at block 195. The next block to be mined 196 is a Sapling block
|
||||
#
|
||||
bci = self.nodes[0].getblockchaininfo()
|
||||
assert_equal(bci['consensus']['chaintip'], '00000000')
|
||||
assert_equal(bci['consensus']['nextblock'], '00000000')
|
||||
assert_equal(bci['upgrades']['5ba81b19']['status'], 'pending')
|
||||
|
||||
# Cannot use the expiryheight parameter of createrawtransaction if Overwinter is not active in the next block
|
||||
try:
|
||||
self.nodes[0].createrawtransaction([], {}, 0, 99)
|
||||
except JSONRPCException,e:
|
||||
errorString = e.error['message']
|
||||
assert_equal("Invalid parameter, expiryheight can only be used if Overwinter is active when the transaction is mined" in errorString, True)
|
||||
assert_equal(bci['consensus']['chaintip'], '76b809bb')
|
||||
assert_equal(bci['consensus']['nextblock'], '76b809bb')
|
||||
assert_equal(bci['upgrades']['2bb40e60']['status'], 'pending')
|
||||
|
||||
# Node 0 sends transparent funds to Node 2
|
||||
tsendamount = Decimal('1.0')
|
||||
|
@ -75,8 +78,10 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
myopid = self.nodes[0].z_sendmany(taddr0, recipients)
|
||||
txid_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
# Skip over the three blocks prior to activation; no transactions can be mined
|
||||
# in them due to the nearly-expiring restrictions.
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.nodes[0].generate(4)
|
||||
self.sync_all()
|
||||
|
||||
# Verify balance
|
||||
|
@ -84,26 +89,26 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
assert_equal(self.nodes[2].getbalance(), Decimal('0.4999'))
|
||||
assert_equal(self.nodes[2].z_getbalance(zaddr2), zsendamount)
|
||||
|
||||
# Verify transaction versions are 1 or 2 (intended for Sprout)
|
||||
# Verify transaction version is 4 (intended for Sapling+)
|
||||
result = self.nodes[0].getrawtransaction(txid_transparent, 1)
|
||||
assert_equal(result["version"], 1)
|
||||
assert_equal(result["overwintered"], False)
|
||||
assert_equal(result["version"], 4)
|
||||
assert_equal(result["overwintered"], True)
|
||||
result = self.nodes[0].getrawtransaction(txid_zsendmany, 1)
|
||||
assert_equal(result["version"], 1)
|
||||
assert_equal(result["overwintered"], False)
|
||||
assert_equal(result["version"], 4)
|
||||
assert_equal(result["overwintered"], True)
|
||||
result = self.nodes[0].getrawtransaction(txid_shielded, 1)
|
||||
assert_equal(result["version"], 2)
|
||||
assert_equal(result["overwintered"], False)
|
||||
assert_equal(result["version"], 4)
|
||||
assert_equal(result["overwintered"], True)
|
||||
|
||||
#
|
||||
# Currently at block 199. The next block to be mined 200 is an Overwinter block
|
||||
# Currently at block 199. The next block to be mined 200 is a Blossom block
|
||||
#
|
||||
bci = self.nodes[0].getblockchaininfo()
|
||||
assert_equal(bci['consensus']['chaintip'], '00000000')
|
||||
assert_equal(bci['consensus']['nextblock'], '5ba81b19')
|
||||
assert_equal(bci['upgrades']['5ba81b19']['status'], 'pending')
|
||||
assert_equal(bci['consensus']['chaintip'], '76b809bb')
|
||||
assert_equal(bci['consensus']['nextblock'], '2bb40e60')
|
||||
assert_equal(bci['upgrades']['2bb40e60']['status'], 'pending')
|
||||
|
||||
# Test using expiryheight parameter of createrawtransaction when Overwinter is active in the next block
|
||||
# Test using expiryheight parameter of createrawtransaction when Blossom is active in the next block
|
||||
errorString = ""
|
||||
try:
|
||||
self.nodes[0].createrawtransaction([], {}, 0, 499999999)
|
||||
|
@ -144,7 +149,7 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
myopid = self.nodes[0].z_sendmany(taddr0, recipients)
|
||||
txid_shielded = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
||||
|
||||
# Mine the first Overwinter block
|
||||
# Mine the first Blossom block
|
||||
self.sync_all()
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
@ -153,28 +158,28 @@ class WalletOverwinterTxTest (BitcoinTestFramework):
|
|||
# size_on_disk should be > 0
|
||||
assert_greater_than(bci['size_on_disk'], 0)
|
||||
|
||||
assert_equal(bci['consensus']['chaintip'], '5ba81b19')
|
||||
assert_equal(bci['consensus']['nextblock'], '5ba81b19')
|
||||
assert_equal(bci['upgrades']['5ba81b19']['status'], 'active')
|
||||
assert_equal(bci['consensus']['chaintip'], '2bb40e60')
|
||||
assert_equal(bci['consensus']['nextblock'], '2bb40e60')
|
||||
assert_equal(bci['upgrades']['2bb40e60']['status'], 'active')
|
||||
|
||||
# Verify balance
|
||||
assert_equal(self.nodes[1].z_getbalance(taddr1), Decimal('1.0'))
|
||||
assert_equal(self.nodes[3].getbalance(), Decimal('0.4999'))
|
||||
assert_equal(self.nodes[3].z_getbalance(zaddr3), zsendamount)
|
||||
|
||||
# Verify transaction version is 3 (intended for Overwinter)
|
||||
# Verify transaction version is 4 (intended for Sapling+)
|
||||
result = self.nodes[0].getrawtransaction(txid_transparent, 1)
|
||||
assert_equal(result["version"], 3)
|
||||
assert_equal(result["version"], 4)
|
||||
assert_equal(result["overwintered"], True)
|
||||
assert_equal(result["versiongroupid"], "03c48270")
|
||||
assert_equal(result["versiongroupid"], "892f2085")
|
||||
result = self.nodes[0].getrawtransaction(txid_zsendmany, 1)
|
||||
assert_equal(result["version"], 3)
|
||||
assert_equal(result["version"], 4)
|
||||
assert_equal(result["overwintered"], True)
|
||||
assert_equal(result["versiongroupid"], "03c48270")
|
||||
assert_equal(result["versiongroupid"], "892f2085")
|
||||
result = self.nodes[0].getrawtransaction(txid_shielded, 1)
|
||||
assert_equal(result["version"], 3)
|
||||
assert_equal(result["version"], 4)
|
||||
assert_equal(result["overwintered"], True)
|
||||
assert_equal(result["versiongroupid"], "03c48270")
|
||||
assert_equal(result["versiongroupid"], "892f2085")
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletOverwinterTxTest().main()
|
||||
|
|
|
@ -22,11 +22,7 @@ class WalletPersistenceTest (BitcoinTestFramework):
|
|||
initialize_chain_clean(self.options.tmpdir, 3)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(3, self.options.tmpdir,
|
||||
extra_args=[[
|
||||
'-nuparams=5ba81b19:100', # Overwinter
|
||||
'-nuparams=76b809bb:201', # Sapling
|
||||
]] * 3)
|
||||
self.nodes = start_nodes(3, self.options.tmpdir)
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
self.is_network_split=False
|
||||
|
@ -38,7 +34,7 @@ class WalletPersistenceTest (BitcoinTestFramework):
|
|||
assert_equal(self.nodes[0].getblockcount(), 200)
|
||||
self.sync_all()
|
||||
|
||||
# Verify Sapling address is persisted in wallet (even when Sapling is not yet active)
|
||||
# Verify Sapling address is persisted in wallet
|
||||
sapling_addr = self.nodes[0].z_getnewaddress('sapling')
|
||||
|
||||
# Make sure the node has the addresss
|
||||
|
@ -54,10 +50,6 @@ class WalletPersistenceTest (BitcoinTestFramework):
|
|||
addresses = self.nodes[0].z_listaddresses()
|
||||
assert_true(sapling_addr in addresses, "Should contain address after restart")
|
||||
|
||||
# Activate Sapling
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Node 0 shields funds to Sapling address
|
||||
taddr0 = get_coinbase_address(self.nodes[0])
|
||||
recipients = []
|
||||
|
|
|
@ -21,8 +21,6 @@ class WalletSaplingTest(BitcoinTestFramework):
|
|||
|
||||
def setup_nodes(self):
|
||||
return start_nodes(4, self.options.tmpdir, [[
|
||||
'-nuparams=5ba81b19:201', # Overwinter
|
||||
'-nuparams=76b809bb:203', # Sapling
|
||||
'-experimentalfeatures', '-zmergetoaddress',
|
||||
]] * 4)
|
||||
|
||||
|
@ -30,52 +28,6 @@ class WalletSaplingTest(BitcoinTestFramework):
|
|||
# Sanity-check the test harness
|
||||
assert_equal(self.nodes[0].getblockcount(), 200)
|
||||
|
||||
# Activate Overwinter
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Verify RPCs disallow Sapling value transfer if Sapling is not active
|
||||
tmp_taddr = get_coinbase_address(self.nodes[3])
|
||||
tmp_zaddr = self.nodes[3].z_getnewaddress('sapling')
|
||||
try:
|
||||
recipients = []
|
||||
recipients.append({"address": tmp_zaddr, "amount": Decimal('10')})
|
||||
self.nodes[3].z_sendmany(tmp_taddr, recipients, 1, 0)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling has not activated", e.error['message'])
|
||||
try:
|
||||
recipients = []
|
||||
recipients.append({"address": tmp_taddr, "amount": Decimal('10')})
|
||||
self.nodes[3].z_sendmany(tmp_zaddr, recipients, 1, 0)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling has not activated", e.error['message'])
|
||||
try:
|
||||
self.nodes[3].z_shieldcoinbase(tmp_taddr, tmp_zaddr)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling has not activated", e.error['message'])
|
||||
|
||||
# Verify z_mergetoaddress RPC does not support Sapling yet
|
||||
try:
|
||||
self.nodes[3].z_mergetoaddress([tmp_taddr], tmp_zaddr)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
assert_equal("Invalid parameter, Sapling has not activated", e.error['message'])
|
||||
try:
|
||||
self.nodes[3].z_mergetoaddress([tmp_zaddr], tmp_taddr)
|
||||
raise AssertionError("Should have thrown an exception")
|
||||
except JSONRPCException as e:
|
||||
# When sending from a zaddr we check for sapling activation only if
|
||||
# we find notes belonging to that address. Since sapling is not active
|
||||
# none can be generated and none will be found.
|
||||
assert_equal("Could not find any funds to merge.", e.error['message'])
|
||||
|
||||
# Activate Sapling
|
||||
self.nodes[2].generate(2)
|
||||
self.sync_all()
|
||||
|
||||
taddr1 = self.nodes[1].getnewaddress()
|
||||
saplingAddr0 = self.nodes[0].z_getnewaddress('sapling')
|
||||
saplingAddr1 = self.nodes[1].z_getnewaddress('sapling')
|
||||
|
|
|
@ -24,18 +24,10 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
|
||||
def setup_network(self, split=False):
|
||||
args = ['-regtestprotectcoinbase', '-debug=zrpcunsafe']
|
||||
args2 = ['-regtestprotectcoinbase', '-debug=zrpcunsafe', "-mempooltxinputlimit=7"]
|
||||
if self.addr_type != 'sprout':
|
||||
nu = [
|
||||
'-nuparams=5ba81b19:0', # Overwinter
|
||||
'-nuparams=76b809bb:1', # Sapling
|
||||
]
|
||||
args.extend(nu)
|
||||
args2 = args
|
||||
self.nodes = []
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, args))
|
||||
self.nodes.append(start_node(1, self.options.tmpdir, args))
|
||||
self.nodes.append(start_node(2, self.options.tmpdir, args2))
|
||||
self.nodes.append(start_node(2, self.options.tmpdir, args))
|
||||
connect_nodes_bi(self.nodes,0,1)
|
||||
connect_nodes_bi(self.nodes,1,2)
|
||||
connect_nodes_bi(self.nodes,0,2)
|
||||
|
@ -164,14 +156,8 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
wait_and_assert_operationid_status(self.nodes[0], opid1)
|
||||
wait_and_assert_operationid_status(self.nodes[0], opid2)
|
||||
|
||||
if self.addr_type == 'sprout':
|
||||
# Shielding the 800 utxos will occur over two transactions, since max tx size is 100,000 bytes.
|
||||
# We don't verify shieldingValue as utxos are not selected in any specific order, so value can change on each test run.
|
||||
# We set an unrealistically high limit parameter of 99999, to verify that max tx size will constrain the number of utxos.
|
||||
verify_locking('662', '138', 99999)
|
||||
else:
|
||||
# Shield the 800 utxos over two transactions
|
||||
verify_locking('500', '300', 500)
|
||||
# Shield the 800 utxos over two transactions
|
||||
verify_locking('500', '300', 500)
|
||||
|
||||
# sync_all() invokes sync_mempool() but node 2's mempool limit will cause tx1 and tx2 to be rejected.
|
||||
# So instead, we sync on blocks and mempool for node 0 and node 1, and after a new block is generated
|
||||
|
@ -181,18 +167,6 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
|
|||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
if self.addr_type == 'sprout':
|
||||
# Verify maximum number of utxos which node 2 can shield is limited by option -mempooltxinputlimit
|
||||
# This option is used when the limit parameter is set to 0.
|
||||
mytaddr = get_coinbase_address(self.nodes[2], 20)
|
||||
result = self.nodes[2].z_shieldcoinbase(mytaddr, myzaddr, Decimal('0.0001'), 0)
|
||||
assert_equal(result["shieldingUTXOs"], Decimal('7'))
|
||||
assert_equal(result["remainingUTXOs"], Decimal('13'))
|
||||
wait_and_assert_operationid_status(self.nodes[2], result['opid'])
|
||||
self.sync_all()
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
# Verify maximum number of utxos which node 0 can shield is set by default limit parameter of 50
|
||||
self.nodes[0].generate(200)
|
||||
self.sync_all()
|
||||
|
|
Loading…
Reference in New Issue