From cb1c257b5017e79be8629639c33e8945a5bf7f89 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 1 Jan 2026 15:20:29 -0500 Subject: [PATCH] Add "test" to run Hush tests This replaces the hack that was test.sh with a more extensible and less hackish test script. To run the tests just run "./test" . By default it shows all RPCs called via the "--tracerpc" flag. If you want to set custom test flags you can do TEST_FLAGS="--elite-test-flag --foo" ./test Currently we are only running lockzins.py and shieldcoinbase_donation.py tests which are hardcoded. The plan is to allow custom sets of tests to be run with this script. --- test | 47 +++++++++++++++++++++++++++++++++++++++++++++++ test.sh | 11 ----------- 2 files changed, 47 insertions(+), 11 deletions(-) create mode 100755 test delete mode 100755 test.sh diff --git a/test b/test new file mode 100755 index 000000000..c9c507ca8 --- /dev/null +++ b/test @@ -0,0 +1,47 @@ +#!/usr/bin/env perl +# Copyright 2016-2026 The Hush developers +# Distributed under the GPLv3 software license, see the accompanying +# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html + +use strict; +use warnings; +use 5.010; + +my $flags = $ENV{TEST_FLAGS} || '--tracerpc'; +my $test_dir = './qa/rpc-tests'; + +$ENV{PYTHONPATH} = "./qa/rpc-tests/test_framework/"; +#$ENV{PYTHON_DEBUG} = 1; + +my @tests_to_run = qw{ + lockzins.py + shieldcoinbase_donation.py +}; + +my $exit = 0; +my $failed_tests = 0; +my $time=time(); +my $num_tests = @tests_to_run; + +print "# Running $num_tests tests"; +for my $test (@tests_to_run) { + # send both stderr+stdout to our output file + my $cmd = "$test_dir/$test $flags 1>test-$time.txt 2>&1"; + system($cmd); + + print "."; + + if($?) { + say "$cmd FAILED!"; + $exit = 1; + $failed_tests++; + } +} +print "\n"; + +if ($exit) { + say "FAIL! Number of failed tests: $failed_tests . Details in test-$time.txt"; +} else { + say "PASS!"; +} +exit($exit); diff --git a/test.sh b/test.sh deleted file mode 100755 index dba7a8c15..000000000 --- a/test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2016-2025 The Hush developers -# Distributed under the GPLv3 software license, see the accompanying -# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - -#export PYTHON_DEBUG=1 -export PYTHONPATH=./qa/rpc-tests/test_framework/ - -#./qa/rpc-tests/ac_private.py -# ./qa/rpc-tests/lockzins.py --tracerpc - ./qa/rpc-tests/shieldcoinbase_donation.py --tracerpc