aboutsummaryrefslogtreecommitdiff
path: root/tests/functional_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional_tests')
-rwxr-xr-xtests/functional_tests/blockchain.py5
-rwxr-xr-xtests/functional_tests/functional_tests_rpc.py14
-rw-r--r--tests/functional_tests/make_test_signature.cc24
-rwxr-xr-xtests/functional_tests/rpc_payment.py42
-rwxr-xr-xtests/functional_tests/transfer.py59
-rwxr-xr-xtests/functional_tests/txpool.py24
6 files changed, 133 insertions, 35 deletions
diff --git a/tests/functional_tests/blockchain.py b/tests/functional_tests/blockchain.py
index 78e0d8952..b8f8bac1a 100755
--- a/tests/functional_tests/blockchain.py
+++ b/tests/functional_tests/blockchain.py
@@ -203,10 +203,15 @@ class BlockchainTest():
res_sum = daemon.get_coinbase_tx_sum(i, 1)
res_header = daemon.getblockheaderbyheight(i)
assert res_sum.emission_amount == res_header.block_header.reward
+ assert res_sum.emission_amount_top64 == 0
+ assert res_sum.emission_amount == int(res_sum.wide_emission_amount, 16)
+ assert res_sum.fee_amount == int(res_sum.wide_fee_amount, 16)
res = daemon.get_coinbase_tx_sum(0, 1)
assert res.emission_amount == 17592186044415
+ assert res.emission_amount_top64 == 0
assert res.fee_amount == 0
+ assert res.fee_amount_top64 == 0
sum_blocks = height + nblocks - 1
res = daemon.get_coinbase_tx_sum(0, sum_blocks)
extrapolated = 17592186044415 + 17592186044415 * 2 * (sum_blocks - 1)
diff --git a/tests/functional_tests/functional_tests_rpc.py b/tests/functional_tests/functional_tests_rpc.py
index 5f2a3d077..42d14e91a 100755
--- a/tests/functional_tests/functional_tests_rpc.py
+++ b/tests/functional_tests/functional_tests_rpc.py
@@ -34,8 +34,8 @@ try:
except:
tests = DEFAULT_TESTS
-N_MONERODS = 2
-N_WALLETS = 4
+N_MONERODS = 3
+N_WALLETS = 7
WALLET_DIRECTORY = builddir + "/functional-tests-directory"
DIFFICULTY = 10
@@ -43,9 +43,17 @@ monerod_base = [builddir + "/bin/monerod", "--regtest", "--fixed-difficulty", st
monerod_extra = [
[],
["--rpc-payment-address", "44SKxxLQw929wRF6BA9paQ1EWFshNnKhXM3qz6Mo3JGDE2YG3xyzVutMStEicxbQGRfrYvAAYxH6Fe8rnD56EaNwUiqhcwR", "--rpc-payment-difficulty", str(DIFFICULTY), "--rpc-payment-credits", "5000", "--data-dir", builddir + "/functional-tests-directory/monerod1"],
+ ["--rpc-restricted-bind-port", "18482", "--data-dir", builddir + "/functional-tests-directory/monerod2"]
]
-wallet_base = [builddir + "/bin/monero-wallet-rpc", "--wallet-dir", WALLET_DIRECTORY, "--rpc-bind-port", "wallet_port", "--disable-rpc-login", "--rpc-ssl", "disabled", "--daemon-ssl", "disabled", "--daemon-port", "18180", "--log-level", "1"]
+wallet_base = [builddir + "/bin/monero-wallet-rpc", "--wallet-dir", WALLET_DIRECTORY, "--rpc-bind-port", "wallet_port", "--disable-rpc-login", "--rpc-ssl", "disabled", "--daemon-ssl", "disabled", "--log-level", "1"]
wallet_extra = [
+ ["--daemon-port", "18180"],
+ ["--daemon-port", "18180"],
+ ["--daemon-port", "18180"],
+ ["--daemon-port", "18180"],
+ ["--daemon-port", "18182"],
+ ["--daemon-port", "18182"],
+ ["--daemon-port", "18182"]
]
command_lines = []
diff --git a/tests/functional_tests/make_test_signature.cc b/tests/functional_tests/make_test_signature.cc
index 789523de5..f31816841 100644
--- a/tests/functional_tests/make_test_signature.cc
+++ b/tests/functional_tests/make_test_signature.cc
@@ -27,15 +27,16 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
+#include "misc_language.h"
#include "string_tools.h"
#include "rpc/rpc_payment_signature.h"
int main(int argc, const char **argv)
{
TRY_ENTRY();
- if (argc > 2)
+ if (argc > 3)
{
- fprintf(stderr, "usage: %s <secret_key>\n", argv[0]);
+ fprintf(stderr, "usage: %s [<secret_key> [N]]\n", argv[0]);
return 1;
}
@@ -55,8 +56,23 @@ int main(int argc, const char **argv)
fprintf(stderr, "invalid secret key\n");
return 1;
}
- std::string signature = cryptonote::make_rpc_payment_signature(skey);
- printf("%s\n", signature.c_str());
+ uint32_t count = 1;
+ if (argc == 3)
+ {
+ int i = atoi(argv[2]);
+ if (i <= 0)
+ {
+ fprintf(stderr, "invalid count\n");
+ return 1;
+ }
+ count = (uint32_t)i;
+ }
+ while (count--)
+ {
+ std::string signature = cryptonote::make_rpc_payment_signature(skey);
+ epee::misc_utils::sleep_no_w(1);
+ printf("%s\n", signature.c_str());
+ }
return 0;
CATCH_ENTRY_L0("main()", 1);
}
diff --git a/tests/functional_tests/rpc_payment.py b/tests/functional_tests/rpc_payment.py
index 4c777ccd7..5f23c2022 100755
--- a/tests/functional_tests/rpc_payment.py
+++ b/tests/functional_tests/rpc_payment.py
@@ -31,6 +31,7 @@
from __future__ import print_function
import subprocess
import os
+import time
"""Test daemon RPC payment calls
"""
@@ -43,6 +44,7 @@ class RPCPaymentTest():
self.make_test_signature = os.environ['MAKE_TEST_SIGNATURE']
assert len(self.make_test_signature) > 0
self.secret_key, self.public_key = self.get_keys()
+ self.signatures = []
self.reset()
self.test_access_tracking()
self.test_access_mining()
@@ -56,8 +58,19 @@ class RPCPaymentTest():
assert len(fields) == 2
return fields
+ def refill_signatures(self):
+ self.signatures_time = time.time()
+ self.signatures = []
+ signatures = subprocess.check_output([self.make_test_signature, self.secret_key, '256']).decode('utf-8')
+ for line in signatures.split():
+ self.signatures.append(line.rstrip())
+
def get_signature(self):
- return subprocess.check_output([self.make_test_signature, self.secret_key]).decode('utf-8').rstrip()
+ if len(self.signatures) == 0 or self.signatures_time + 10 < time.time():
+ self.refill_signatures()
+ s = self.signatures[0]
+ self.signatures = self.signatures[1:]
+ return s
def reset(self):
print('Resetting blockchain')
@@ -143,6 +156,7 @@ class RPCPaymentTest():
found_valid = 0
found_invalid = 0
last_credits = 0
+ loop_time = time.time()
while found_valid == 0 or found_invalid == 0:
nonce += 1
try:
@@ -152,10 +166,17 @@ class RPCPaymentTest():
except Exception as e:
found_invalid += 1
res = daemon.rpc_access_info(client = self.get_signature())
+ cookie = res.cookie
+ loop_time = time.time()
assert res.credits < last_credits or res.credits == 0
assert nonce < 1000 # can't find both valid and invalid -> the RPC probably fails
last_credits = res.credits
+ if time.time() >= loop_time + 10:
+ res = daemon.rpc_access_info(client = self.get_signature())
+ cookie = res.cookie
+ loop_time = time.time()
+
# we should now have 1 valid nonce, and a number of bad ones
res = daemon.rpc_access_info(client = self.get_signature())
assert len(res.hashing_blob) > 39
@@ -176,6 +197,7 @@ class RPCPaymentTest():
assert e.nonces_dupe == 0
# Try random nonces till we find one that's valid so we get a load of credits
+ loop_time = time.time()
while last_credits == 0:
nonce += 1
try:
@@ -186,6 +208,10 @@ class RPCPaymentTest():
except:
found_invalid += 1
assert nonce < 1000 # can't find a valid none -> the RPC probably fails
+ if time.time() >= loop_time + 10:
+ res = daemon.rpc_access_info(client = self.get_signature())
+ cookie = res.cookie
+ loop_time = time.time()
# we should now have at least 5000
res = daemon.rpc_access_info(client = self.get_signature())
@@ -208,6 +234,7 @@ class RPCPaymentTest():
res = daemon.rpc_access_info(client = self.get_signature())
cookie = res.cookie
old_cookie = cookie # we keep that so can submit a stale later
+ loop_time = time.time()
while True:
nonce += 1
try:
@@ -218,6 +245,11 @@ class RPCPaymentTest():
found_invalid += 1
assert nonce < 1000 # can't find both valid and invalid -> the RPC probably fails
+ if time.time() >= loop_time + 10:
+ res = daemon.rpc_access_info(client = self.get_signature())
+ cookie = res.cookie
+ loop_time = time.time()
+
res = daemon.rpc_access_data()
assert len(res.entries) > 0
e = [x for x in res.entries if x['client'] == self.public_key]
@@ -247,14 +279,17 @@ class RPCPaymentTest():
# find stales without updating cookie, one within 5 seconds (accepted), one later (rejected)
res = daemon.rpc_access_info(client = self.get_signature())
+ cookie = res.cookie # let the daemon update its timestamp, but use old cookie
found_close_stale = 0
found_late_stale = 0
+ loop_time = time.time()
while found_close_stale == 0 or found_late_stale == 0:
nonce += 1
try:
res = daemon.rpc_access_submit_nonce(nonce = nonce, cookie = cookie, client = self.get_signature())
found_close_stale += 1
found_valid += 1
+ time.sleep(15) # now we've got an early stale, wait till they become late stales
except Exception as e:
#if e[0]['error']['code'] == -18: # stale
if "'code': -18" in str(e): # stale (ugly version, but also works with python 3)
@@ -263,6 +298,11 @@ class RPCPaymentTest():
found_invalid += 1
assert nonce < 1000 # can't find both valid and invalid -> the RPC probably fails
+ if time.time() >= loop_time + 10:
+ res = daemon.rpc_access_info(client = self.get_signature())
+ # cookie = res.cookie # let the daemon update its timestamp, but use old cookie
+ loop_time = time.time()
+
res = daemon.rpc_access_data()
assert len(res.entries) > 0
e = [x for x in res.entries if x['client'] == self.public_key]
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py
index 0c942f48b..f7a39fa0c 100755
--- a/tests/functional_tests/transfer.py
+++ b/tests/functional_tests/transfer.py
@@ -55,7 +55,7 @@ class TransferTest():
def reset(self):
print('Resetting blockchain')
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
res = daemon.get_height()
daemon.pop_blocks(res.height - 1)
daemon.flush_txpool()
@@ -69,7 +69,7 @@ class TransferTest():
]
self.wallet = [None] * len(seeds)
for i in range(len(seeds)):
- self.wallet[i] = Wallet(idx = i)
+ self.wallet[i] = Wallet(idx = i + 4)
# close the wallet if any, will throw if none is loaded
try: self.wallet[i].close_wallet()
except: pass
@@ -77,7 +77,7 @@ class TransferTest():
def mine(self):
print("Mining some blocks")
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
res = daemon.get_info()
height = res.height
@@ -89,7 +89,7 @@ class TransferTest():
assert res.height == height + 80
def transfer(self):
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
print("Creating transfer to self")
@@ -169,7 +169,7 @@ class TransferTest():
assert e.subaddr_indices == [{'major': 0, 'minor': 0}]
assert e.address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
assert e.double_spend_seen == False
- assert e.confirmations == 0
+ assert not 'confirmations' in e or e.confirmations == 0
running_balances[0] -= 1000000000000 + fee
@@ -256,7 +256,6 @@ class TransferTest():
assert res.too_big == False
assert res.overspend == False
assert res.fee_too_low == False
- assert res.not_rct == False
self.wallet[0].refresh()
@@ -282,7 +281,7 @@ class TransferTest():
assert e.subaddr_indices == [{'major': 0, 'minor': 0}]
assert e.address == '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW'
assert e.double_spend_seen == False
- assert e.confirmations == 0
+ assert not 'confirmations' in e or e.confirmations == 0
assert e.amount == amount
assert e.fee == fee
@@ -509,7 +508,7 @@ class TransferTest():
def check_get_bulk_payments(self):
print('Checking get_bulk_payments')
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
res = daemon.get_info()
height = res.height
@@ -545,7 +544,7 @@ class TransferTest():
def check_get_payments(self):
print('Checking get_payments')
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
res = daemon.get_info()
height = res.height
@@ -588,7 +587,8 @@ class TransferTest():
assert len(res.tx_blob_list) == 1
txes[i][1] = res.tx_blob_list[0]
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
+ restricted_daemon = Daemon(idx = 2, restricted_rpc = True)
res = daemon.send_raw_transaction(txes[0][1])
assert res.not_relayed == False
assert res.low_mixin == False
@@ -598,8 +598,19 @@ class TransferTest():
assert res.too_big == False
assert res.overspend == False
assert res.fee_too_low == False
- assert res.not_rct == False
+ res = restricted_daemon.send_raw_transaction(txes[0][1])
+ assert res.not_relayed == False
+ assert res.low_mixin == False
+ assert res.double_spend == False
+ assert res.invalid_input == False
+ assert res.invalid_output == False
+ assert res.too_big == False
+ assert res.overspend == False
+ assert res.fee_too_low == False
+
+ res = restricted_daemon.get_transactions([txes[0][0]])
+ assert not 'txs' in res or len(res.txs) == 0
res = daemon.get_transactions([txes[0][0]])
assert len(res.txs) >= 1
tx = [tx for tx in res.txs if tx.tx_hash == txes[0][0]][0]
@@ -615,9 +626,21 @@ class TransferTest():
assert res.too_big == False
assert res.overspend == False
assert res.fee_too_low == False
- assert res.not_rct == False
assert res.too_few_outputs == False
+ res = restricted_daemon.send_raw_transaction(txes[1][1])
+ assert res.not_relayed == False
+ assert res.low_mixin == False
+ assert res.double_spend == True
+ assert res.invalid_input == False
+ assert res.invalid_output == False
+ assert res.too_big == False
+ assert res.overspend == False
+ assert res.fee_too_low == False
+ assert res.too_few_outputs == False
+
+ res = restricted_daemon.get_transactions([txes[0][0]])
+ assert not 'txs' in res or len(res.txs) == 0
res = daemon.get_transactions([txes[0][0]])
assert len(res.txs) >= 1
tx = [tx for tx in res.txs if tx.tx_hash == txes[0][0]][0]
@@ -626,13 +649,13 @@ class TransferTest():
def sweep_dust(self):
print("Sweeping dust")
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
self.wallet[0].refresh()
res = self.wallet[0].sweep_dust()
assert not 'tx_hash_list' in res or len(res.tx_hash_list) == 0 # there's just one, but it cannot meet the fee
def sweep_single(self):
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
print("Sending single output")
@@ -688,7 +711,7 @@ class TransferTest():
assert len([t for t in res.transfers if t.key_image == ki]) == 1
def check_destinations(self):
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
print("Checking transaction destinations")
@@ -744,7 +767,7 @@ class TransferTest():
self.wallet[0].refresh()
def check_tx_notes(self):
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
print('Testing tx notes')
res = self.wallet[0].get_transfers()
@@ -761,7 +784,7 @@ class TransferTest():
assert res.notes == ['out txid', 'in txid']
def check_rescan(self):
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
print('Testing rescan_spent')
res = self.wallet[0].incoming_transfers(transfer_type = 'all')
@@ -801,7 +824,7 @@ class TransferTest():
assert sorted(old_t_out, key = lambda k: k['txid']) == sorted(new_t_out, key = lambda k: k['txid'])
def check_is_key_image_spent(self):
- daemon = Daemon()
+ daemon = Daemon(idx = 2)
print('Testing is_key_image_spent')
res = self.wallet[0].incoming_transfers(transfer_type = 'all')
diff --git a/tests/functional_tests/txpool.py b/tests/functional_tests/txpool.py
index 27ae89764..2d7f69f3c 100755
--- a/tests/functional_tests/txpool.py
+++ b/tests/functional_tests/txpool.py
@@ -45,14 +45,14 @@ class TransferTest():
def reset(self):
print('Resetting blockchain')
- daemon = Daemon()
+ daemon = Daemon(idx=2)
res = daemon.get_height()
daemon.pop_blocks(res.height - 1)
daemon.flush_txpool()
def create(self):
print('Creating wallet')
- wallet = Wallet()
+ wallet = Wallet(idx = 4)
# close the wallet if any, will throw if none is loaded
try: wallet.close_wallet()
except: pass
@@ -61,8 +61,8 @@ class TransferTest():
def mine(self):
print("Mining some blocks")
- daemon = Daemon()
- wallet = Wallet()
+ daemon = Daemon(idx = 2)
+ wallet = Wallet(idx = 4)
daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 80)
wallet.refresh()
@@ -70,8 +70,8 @@ class TransferTest():
def create_txes(self, address, ntxes):
print('Creating ' + str(ntxes) + ' transactions')
- daemon = Daemon()
- wallet = Wallet()
+ daemon = Daemon(idx = 2)
+ wallet = Wallet(idx = 4)
dst = {'address': address, 'amount': 1000000000000}
@@ -83,8 +83,10 @@ class TransferTest():
return txes
def check_empty_pool(self):
- daemon = Daemon()
+ self.check_empty_rpc_pool(Daemon(idx = 2))
+ self.check_empty_rpc_pool(Daemon(idx = 2, restricted_rpc = True))
+ def check_empty_rpc_pool(self, daemon):
res = daemon.get_transaction_pool_hashes()
assert not 'tx_hashes' in res or len(res.tx_hashes) == 0
res = daemon.get_transaction_pool_stats()
@@ -103,8 +105,9 @@ class TransferTest():
assert res.pool_stats.num_double_spends == 0
def check_txpool(self):
- daemon = Daemon()
- wallet = Wallet()
+ daemon = Daemon(idx = 2)
+ restricted_daemon = Daemon(idx = 2, restricted_rpc = True)
+ wallet = Wallet(idx = 4)
res = daemon.get_info()
height = res.height
@@ -117,6 +120,7 @@ class TransferTest():
res = daemon.get_info()
assert res.tx_pool_size == txpool_size + 5
txpool_size = res.tx_pool_size
+ self.check_empty_rpc_pool(restricted_daemon)
res = daemon.get_transaction_pool()
assert len(res.transactions) == txpool_size
@@ -160,6 +164,7 @@ class TransferTest():
print('Flushing 2 transactions')
txes_keys = list(txes.keys())
daemon.flush_txpool([txes_keys[1], txes_keys[3]])
+ self.check_empty_rpc_pool(restricted_daemon)
res = daemon.get_transaction_pool()
assert len(res.transactions) == txpool_size - 2
assert len([x for x in res.transactions if x.id_hash == txes_keys[1]]) == 0
@@ -210,6 +215,7 @@ class TransferTest():
print('Flushing unknown transactions')
unknown_txids = ['1'*64, '2'*64, '3'*64]
daemon.flush_txpool(unknown_txids)
+ self.check_empty_rpc_pool(restricted_daemon)
res = daemon.get_transaction_pool()
assert len(res.transactions) == txpool_size - 2