desprout
This commit is contained in:
@@ -23,7 +23,6 @@ testScripts=(
|
|||||||
'wallet_changeindicator.py'
|
'wallet_changeindicator.py'
|
||||||
'wallet_import_export.py'
|
'wallet_import_export.py'
|
||||||
'wallet_protectcoinbase.py'
|
'wallet_protectcoinbase.py'
|
||||||
'wallet_shieldcoinbase_sprout.py'
|
|
||||||
'wallet_shieldcoinbase_sapling.py'
|
'wallet_shieldcoinbase_sapling.py'
|
||||||
'wallet_listreceived.py'
|
'wallet_listreceived.py'
|
||||||
'wallet_mergetoaddress.py'
|
'wallet_mergetoaddress.py'
|
||||||
@@ -69,7 +68,6 @@ testScripts=(
|
|||||||
'getblocktemplate.py'
|
'getblocktemplate.py'
|
||||||
'bip65-cltv-p2p.py'
|
'bip65-cltv-p2p.py'
|
||||||
'bipdersig-p2p.py'
|
'bipdersig-p2p.py'
|
||||||
'p2p_nu_peer_management.py'
|
|
||||||
'rewind_index.py'
|
'rewind_index.py'
|
||||||
'p2p_txexpiry_dos.py'
|
'p2p_txexpiry_dos.py'
|
||||||
'p2p_node_bloom.py'
|
'p2p_node_bloom.py'
|
||||||
|
|||||||
@@ -1,192 +0,0 @@
|
|||||||
#!/usr/bin/env python2
|
|
||||||
# Copyright (c) 2018 The Zcash developers
|
|
||||||
# Distributed under the MIT software license, see the accompanying
|
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
||||||
|
|
||||||
from test_framework.mininode import (
|
|
||||||
NodeConn,
|
|
||||||
NodeConnCB,
|
|
||||||
NetworkThread,
|
|
||||||
msg_ping,
|
|
||||||
SPROUT_PROTO_VERSION,
|
|
||||||
OVERWINTER_PROTO_VERSION,
|
|
||||||
SAPLING_PROTO_VERSION,
|
|
||||||
)
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
|
||||||
from test_framework.util import initialize_chain_clean, start_nodes, \
|
|
||||||
p2p_port, assert_equal
|
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
#
|
|
||||||
# In this test we connect Sprout, Overwinter, and Sapling mininodes to a Zcashd
|
|
||||||
# node which will activate Overwinter at block 10 and Sapling at block 15.
|
|
||||||
#
|
|
||||||
# We test:
|
|
||||||
# 1. the mininodes stay connected to Zcash with Sprout consensus rules
|
|
||||||
# 2. when Overwinter activates, the Sprout mininodes are dropped
|
|
||||||
# 3. new Overwinter and Sapling nodes can connect to Zcash
|
|
||||||
# 4. new Sprout nodes cannot connect to Zcash
|
|
||||||
# 5. when Sapling activates, the Overwinter mininodes are dropped
|
|
||||||
# 6. new Sapling nodes can connect to Zcash
|
|
||||||
# 7. new Sprout and Overwinter nodes cannot connect to Zcash
|
|
||||||
#
|
|
||||||
# This test *does not* verify that prior to each activation, the Zcashd
|
|
||||||
# node will prefer connections with NU-aware nodes, with an eviction process
|
|
||||||
# that prioritizes non-NU-aware connections.
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
class TestManager(NodeConnCB):
|
|
||||||
def __init__(self):
|
|
||||||
NodeConnCB.__init__(self)
|
|
||||||
self.create_callback_map()
|
|
||||||
|
|
||||||
def on_close(self, conn):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def on_reject(self, conn, message):
|
|
||||||
conn.rejectMessage = message
|
|
||||||
|
|
||||||
|
|
||||||
class NUPeerManagementTest(BitcoinTestFramework):
|
|
||||||
|
|
||||||
def setup_chain(self):
|
|
||||||
print "Initializing test directory "+self.options.tmpdir
|
|
||||||
initialize_chain_clean(self.options.tmpdir, 1)
|
|
||||||
|
|
||||||
def setup_network(self):
|
|
||||||
self.nodes = start_nodes(1, self.options.tmpdir, extra_args=[[
|
|
||||||
'-nuparams=5ba81b19:10', # Overwinter
|
|
||||||
'-nuparams=76b809bb:15', # Sapling
|
|
||||||
'-debug',
|
|
||||||
'-whitelist=127.0.0.1',
|
|
||||||
]])
|
|
||||||
|
|
||||||
def run_test(self):
|
|
||||||
test = TestManager()
|
|
||||||
|
|
||||||
# Launch Sprout, Overwinter, and Sapling mininodes
|
|
||||||
nodes = []
|
|
||||||
for x in xrange(10):
|
|
||||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
|
||||||
test, "regtest", SPROUT_PROTO_VERSION))
|
|
||||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
|
||||||
test, "regtest", OVERWINTER_PROTO_VERSION))
|
|
||||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0],
|
|
||||||
test, "regtest", SAPLING_PROTO_VERSION))
|
|
||||||
|
|
||||||
# Start up network handling in another thread
|
|
||||||
NetworkThread().start()
|
|
||||||
|
|
||||||
# Sprout consensus rules apply at block height 9
|
|
||||||
self.nodes[0].generate(9)
|
|
||||||
assert_equal(9, self.nodes[0].getblockcount())
|
|
||||||
|
|
||||||
# Verify mininodes are still connected to zcashd node
|
|
||||||
peerinfo = self.nodes[0].getpeerinfo()
|
|
||||||
versions = [x["version"] for x in peerinfo]
|
|
||||||
assert_equal(10, versions.count(SPROUT_PROTO_VERSION))
|
|
||||||
assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION))
|
|
||||||
assert_equal(10, versions.count(SAPLING_PROTO_VERSION))
|
|
||||||
|
|
||||||
# Overwinter consensus rules activate at block height 10
|
|
||||||
self.nodes[0].generate(1)
|
|
||||||
assert_equal(10, self.nodes[0].getblockcount())
|
|
||||||
print('Overwinter active')
|
|
||||||
|
|
||||||
# Mininodes send ping message to zcashd node.
|
|
||||||
pingCounter = 1
|
|
||||||
for node in nodes:
|
|
||||||
node.send_message(msg_ping(pingCounter))
|
|
||||||
pingCounter = pingCounter + 1
|
|
||||||
|
|
||||||
time.sleep(3)
|
|
||||||
|
|
||||||
# Verify Sprout mininodes have been dropped, while Overwinter and
|
|
||||||
# Sapling mininodes are still connected.
|
|
||||||
peerinfo = self.nodes[0].getpeerinfo()
|
|
||||||
versions = [x["version"] for x in peerinfo]
|
|
||||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
|
||||||
assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION))
|
|
||||||
assert_equal(10, versions.count(SAPLING_PROTO_VERSION))
|
|
||||||
|
|
||||||
# Extend the Overwinter chain with another block.
|
|
||||||
self.nodes[0].generate(1)
|
|
||||||
|
|
||||||
# Connect a new Overwinter mininode to the zcashd node, which is accepted.
|
|
||||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", OVERWINTER_PROTO_VERSION))
|
|
||||||
time.sleep(3)
|
|
||||||
assert_equal(21, len(self.nodes[0].getpeerinfo()))
|
|
||||||
|
|
||||||
# Connect a new Sapling mininode to the zcashd node, which is accepted.
|
|
||||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SAPLING_PROTO_VERSION))
|
|
||||||
time.sleep(3)
|
|
||||||
assert_equal(22, len(self.nodes[0].getpeerinfo()))
|
|
||||||
|
|
||||||
# Try to connect a new Sprout mininode to the zcashd node, which is rejected.
|
|
||||||
sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SPROUT_PROTO_VERSION)
|
|
||||||
nodes.append(sprout)
|
|
||||||
time.sleep(3)
|
|
||||||
assert("Version must be 170003 or greater" in str(sprout.rejectMessage))
|
|
||||||
|
|
||||||
# Verify that only Overwinter and Sapling mininodes are connected.
|
|
||||||
peerinfo = self.nodes[0].getpeerinfo()
|
|
||||||
versions = [x["version"] for x in peerinfo]
|
|
||||||
assert_equal(0, versions.count(SPROUT_PROTO_VERSION))
|
|
||||||
assert_equal(11, versions.count(OVERWINTER_PROTO_VERSION))
|
|
||||||
assert_equal(11, versions.count(SAPLING_PROTO_VERSION))
|
|
||||||
|
|
||||||
# Sapling consensus rules activate at block height 15
|
|
||||||
self.nodes[0].generate(4)
|
|
||||||
assert_equal(15, self.nodes[0].getblockcount())
|
|
||||||
print('Sapling active')
|
|
||||||
|
|
||||||
# Mininodes send ping message to zcashd node.
|
|
||||||
pingCounter = 1
|
|
||||||
for node in nodes:
|
|
||||||
node.send_message(msg_ping(pingCounter))
|
|
||||||
pingCounter = pingCounter + 1
|
|
||||||
|
|
||||||
time.sleep(3)
|
|
||||||
|
|
||||||
# Verify Sprout and Overwinter mininodes have been dropped, while
|
|
||||||
# Sapling mininodes are 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(OVERWINTER_PROTO_VERSION))
|
|
||||||
assert_equal(11, versions.count(SAPLING_PROTO_VERSION))
|
|
||||||
|
|
||||||
# Extend the Sapling chain with another block.
|
|
||||||
self.nodes[0].generate(1)
|
|
||||||
|
|
||||||
# Connect a new Sapling mininode to the zcashd node, which is accepted.
|
|
||||||
nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SAPLING_PROTO_VERSION))
|
|
||||||
time.sleep(3)
|
|
||||||
assert_equal(12, len(self.nodes[0].getpeerinfo()))
|
|
||||||
|
|
||||||
# Try to connect a new Sprout mininode to the zcashd node, which is rejected.
|
|
||||||
sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SPROUT_PROTO_VERSION)
|
|
||||||
nodes.append(sprout)
|
|
||||||
time.sleep(3)
|
|
||||||
assert("Version must be 170006 or greater" in str(sprout.rejectMessage))
|
|
||||||
|
|
||||||
# Try to connect a new Overwinter mininode to the zcashd node, which is rejected.
|
|
||||||
sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", OVERWINTER_PROTO_VERSION)
|
|
||||||
nodes.append(sprout)
|
|
||||||
time.sleep(3)
|
|
||||||
assert("Version must be 170006 or greater" in str(sprout.rejectMessage))
|
|
||||||
|
|
||||||
# Verify that only Sapling mininodes are 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(OVERWINTER_PROTO_VERSION))
|
|
||||||
assert_equal(12, versions.count(SAPLING_PROTO_VERSION))
|
|
||||||
|
|
||||||
for node in nodes:
|
|
||||||
node.disconnect_node()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
NUPeerManagementTest().main()
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
# Copyright (c) 2019-2020 The Hush developers
|
||||||
# Copyright (c) 2018 The Zcash developers
|
# Copyright (c) 2018 The Zcash developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
@@ -20,89 +21,9 @@ class WalletListNotes(BitcoinTestFramework):
|
|||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Current height = 200 -> Sprout
|
# Current height = 200 -> Sprout
|
||||||
assert_equal(200, self.nodes[0].getblockcount())
|
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
|
# test that we can create a sapling zaddr before sapling activates
|
||||||
saplingzaddr = self.nodes[0].z_getnewaddress('sapling')
|
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
|
|
||||||
self.nodes[0].generate(1)
|
|
||||||
self.sync_all()
|
|
||||||
assert_equal(201, self.nodes[0].getblockcount())
|
|
||||||
|
|
||||||
mining_addr = self.nodes[0].listunspent()[0]['address']
|
|
||||||
|
|
||||||
# Shield coinbase funds (must be a multiple of 10, no change allowed pre-sapling)
|
|
||||||
receive_amount_10 = Decimal('10.0') - Decimal('0.0001')
|
|
||||||
recipients = [{"address":sproutzaddr, "amount":receive_amount_10}]
|
|
||||||
myopid = self.nodes[0].z_sendmany(mining_addr, recipients)
|
|
||||||
txid_1 = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
|
||||||
self.sync_all()
|
|
||||||
|
|
||||||
# No funds (with (default) one or more confirmations) in sproutzaddr yet
|
|
||||||
assert_equal(0, len(self.nodes[0].z_listunspent()))
|
|
||||||
assert_equal(0, len(self.nodes[0].z_listunspent(1)))
|
|
||||||
|
|
||||||
# no private balance because no confirmations yet
|
|
||||||
assert_equal(0, Decimal(self.nodes[0].z_gettotalbalance()['private']))
|
|
||||||
|
|
||||||
# list private unspent, this time allowing 0 confirmations
|
|
||||||
unspent_cb = self.nodes[0].z_listunspent(0)
|
|
||||||
assert_equal(1, len(unspent_cb))
|
|
||||||
assert_equal(False, unspent_cb[0]['change'])
|
|
||||||
assert_equal(txid_1, unspent_cb[0]['txid'])
|
|
||||||
assert_equal(True, unspent_cb[0]['spendable'])
|
|
||||||
assert_equal(sproutzaddr, unspent_cb[0]['address'])
|
|
||||||
assert_equal(receive_amount_10, unspent_cb[0]['amount'])
|
|
||||||
|
|
||||||
# list unspent, filtering by address, should produce same result
|
|
||||||
unspent_cb_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr])
|
|
||||||
assert_equal(unspent_cb, unspent_cb_filter)
|
|
||||||
|
|
||||||
# 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
|
|
||||||
assert_equal(202, self.nodes[0].getblockcount())
|
|
||||||
|
|
||||||
# Send 1.0 (actually 0.9999) from sproutzaddr to a new zaddr
|
|
||||||
sproutzaddr2 = self.nodes[0].z_getnewaddress()
|
|
||||||
receive_amount_1 = Decimal('1.0') - Decimal('0.0001')
|
|
||||||
change_amount_9 = receive_amount_10 - Decimal('1.0')
|
|
||||||
assert_equal('sprout', self.nodes[0].z_validateaddress(sproutzaddr2)['type'])
|
|
||||||
recipients = [{"address": sproutzaddr2, "amount":receive_amount_1}]
|
|
||||||
myopid = self.nodes[0].z_sendmany(sproutzaddr, recipients)
|
|
||||||
txid_2 = wait_and_assert_operationid_status(self.nodes[0], myopid)
|
|
||||||
self.sync_all()
|
|
||||||
|
|
||||||
# list unspent, allowing 0conf txs
|
|
||||||
unspent_tx = self.nodes[0].z_listunspent(0)
|
|
||||||
assert_equal(len(unspent_tx), 2)
|
|
||||||
# sort low-to-high by amount (order of returned entries is not guaranteed)
|
|
||||||
unspent_tx = sorted(unspent_tx, key=lambda k: k['amount'])
|
|
||||||
assert_equal(False, unspent_tx[0]['change'])
|
|
||||||
assert_equal(txid_2, unspent_tx[0]['txid'])
|
|
||||||
assert_equal(True, unspent_tx[0]['spendable'])
|
|
||||||
assert_equal(sproutzaddr2, unspent_tx[0]['address'])
|
|
||||||
assert_equal(receive_amount_1, unspent_tx[0]['amount'])
|
|
||||||
|
|
||||||
assert_equal(True, unspent_tx[1]['change'])
|
|
||||||
assert_equal(txid_2, unspent_tx[1]['txid'])
|
|
||||||
assert_equal(True, unspent_tx[1]['spendable'])
|
|
||||||
assert_equal(sproutzaddr, unspent_tx[1]['address'])
|
|
||||||
assert_equal(change_amount_9, unspent_tx[1]['amount'])
|
|
||||||
|
|
||||||
unspent_tx_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr2])
|
|
||||||
assert_equal(1, len(unspent_tx_filter))
|
|
||||||
assert_equal(unspent_tx[0], unspent_tx_filter[0])
|
|
||||||
|
|
||||||
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
|
# Set current height to 204 -> Sapling
|
||||||
self.nodes[0].generate(2)
|
self.nodes[0].generate(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user