Merge pull request #2 from MyHush/duke

Merge branch 'duke' of https://github.com/MyHush/hush3 into duke
This commit is contained in:
Denio
2019-12-23 16:33:33 +01:00
committed by GitHub
12 changed files with 114 additions and 61 deletions

View File

@@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
# Copyright 2019 The Hush developers # Copyright (c) 2019-2020 The Hush developers
# Released under the GPLv3
set -e -o pipefail set -e -o pipefail

View File

@@ -1,4 +1,6 @@
#!/bin/bash #!/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 # 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 # from the output if present. It is necessary when using bitcoin-cli.exe on

View File

@@ -1,9 +1,8 @@
#!/bin/bash #!/bin/bash
# THIS FILE IS GENERATED FROM run-bitcoind-for-test.sh.in # THIS FILE IS GENERATED FROM run-bitcoind-for-test.sh.in
# Copyright (c) 2013-2014 The Bitcoin Core developers # Copyright (c) 2013-2014 The Bitcoin Core developers
# Copyright (c) 2019 The Hush developers # Copyright (c) 2019-2020 The Hush developers
# Distributed under the MIT software license, see the accompanying # Released under the GPLv3
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# #
HUSH_LOAD_TIMEOUT=500 HUSH_LOAD_TIMEOUT=500
DATADIR="@abs_top_builddir@/.komodo/HUSH3" DATADIR="@abs_top_builddir@/.komodo/HUSH3"

View File

@@ -1,9 +1,8 @@
#!/bin/bash #!/bin/bash
# THIS FILE IS GENERATED FROM tests-config.sh.in # THIS FILE IS GENERATED FROM tests-config.sh.in
# Copyright (c) 2013-2014 The Bitcoin Core developers # Copyright (c) 2013-2014 The Bitcoin Core developers
# Copyright (c) 2019 The Hush developers # Copyright (c) 2019-2020 The Hush developers
# Distributed under the MIT software license, see the accompanying # Released under the GPLv3
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
BUILDDIR="@abs_top_builddir@" BUILDDIR="@abs_top_builddir@"
EXEEXT="@EXEEXT@" EXEEXT="@EXEEXT@"

View File

@@ -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. 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. Generally useful functions.
Notes ## Notes
=====
You can run a single test by calling `qa/pull-tester/rpc-tests.sh <testname>`. You can run a single test by calling `qa/pull-tester/rpc-tests.sh <testname>`.
@@ -22,7 +22,7 @@ Possible options:
-h, --help show this help message and exit -h, --help show this help message and exit
--nocleanup Leave komodods and test.* datadir on exit or error --nocleanup Leave komodods and test.* datadir on exit or error
--noshutdown Don't stop komodods after the test execution --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) ../../src)
--tmpdir=TMPDIR Root directory for datadirs --tmpdir=TMPDIR Root directory for datadirs
--tracerpc Print out all RPC calls as they are made --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 A 200-block -regtest blockchain and wallets for four nodes
is created the first time a regression test is run and is created the first time a regression test is run and
is stored in the cache/ directory. Each node has the miner 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 After the first run, the cache/ blockchain and wallets are
copied into a temporary directory and used as the initial copied into a temporary directory and used as the initial
@@ -46,3 +46,5 @@ to recover with:
rm -rf cache rm -rf cache
killall komodod killall komodod
``` ```
but beware that could kill various other processes you might not want to kill!

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Copyright (c) 2019-2020 The Hush developers
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # Released under the GPLv3
# #
# Test -reindex with CheckBlockIndex # Test -reindex with CheckBlockIndex
# #

View File

