aboutsummaryrefslogtreecommitdiff
path: root/tests/functional_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional_tests')
-rwxr-xr-xtests/functional_tests/blockchain.py8
-rwxr-xr-xtests/functional_tests/multisig.py7
-rwxr-xr-xtests/functional_tests/transfer.py4
-rwxr-xr-xtests/functional_tests/validate_address.py111
4 files changed, 126 insertions, 4 deletions
diff --git a/tests/functional_tests/blockchain.py b/tests/functional_tests/blockchain.py
index 644597584..2bd7672c0 100755
--- a/tests/functional_tests/blockchain.py
+++ b/tests/functional_tests/blockchain.py
@@ -74,7 +74,7 @@ class BlockchainTest():
# we should not see a block at height
ok = False
- try: daemon.getblock(height)
+ try: daemon.getblock(height = height)
except: ok = True
assert ok
@@ -92,7 +92,7 @@ class BlockchainTest():
# get the blocks, check they have the right height
res_getblock = []
for n in range(blocks):
- res_getblock.append(daemon.getblock(height + n))
+ res_getblock.append(daemon.getblock(height = height + n))
block_header = res_getblock[n].block_header
assert abs(block_header.timestamp - time.time()) < 10 # within 10 seconds
assert block_header.height == height + n
@@ -111,7 +111,7 @@ class BlockchainTest():
# we should not see a block after that
ok = False
- try: daemon.getblock(height + blocks)
+ try: daemon.getblock(height = height + blocks)
except: ok = True
assert ok
@@ -157,7 +157,7 @@ class BlockchainTest():
# we should not see the popped block anymore
ok = False
- try: daemon.getblock(height + blocks - 1)
+ try: daemon.getblock(height = height + blocks - 1)
except: ok = True
assert ok
diff --git a/tests/functional_tests/multisig.py b/tests/functional_tests/multisig.py
index 3c8cd9c1d..b109acf91 100755
--- a/tests/functional_tests/multisig.py
+++ b/tests/functional_tests/multisig.py
@@ -43,6 +43,7 @@ class MultisigTest():
self.mine('42jSRGmmKN96V2j3B8X2DbiNThBXW1tSi1rW1uwkqbyURenq3eC3yosNm8HEMdHuWwKMFGzMUB3RCTvcTaW9kHpdRPP7p5y', 5)
self.mine('47fF32AdrmXG84FcPY697uZdd42pMMGiH5UpiTRTt3YX2pZC7t7wkzEMStEicxbQGRfrYvAAYxH6Fe8rnD56EaNwUgxRd53', 5)
self.mine('44SKxxLQw929wRF6BA9paQ1EWFshNnKhXM3qz6Mo3JGDE2YG3xyzVutMStEicxbQGRfrYvAAYxH6Fe8rnD56EaNwUiqhcwR', 5)
+ self.mine('4ADHswEU3XBUee8pudBkZQd9beJainqNo1BQKkHJujAEPJyQrLj9U4dNm8HEMdHuWwKMFGzMUB3RCTvcTaW9kHpdRUDxgjW', 5)
self.mine('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 60)
self.create_multisig_wallets(2, 2, '493DsrfJPqiN3Suv9RcRDoZEbQtKZX1sNcGPA3GhkKYEEmivk8kjQrTdRdVc4ZbmzWJuE157z9NNUKmF2VDfdYDR3CziGMk')
@@ -57,6 +58,12 @@ class MultisigTest():
self.import_multisig_info([0, 1, 2], 6)
self.check_transaction(txid)
+ self.create_multisig_wallets(3, 3, '4ADHswEU3XBUee8pudBkZQd9beJainqNo1BQKkHJujAEPJyQrLj9U4dNm8HEMdHuWwKMFGzMUB3RCTvcTaW9kHpdRUDxgjW')
+ self.import_multisig_info([2, 0, 1], 5)
+ txid = self.transfer([2, 1, 0])
+ self.import_multisig_info([0, 2, 1], 6)
+ self.check_transaction(txid)
+
self.create_multisig_wallets(3, 4, '47fF32AdrmXG84FcPY697uZdd42pMMGiH5UpiTRTt3YX2pZC7t7wkzEMStEicxbQGRfrYvAAYxH6Fe8rnD56EaNwUgxRd53')
self.import_multisig_info([0, 2, 3], 5)
txid = self.transfer([0, 2, 3])
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py
index 7bf0f4957..e3c01c27f 100755
--- a/tests/functional_tests/transfer.py
+++ b/tests/functional_tests/transfer.py
@@ -519,6 +519,9 @@ class TransferTest():
res = self.wallet[2].get_bulk_payments(payment_ids = ['1'*64, '1234500000012345abcde00000abcdeff1234500000012345abcde00000abcde', '2'*64])
assert len(res.payments) >= 1 # one tx was sent
+ res = self.wallet[1].get_bulk_payments(["1111111122222222"])
+ assert len(res.payments) >= 1 # we have one of these
+
def check_double_spend_detection(self):
print('Checking double spend detection')
txes = [[None, None], [None, None]]
@@ -571,6 +574,7 @@ class TransferTest():
assert res.overspend == False
assert res.fee_too_low == False
assert res.not_rct == False
+ assert res.too_few_outputs == False
res = daemon.get_transactions([txes[0][0]])
assert len(res.txs) >= 1
diff --git a/tests/functional_tests/validate_address.py b/tests/functional_tests/validate_address.py
new file mode 100755
index 000000000..58748b0a2
--- /dev/null
+++ b/tests/functional_tests/validate_address.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python3
+
+# Copyright (c) 2019 The Monero Project
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other
+# materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be
+# used to endorse or promote products derived from this software without specific
+# prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import time
+
+"""Test address validation RPC calls
+"""
+
+from framework.wallet import Wallet
+
+class AddressValidationTest():
+ def run_test(self):
+ self.create()
+ self.check_bad_addresses()
+ self.check_good_addresses()
+ self.check_openalias_addresses()
+
+ def create(self):
+ print('Creating wallet')
+ seed = 'velvet lymph giddy number token physics poetry unquoted nibs useful sabotage limits benches lifestyle eden nitrogen anvil fewest avoid batch vials washing fences goat unquoted'
+ address = '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
+ self.wallet = Wallet()
+ # close the wallet if any, will throw if none is loaded
+ try: self.wallet.close_wallet()
+ except: pass
+ res = self.wallet.restore_deterministic_wallet(seed = seed)
+ assert res.address == address
+ assert res.seed == seed
+
+ def check_bad_addresses(self):
+ print('Validating bad addresses')
+ bad_addresses = ['', 'a', '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWD9', ' ', '@', '42ey']
+ for address in bad_addresses:
+ res = self.wallet.validate_address(address, any_net_type = False)
+ assert not res.valid
+ res = self.wallet.validate_address(address, any_net_type = True)
+ assert not res.valid
+
+ def check_good_addresses(self):
+ print('Validating good addresses')
+ addresses = [
+ [ 'mainnet', '', '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm' ],
+ [ 'mainnet', '', '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW' ],
+ [ 'testnet', '', '9ujeXrjzf7bfeK3KZdCqnYaMwZVFuXemPU8Ubw335rj2FN1CdMiWNyFV3ksEfMFvRp9L9qum5UxkP5rN9aLcPxbH1au4WAB' ],
+ [ 'stagenet', '', '53teqCAESLxeJ1REzGMAat1ZeHvuajvDiXqboEocPaDRRmqWoVPzy46GLo866qRFjbNhfkNckyhST3WEvBviDwpUDd7DSzB' ],
+ [ 'mainnet', 'i', '4BxSHvcgTwu25WooY4BVmgdcKwZu5EksVZSZkDd6ooxSVVqQ4ubxXkhLF6hEqtw96i9cf3cVfLw8UWe95bdDKfRQeYtPwLm1Jiw7AKt2LY' ],
+ [ 'mainnet', 's', '8AsN91rznfkBGTY8psSNkJBg9SZgxxGGRUhGwRptBhgr5XSQ1XzmA9m8QAnoxydecSh5aLJXdrgXwTDMMZ1AuXsN1EX5Mtm' ],
+ [ 'mainnet', 's', '86kKnBKFqzCLxtK1Jmx2BkNBDBSMDEVaRYMMyVbeURYDWs8uNGDZURKCA5yRcyMxHzPcmCf1q2fSdhQVcaKsFrtGRsdGfNk' ],
+ [ 'testnet', 'i', 'AApMA1VuhiCaHzr5X2KXi2Zc9oJ3VaGjkfChxxpRpxkyKf1NetvbRbQTbFMrGkr85DjnEH7JsBaoUFsgKwZnmtnVWnoB8MDotCsLb7eWwz' ],
+ [ 'testnet', 's', 'BdKg9udkvckC5T58a8Nmtb6BNsgRAxs7uA2D49sWNNX5HPW5Us6Wxu8QMXrnSx3xPBQQ2iu9kwEcRGAoiz6EPmcZKbF62GS' ],
+ [ 'testnet', 's', 'BcFvPa3fT4gVt5QyRDe5Vv7VtUFao9ci8NFEy3r254KF7R1N2cNB5FYhGvrHbMStv4D6VDzZ5xtxeKV8vgEPMnDcNFuwZb9' ],
+ [ 'stagenet', 'i', '5K8mwfjumVseCcQEjNbf59Um6R9NfVUNkHTLhhPCmNvgDLVS88YW5tScnm83rw9mfgYtchtDDTW5jEfMhygi27j1QYphX38hg6m4VMtN29' ],
+ [ 'stagenet', 's', '73LhUiix4DVFMcKhsPRG51QmCsv8dYYbL6GcQoLwEEFvPvkVvc7BhebfA4pnEFF9Lq66hwvLqBvpHjTcqvpJMHmmNjPPBqa' ],
+ [ 'stagenet', 's', '7A1Hr63MfgUa8pkWxueD5xBqhQczkusYiCMYMnJGcGmuQxa7aDBxN1G7iCuLCNB3VPeb2TW7U9FdxB27xKkWKfJ8VhUZthF' ],
+ ]
+ for any_net_type in [True, False]:
+ for address in addresses:
+ res = self.wallet.validate_address(address[2], any_net_type = any_net_type)
+ if any_net_type or address[0] == 'mainnet':
+ assert res.valid
+ assert res.integrated == (address[1] == 'i')
+ assert res.subaddress == (address[1] == 's')
+ assert res.nettype == address[0]
+ assert res.openalias_address == ''
+ else:
+ assert not res.valid
+
+ def check_openalias_addresses(self):
+ print('Validating openalias addresses')
+ addresses = [
+ ['donate@getmonero.org', '44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A']
+ ]
+ for address in addresses:
+ res = self.wallet.validate_address(address[0])
+ assert not res.valid
+ res = self.wallet.validate_address(address[0], allow_openalias = True)
+ assert res.valid
+ assert not res.integrated
+ assert not res.subaddress
+ assert res.nettype == 'mainnet'
+ assert res.openalias_address == address[1]
+
+if __name__ == '__main__':
+ AddressValidationTest().run_test()