From 5d580bfa9c55690e056ce3148cbeb27cd1635a8f Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 19 Mar 2019 13:20:42 +0000 Subject: [PATCH] functional_tests: add get_bulk_transfer tests --- .../functional_tests/test_framework/wallet.py | 12 ++++++ tests/functional_tests/transfer.py | 37 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tests/functional_tests/test_framework/wallet.py b/tests/functional_tests/test_framework/wallet.py index 340eed179..7b83944e4 100644 --- a/tests/functional_tests/test_framework/wallet.py +++ b/tests/functional_tests/test_framework/wallet.py @@ -89,6 +89,18 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(transfer) + def get_bulk_payments(self, payment_ids = [], min_block_height = 0): + get_bulk_payments = { + 'method': 'get_bulk_payments', + 'params': { + 'payment_ids': payment_ids, + 'min_block_height': min_block_height, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_bulk_payments) + def describe_transfer(self, unsigned_txset): describe_transfer = { 'method': 'describe_transfer', diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py index de86c9daf..4599a7f49 100755 --- a/tests/functional_tests/transfer.py +++ b/tests/functional_tests/transfer.py @@ -41,6 +41,7 @@ class TransferTest(): self.create(0) self.mine() self.transfer() + self.check_get_bulk_payments() def create(self, idx): print 'Creating wallet' @@ -287,5 +288,41 @@ class TransferTest(): assert e.amount == 1200000000000 assert e.fee == fee + def check_get_bulk_payments(self): + print('Checking get_bulk_payments') + + daemon = Daemon() + res = daemon.get_info() + height = res.height + + wallet = Wallet() + + self.create(0) + wallet.refresh() + res = wallet.get_bulk_payments() + assert len(res.payments) >= 83 # at least 83 coinbases + res = wallet.get_bulk_payments(payment_ids = ['1234500000012345abcde00000abcdeff1234500000012345abcde00000abcde']) + assert 'payments' not in res or len(res.payments) == 0 + res = wallet.get_bulk_payments(min_block_height = height) + assert 'payments' not in res or len(res.payments) == 0 + res = wallet.get_bulk_payments(min_block_height = height - 40) + assert len(res.payments) >= 39 # coinbases + + self.create(1) + wallet.refresh() + res = wallet.get_bulk_payments() + assert len(res.payments) >= 2 # two txes were sent + res = wallet.get_bulk_payments(payment_ids = ['1234500000012345abcde00000abcdeff1234500000012345abcde00000abcde']) + assert len(res.payments) >= 2 # two txes were sent with that payment id + res = wallet.get_bulk_payments(payment_ids = ['ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff']) + assert 'payments' not in res or len(res.payments) == 0 # none with that payment id + + self.create(2) + wallet.refresh() + res = wallet.get_bulk_payments() + assert len(res.payments) >= 1 # one tx was sent + res = wallet.get_bulk_payments(payment_ids = ['1'*64, '1234500000012345abcde00000abcdeff1234500000012345abcde00000abcde', '2'*64]) + assert len(res.payments) >= 1 # one tx was sent + if __name__ == '__main__': TransferTest().run_test()