@@ -1,11 +1,11 @@
# mininode.py - Bitcoin P2P network half-a-node # mininode.py - Bitcoin P2P network half-a-node
# Copyright (c) 2019 The Hush developers # Copyright (c) 2019 The Hush developers
# # Released under the GPLv3
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# #
# This python code was modified from ArtForz' public domain half-a-node, as # 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. # 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 # NodeConn: an object which manages p2p connectivity to a bitcoin node
# NodeConnCB: a base class that describes the interface for receiving # NodeConnCB: a base class that describes the interface for receiving
@@ -44,7 +44,7 @@ OVERWINTER_PROTO_VERSION = 170003
BIP0031_VERSION = 60000 BIP0031_VERSION = 60000
SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong SPROUT_PROTO_VERSION = 170002 # past bip-31 for ping/pong
SAPLING_PROTO_VERSION = 170006 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 OVERWINTER_VERSION_GROUP_ID = 0x03C48270
@@ -1387,6 +1387,7 @@ class NodeConn(asyncore.dispatcher):
"reject": msg_reject, "reject": msg_reject,
"mempool": msg_mempool "mempool": msg_mempool
} }
# TODO: are these correct for Hush?
MAGIC_BYTES = { MAGIC_BYTES = {
"mainnet": "\x24\xe9\x27\x64", # mainnet "mainnet": "\x24\xe9\x27\x64", # mainnet
"testnet3": "\xfa\x1a\xf9\xbf", # testnet3 "testnet3": "\xfa\x1a\xf9\xbf", # testnet3
@@ -1416,7 +1417,7 @@ class NodeConn(asyncore.dispatcher):
vt.addrFrom.ip = "0.0.0.0" vt.addrFrom.ip = "0.0.0.0"
vt.addrFrom.port = 0 vt.addrFrom.port = 0
self.send_message(vt, True) 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) + str(dstport) + ' using version ' + str(protocol_version)
try: try:

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying # Copyright (c) 2019-2020 The Hush developers
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # Released under the GPLv3
# Base class for RPC testing # Base class for RPC testing
@@ -182,6 +182,66 @@ class ComparisonTestFramework(BitcoinTestFramework):
[self.options.refbinary]*(self.num_nodes-1)) [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): class CryptoconditionsTestFramework(BitcoinTestFramework):
def __init__(self): def __init__(self):

View File

