diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index f8b39739e..a23f2908d 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -1,5 +1,6 @@ #!/bin/bash -# Copyright 2019 The Hush developers +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 set -e -o pipefail diff --git a/qa/pull-tester/run-bitcoin-cli b/qa/pull-tester/run-bitcoin-cli index 93c25bb9f..99acd5bd8 100755 --- a/qa/pull-tester/run-bitcoin-cli +++ b/qa/pull-tester/run-bitcoin-cli @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 # This is a thin wrapper around bitcoin-cli that strips the Windows-style EOLs # from the output if present. It is necessary when using bitcoin-cli.exe on diff --git a/qa/pull-tester/run-bitcoind-for-test.sh.in b/qa/pull-tester/run-bitcoind-for-test.sh.in index afd45216d..8d95591d2 100755 --- a/qa/pull-tester/run-bitcoind-for-test.sh.in +++ b/qa/pull-tester/run-bitcoind-for-test.sh.in @@ -1,9 +1,8 @@ #!/bin/bash # THIS FILE IS GENERATED FROM run-bitcoind-for-test.sh.in # Copyright (c) 2013-2014 The Bitcoin Core developers -# Copyright (c) 2019 The Hush developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 # HUSH_LOAD_TIMEOUT=500 DATADIR="@abs_top_builddir@/.komodo/HUSH3" diff --git a/qa/pull-tester/tests-config.sh.in b/qa/pull-tester/tests-config.sh.in index 8f2cf3582..4bba14c85 100755 --- a/qa/pull-tester/tests-config.sh.in +++ b/qa/pull-tester/tests-config.sh.in @@ -1,9 +1,8 @@ #!/bin/bash # THIS FILE IS GENERATED FROM tests-config.sh.in # Copyright (c) 2013-2014 The Bitcoin Core developers -# Copyright (c) 2019 The Hush developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 BUILDDIR="@abs_top_builddir@" EXEEXT="@EXEEXT@" diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md index e95d6a120..f5f3da760 100644 --- a/qa/rpc-tests/README.md +++ b/qa/rpc-tests/README.md @@ -1,14 +1,14 @@ -Regression tests of RPC interface -================================= +# Regression tests of RPC interface + +## [test_framework/test_framework.py](test_framework/test_framework.py) -### [test_framework/test_framework.py](test_framework/test_framework.py) Base class for RPC regression tests. -### [test_framework/util.py](test_framework/util.py) +## [test_framework/util.py](test_framework/util.py) + Generally useful functions. -Notes -===== +## Notes You can run a single test by calling `qa/pull-tester/rpc-tests.sh `. @@ -22,7 +22,7 @@ Possible options: -h, --help show this help message and exit --nocleanup Leave komodods and test.* datadir on exit or error --noshutdown Don't stop komodods after the test execution - --srcdir=SRCDIR Source directory containing komodod/komodo-cli (default: + --srcdir=SRCDIR Source directory containing hushd/hush-cli (default: ../../src) --tmpdir=TMPDIR Root directory for datadirs --tracerpc Print out all RPC calls as they are made @@ -33,7 +33,7 @@ If you set the environment variable `PYTHON_DEBUG=1` you will get some debug out A 200-block -regtest blockchain and wallets for four nodes is created the first time a regression test is run and is stored in the cache/ directory. Each node has the miner -subsidy from 25 mature blocks (25*10=250 KMD) in its wallet. +subsidy from 25 mature blocks (`25*10=250 HUSH`) in its wallet. After the first run, the cache/ blockchain and wallets are copied into a temporary directory and used as the initial @@ -46,3 +46,5 @@ to recover with: rm -rf cache killall komodod ``` + +but beware that could kill various other processes you might not want to kill! diff --git a/qa/rpc-tests/reindex.py b/qa/rpc-tests/reindex.py index ae7563192..fe5af0b2a 100755 --- a/qa/rpc-tests/reindex.py +++ b/qa/rpc-tests/reindex.py @@ -1,8 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 # # Test -reindex with CheckBlockIndex # diff --git a/qa/rpc-tests/test_framework/mininode.py b/qa/rpc-tests/test_framework/mininode.py index 034435edb..3d1f7e5aa 100755 --- a/qa/rpc-tests/test_framework/mininode.py +++ b/qa/rpc-tests/test_framework/mininode.py @@ -1,11 +1,11 @@ # mininode.py - Bitcoin P2P network half-a-node # Copyright (c) 2019 The Hush developers -# -# Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# Released under the GPLv3 # # This python code was modified from ArtForz' public domain half-a-node, as # found in the mini-node branch of http://github.com/jgarzik/pynode. +# oringally from https://pastebin.com/ZSM7iHZw +# Mad respect to ArtForz!!!! # # NodeConn: an object which manages p2p connectivity to a bitcoin node # NodeConnCB: a base class that describes the interface for receiving @@ -44,7 +44,7 @@ OVERWINTER_PROTO_VERSION = 170003 BIP0031_VERSION = 60000 SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong SAPLING_PROTO_VERSION = 170006 -MY_SUBVERSION = "/python-mininode-hush-tester:0.0.1/" +MY_SUBVERSION = "/python-mininode-hush-tester:3.3.0/" OVERWINTER_VERSION_GROUP_ID = 0x03C48270 @@ -1387,6 +1387,7 @@ class NodeConn(asyncore.dispatcher): "reject": msg_reject, "mempool": msg_mempool } + # TODO: are these correct for Hush? MAGIC_BYTES = { "mainnet": "\x24\xe9\x27\x64", # mainnet "testnet3": "\xfa\x1a\xf9\xbf", # testnet3 @@ -1416,7 +1417,7 @@ class NodeConn(asyncore.dispatcher): vt.addrFrom.ip = "0.0.0.0" vt.addrFrom.port = 0 self.send_message(vt, True) - print 'MiniNode: Connecting to Bitcoin Node IP # ' + dstaddr + ':' \ + print 'MiniNode: Connecting to Hush Full Node IP # ' + dstaddr + ':' \ + str(dstport) + ' using version ' + str(protocol_version) try: diff --git a/qa/rpc-tests/test_framework/test_framework.py b/qa/rpc-tests/test_framework/test_framework.py index d1c3d87e3..6a22eeabe 100755 --- a/qa/rpc-tests/test_framework/test_framework.py +++ b/qa/rpc-tests/test_framework/test_framework.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 # Base class for RPC testing @@ -182,6 +182,66 @@ class ComparisonTestFramework(BitcoinTestFramework): [self.options.refbinary]*(self.num_nodes-1)) +class HushTestFramework(BitcoinTestFramework): + def __init__(self): + self.num_nodes = 2 + + def setup_chain(self): + print("Initializing Hush regtest directory "+self.options.tmpdir) + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up Hush regtest network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + class CryptoconditionsTestFramework(BitcoinTestFramework): def __init__(self): diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 8e465287b..9f505515f 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -1,5 +1,6 @@ # Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2018-2019 The SuperNET developers +# Copyright (c) 2018-2019 The Hush developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. # @@ -83,9 +84,10 @@ def initialize_datadir(dirname, n): if not os.path.isdir(datadir): os.makedirs(datadir) # kmd AC's don't use this, they use the conf auto-created when the AC is created - # plus CLI arguments. This is for komodod tests - print("Writing to " + os.path.join(datadir,"komodo.conf")) - with open(os.path.join(datadir, "komodo.conf"), 'w') as f: + # plus CLI arguments. This is for hushd tests + #TODO: need to create HUSH3.conf + print("Writing to " + os.path.join(datadir,"hush.conf")) + with open(os.path.join(datadir, "hush.conf"), 'w') as f: f.write("regtest=1\n"); f.write("txindex=1\n"); f.write("server=1\n"); @@ -101,36 +103,37 @@ def initialize_datadir(dirname, n): f.write("addressindex=1\n"); f.write("spentindex=1\n"); f.write("timestampindex=1\n"); + f.write("zindex=1\n"); return datadir def initialize_chain(test_dir): """ Create (or copy from cache) a 200-block-long chain and 4 wallets. - komodod and komodo-cli must be in search path. + hushd and hush-cli must be in search path. """ print("initialize_chain") if not os.path.isdir(os.path.join("cache", "node0")): devnull = open("/dev/null", "w+") - # Create cache directories, run komodods: + # Create cache directories, run hushds: for i in range(4): datadir=initialize_datadir("cache", i) - args = [ os.getenv("BITCOIND", "komodod"), "-keypool=1", "-datadir="+datadir, "-discover=0" ] + args = [ os.getenv("BITCOIND", "hushd"), "-keypool=1", "-datadir="+datadir, "-discover=0" ] if i > 0: args.append("-connect=127.0.0.1:"+str(p2p_port(0))) bitcoind_processes[i] = subprocess.Popen(args) - cmd = os.getenv("BITCOINCLI", "komodo-cli") + cmd = os.getenv("BITCOINCLI", "hush-cli") cmd_args = cmd + " -datadir="+datadir + " -rpcwait getblockcount" if os.getenv("PYTHON_DEBUG", ""): - print "initialize_chain: komodod started, calling: " + cmd_args + print "initialize_chain: hushd started, calling: " + cmd_args strcmd = cmd + " " + "-datadir="+datadir + " -rpcwait getblockcount" print("Running " + strcmd) subprocess.check_call(strcmd, shell=True); #subprocess.check_call([ cmd, "-rpcwait", "getblockcount"], stdout=devnull) if os.getenv("PYTHON_DEBUG", ""): - print "initialize_chain: komodo-cli -rpcwait getblockcount completed" + print "initialize_chain: hush-cli -rpcwait getblockcount completed" devnull.close() rpcs = [] for i in range(4): @@ -145,6 +148,7 @@ def initialize_chain(test_dir): # gets 25 mature blocks and 25 immature. # blocks are created with timestamps 10 minutes apart, starting # at 1 Jan 2014 + # TODO: change this to a recent time block_time = 1388534400 for i in range(2): for peer in range(4): @@ -159,6 +163,7 @@ def initialize_chain(test_dir): stop_nodes(rpcs) wait_bitcoinds() for i in range(4): + print "Cleaning up cache dir files" os.remove(log_filename("cache", i, "debug.log")) os.remove(log_filename("cache", i, "db.log")) os.remove(log_filename("cache", i, "peers.dat")) @@ -168,7 +173,7 @@ def initialize_chain(test_dir): from_dir = os.path.join("cache", "node"+str(i)) to_dir = os.path.join(test_dir, "node"+str(i)) shutil.copytree(from_dir, to_dir) - initialize_datadir(test_dir, i) # Overwrite port/rpcport in komodo.conf + initialize_datadir(test_dir, i) # Overwrite port/rpcport in hush.conf def initialize_chain_clean(test_dir, num_nodes): """ @@ -201,7 +206,7 @@ def _rpchost_to_args(rpchost): def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None): """ - Start a komodod and return RPC connection to it + Start a hushd and return RPC connection to it """ datadir = os.path.join(dirname, "node"+str(i)) # creating special config in case of cryptocondition asset chain test @@ -220,29 +225,29 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= config.write("bind=127.0.0.1\n") config.write("rpcbind=127.0.0.1") if binary is None: - binary = os.getenv("BITCOIND", "komodod") + binary = os.getenv("BITCOIND", "hushd") args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ] if extra_args is not None: args.extend(extra_args) #print("args=" + ' '.join(args)) bitcoind_processes[i] = subprocess.Popen(args) devnull = open("/dev/null", "w+") - cmd = os.getenv("BITCOINCLI", "komodo-cli") + cmd = os.getenv("BITCOINCLI", "hush-cli") print("cmd=" + cmd) cmd_args = ' '.join(extra_args) + " -rpcwait getblockcount " if os.getenv("PYTHON_DEBUG", ""): - print "start_node: komodod started, calling : " + cmd + " " + cmd_args + print "start_node: hushd started, calling : " + cmd + " " + cmd_args strcmd = cmd + " " + cmd_args print("Running " + strcmd) import time time.sleep(2) subprocess.check_call(strcmd, shell=True); - #subprocess.check_call([ os.getenv("BITCOINCLI", "komodo-cli"), "-datadir="+datadir] + + #subprocess.check_call([ os.getenv("BITCOINCLI", "hush-cli"), "-datadir="+datadir] + # _rpchost_to_args(rpchost) + # ["-rpcwait", "-rpcport=6438", "getblockcount"], stdout=devnull) if os.getenv("PYTHON_DEBUG", ""): - print "start_node: calling komodo-cli -rpcwait getblockcount returned" + print "start_node: calling hush-cli -rpcwait getblockcount returned" devnull.close() port = extra_args[3] url = "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', int(port[9:])) @@ -257,7 +262,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None): """ - Start multiple komodods, return RPC connections to them + Start multiple hushds, return RPC connections to them """ if extra_args is None: extra_args = [ None for i in range(num_nodes) ] if binary is None: binary = [ None for i in range(num_nodes) ] diff --git a/qa/rpc-tests/wallet_sapling.py b/qa/rpc-tests/wallet_sapling.py index 1cbd94abf..4bca451cf 100755 --- a/qa/rpc-tests/wallet_sapling.py +++ b/qa/rpc-tests/wallet_sapling.py @@ -1,8 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers -# Copyright (c) 2019 The Hush developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/wallet_shieldcoinbase_sapling.py b/qa/rpc-tests/wallet_shieldcoinbase_sapling.py index d5d130329..290a44095 100755 --- a/qa/rpc-tests/wallet_shieldcoinbase_sapling.py +++ b/qa/rpc-tests/wallet_shieldcoinbase_sapling.py @@ -1,4 +1,6 @@ #!/usr/bin/env python2 +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 import inspect import os diff --git a/qa/rpc-tests/wallet_shieldcoinbase_sprout.py b/qa/rpc-tests/wallet_shieldcoinbase_sprout.py deleted file mode 100755 index 619ae7caf..000000000 --- a/qa/rpc-tests/wallet_shieldcoinbase_sprout.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python2 -import inspect -import os - -# To keep pyflakes happy -WalletShieldCoinbaseTest = object - -cwd = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) -execfile(os.path.join(cwd, 'wallet_shieldcoinbase.py')) - -class WalletShieldCoinbaseSprout(WalletShieldCoinbaseTest): - def __init__(self): - super(WalletShieldCoinbaseSprout, self).__init__('sprout') - -if __name__ == '__main__': - WalletShieldCoinbaseSprout().main()