@@ -1,5 +1,6 @@
# Copyright (c) 2014 The Bitcoin Core developers # Copyright (c) 2014 The Bitcoin Core developers
# Copyright (c) 2018-2019 The SuperNET developers # Copyright (c) 2018-2019 The SuperNET developers
# Copyright (c) 2018-2019 The Hush 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.
# #
@@ -83,9 +84,10 @@ def initialize_datadir(dirname, n):
if not os.path.isdir(datadir): if not os.path.isdir(datadir):
os.makedirs(datadir) os.makedirs(datadir)
# kmd AC's don't use this, they use the conf auto-created when the AC is created # 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 # plus CLI arguments. This is for hushd tests
print("Writing to " + os.path.join(datadir,"komodo.conf")) #TODO: need to create HUSH3.conf
with open(os.path.join(datadir, "komodo.conf"), 'w') as f: 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("regtest=1\n");
f.write("txindex=1\n"); f.write("txindex=1\n");
f.write("server=1\n"); f.write("server=1\n");
@@ -101,36 +103,37 @@ def initialize_datadir(dirname, n):
f.write("addressindex=1\n"); f.write("addressindex=1\n");
f.write("spentindex=1\n"); f.write("spentindex=1\n");
f.write("timestampindex=1\n"); f.write("timestampindex=1\n");
f.write("zindex=1\n");
return datadir return datadir
def initialize_chain(test_dir): def initialize_chain(test_dir):
""" """
Create (or copy from cache) a 200-block-long chain and Create (or copy from cache) a 200-block-long chain and
4 wallets. 4 wallets.
komodod and komodo-cli must be in search path. hushd and hush-cli must be in search path.
""" """
print("initialize_chain") print("initialize_chain")
if not os.path.isdir(os.path.join("cache", "node0")): if not os.path.isdir(os.path.join("cache", "node0")):
devnull = open("/dev/null", "w+") devnull = open("/dev/null", "w+")
# Create cache directories, run komodods: # Create cache directories, run hushds:
for i in range(4): for i in range(4):
datadir=initialize_datadir("cache", i) 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: if i > 0:
args.append("-connect=127.0.0.1:"+str(p2p_port(0))) args.append("-connect=127.0.0.1:"+str(p2p_port(0)))
bitcoind_processes[i] = subprocess.Popen(args) 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" cmd_args = cmd + " -datadir="+datadir + " -rpcwait getblockcount"
if os.getenv("PYTHON_DEBUG", ""): 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" strcmd = cmd + " " + "-datadir="+datadir + " -rpcwait getblockcount"
print("Running " + strcmd) print("Running " + strcmd)
subprocess.check_call(strcmd, shell=True); subprocess.check_call(strcmd, shell=True);
#subprocess.check_call([ cmd, "-rpcwait", "getblockcount"], stdout=devnull) #subprocess.check_call([ cmd, "-rpcwait", "getblockcount"], stdout=devnull)
if os.getenv("PYTHON_DEBUG", ""): if os.getenv("PYTHON_DEBUG", ""):
print "initialize_chain: komodo-cli -rpcwait getblockcount completed" print "initialize_chain: hush-cli -rpcwait getblockcount completed"
devnull.close() devnull.close()
rpcs = [] rpcs = []
for i in range(4): for i in range(4):
@@ -145,6 +148,7 @@ def initialize_chain(test_dir):
# gets 25 mature blocks and 25 immature. # gets 25 mature blocks and 25 immature.
# blocks are created with timestamps 10 minutes apart, starting # blocks are created with timestamps 10 minutes apart, starting
# at 1 Jan 2014 # at 1 Jan 2014
# TODO: change this to a recent time
block_time = 1388534400 block_time = 1388534400
for i in range(2): for i in range(2):
for peer in range(4): for peer in range(4):
@@ -159,6 +163,7 @@ def initialize_chain(test_dir):
stop_nodes(rpcs) stop_nodes(rpcs)
wait_bitcoinds() wait_bitcoinds()
for i in range(4): 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, "debug.log"))
os.remove(log_filename("cache", i, "db.log")) os.remove(log_filename("cache", i, "db.log"))
os.remove(log_filename("cache", i, "peers.dat")) 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)) from_dir = os.path.join("cache", "node"+str(i))
to_dir = os.path.join(test_dir, "node"+str(i)) to_dir = os.path.join(test_dir, "node"+str(i))
shutil.copytree(from_dir, to_dir) 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): 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): 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)) datadir = os.path.join(dirname, "node"+str(i))
# creating special config in case of cryptocondition asset chain test # 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("bind=127.0.0.1\n")
config.write("rpcbind=127.0.0.1") config.write("rpcbind=127.0.0.1")
if binary is None: if binary is None:
binary = os.getenv("BITCOIND", "komodod") binary = os.getenv("BITCOIND", "hushd")
args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ] args = [ binary, "-datadir="+datadir, "-keypool=1", "-discover=0", "-rest" ]
if extra_args is not None: args.extend(extra_args) if extra_args is not None: args.extend(extra_args)
#print("args=" + ' '.join(args)) #print("args=" + ' '.join(args))
bitcoind_processes[i] = subprocess.Popen(args) bitcoind_processes[i] = subprocess.Popen(args)
devnull = open("/dev/null", "w+") devnull = open("/dev/null", "w+")
cmd = os.getenv("BITCOINCLI", "komodo-cli") cmd = os.getenv("BITCOINCLI", "hush-cli")
print("cmd=" + cmd) print("cmd=" + cmd)
cmd_args = ' '.join(extra_args) + " -rpcwait getblockcount " cmd_args = ' '.join(extra_args) + " -rpcwait getblockcount "
if os.getenv("PYTHON_DEBUG", ""): 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 strcmd = cmd + " " + cmd_args
print("Running " + strcmd) print("Running " + strcmd)
import time import time
time.sleep(2) time.sleep(2)
subprocess.check_call(strcmd, shell=True); 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) + # _rpchost_to_args(rpchost) +
# ["-rpcwait", "-rpcport=6438", "getblockcount"], stdout=devnull) # ["-rpcwait", "-rpcport=6438", "getblockcount"], stdout=devnull)
if os.getenv("PYTHON_DEBUG", ""): 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() devnull.close()
port = extra_args[3] port = extra_args[3]
url = "http://rt:rt@%s:%d" % (rpchost or '127.0.0.1', int(port[9:])) 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): 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 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) ] if binary is None: binary = [ None for i in range(num_nodes) ]

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2018 The Zcash developers # Copyright (c) 2018 The Zcash developers
# Copyright (c) 2019 The Hush developers # Copyright (c) 2019-2020 The Hush developers
# Distributed under the MIT software license, see the accompanying # Released under the GPLv3
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException from test_framework.authproxy import JSONRPCException

View File

@@ -1,4 +1,6 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright (c) 2019-2020 The Hush developers
# Released under the GPLv3
import inspect import inspect
import os import os

View File

@@ -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()