diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/functional_tests/transfer.py | 59 | ||||
-rw-r--r-- | tests/unit_tests/blockchain_db.cpp | 4 | ||||
-rw-r--r-- | tests/unit_tests/epee_utils.cpp | 3 | ||||
-rw-r--r-- | tests/unit_tests/ringct.cpp | 4 | ||||
-rw-r--r-- | tests/unit_tests/rolling_median.cpp | 2 |
5 files changed, 66 insertions, 6 deletions
diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py index e3c01c27f..7ebda6ebd 100755 --- a/tests/functional_tests/transfer.py +++ b/tests/functional_tests/transfer.py @@ -46,6 +46,7 @@ class TransferTest(): self.check_get_bulk_payments() self.check_double_spend_detection() self.sweep_single() + self.check_destinations() def reset(self): print('Resetting blockchain') @@ -630,6 +631,64 @@ class TransferTest(): res = self.wallet[0].incoming_transfers(transfer_type = 'unavailable') assert len([t for t in res.transfers if t.key_image == ki]) == 1 + def check_destinations(self): + daemon = Daemon() + + print("Checking transaction destinations") + + dst = {'address': '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 'amount': 1000000000000} + res = self.wallet[0].transfer([dst]) + assert len(res.tx_hash) == 64 + tx_hash = res.tx_hash + for i in range(2): + res = self.wallet[0].get_transfers(pending = True, out = True) + l = [x for x in (res.pending if i == 0 else res.out) if x.txid == tx_hash] + assert len(l) == 1 + e = l[0] + assert len(e.destinations) == 1 + assert e.destinations[0].amount == 1000000000000 + assert e.destinations[0].address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm' + + if i == 0: + daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1) + self.wallet[0].refresh() + + dst = {'address': '8AsN91rznfkBGTY8psSNkJBg9SZgxxGGRUhGwRptBhgr5XSQ1XzmA9m8QAnoxydecSh5aLJXdrgXwTDMMZ1AuXsN1EX5Mtm', 'amount': 1000000000000} + res = self.wallet[0].transfer([dst]) + assert len(res.tx_hash) == 64 + tx_hash = res.tx_hash + for i in range(2): + res = self.wallet[0].get_transfers(pending = True, out = True) + l = [x for x in (res.pending if i == 0 else res.out) if x.txid == tx_hash] + assert len(l) == 1 + e = l[0] + assert len(e.destinations) == 1 + assert e.destinations[0].amount == 1000000000000 + assert e.destinations[0].address == '8AsN91rznfkBGTY8psSNkJBg9SZgxxGGRUhGwRptBhgr5XSQ1XzmA9m8QAnoxydecSh5aLJXdrgXwTDMMZ1AuXsN1EX5Mtm' + + if i == 0: + daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1) + self.wallet[0].refresh() + + dst = {'address': '4BxSHvcgTwu25WooY4BVmgdcKwZu5EksVZSZkDd6ooxSVVqQ4ubxXkhLF6hEqtw96i9cf3cVfLw8UWe95bdDKfRQeYtPwLm1Jiw7AKt2LY', 'amount': 1000000000000} + res = self.wallet[0].transfer([dst]) + assert len(res.tx_hash) == 64 + tx_hash = res.tx_hash + for i in range(2): + res = self.wallet[0].get_transfers(pending = True, out = True) + l = [x for x in (res.pending if i == 0 else res.out) if x.txid == tx_hash] + assert len(l) == 1 + e = l[0] + assert len(e.destinations) == 1 + assert e.destinations[0].amount == 1000000000000 + assert e.destinations[0].address == '4BxSHvcgTwu25WooY4BVmgdcKwZu5EksVZSZkDd6ooxSVVqQ4ubxXkhLF6hEqtw96i9cf3cVfLw8UWe95bdDKfRQeYtPwLm1Jiw7AKt2LY' + + if i == 0: + daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1) + self.wallet[0].refresh() + + + if __name__ == '__main__': TransferTest().run_test() diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp index f302d7946..d7c60cecb 100644 --- a/tests/unit_tests/blockchain_db.cpp +++ b/tests/unit_tests/blockchain_db.cpp @@ -162,7 +162,7 @@ protected: { block bl; blobdata bd = h2b(i); - parse_and_validate_block_from_blob(bd, bl); + CHECK_AND_ASSERT_THROW_MES(parse_and_validate_block_from_blob(bd, bl), "Invalid block"); m_blocks.push_back(std::make_pair(bl, bd)); } for (auto& i : t_transactions) @@ -172,7 +172,7 @@ protected: { transaction tx; blobdata bd = h2b(j); - parse_and_validate_tx_from_blob(bd, tx); + CHECK_AND_ASSERT_THROW_MES(parse_and_validate_tx_from_blob(bd, tx), "Invalid transaction"); txs.push_back(std::make_pair(tx, bd)); } m_txs.push_back(txs); diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp index c5f9a42d0..32328edd9 100644 --- a/tests/unit_tests/epee_utils.cpp +++ b/tests/unit_tests/epee_utils.cpp @@ -27,6 +27,7 @@ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <array> +#include <boost/predef/other/endian.h> #include <boost/endian/conversion.hpp> #include <boost/range/algorithm/equal.hpp> #include <boost/range/algorithm_ext/iota.hpp> @@ -135,7 +136,7 @@ namespace EXPECT_FALSE( lhs >= rhs ); \ EXPECT_TRUE( rhs >= lhs ) - #ifdef BOOST_LITTLE_ENDIAN + #if BOOST_ENDIAN_LITTLE_BYTE #define CHECK_LESS_ENDIAN(lhs, rhs) CHECK_LESS( rhs , lhs ) #else #define CHECK_LESS_ENDIAN(lhs, rhs) CHECK_LESS( lhs , rhs ) diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp index 4d51ec434..d2b2c3109 100644 --- a/tests/unit_tests/ringct.cpp +++ b/tests/unit_tests/ringct.cpp @@ -779,8 +779,8 @@ TEST(ringct, range_proofs_accept_very_long_simple) inputs[n] = n; outputs[n] = n; } - std::random_shuffle(inputs, inputs + N); - std::random_shuffle(outputs, outputs + N); + std::shuffle(inputs, inputs + N, crypto::random_device{}); + std::shuffle(outputs, outputs + N, crypto::random_device{}); EXPECT_TRUE(range_proof_test(true, NELTS(inputs), inputs, NELTS(outputs), outputs, false, true)); } diff --git a/tests/unit_tests/rolling_median.cpp b/tests/unit_tests/rolling_median.cpp index 547fe092f..9e4cf87b8 100644 --- a/tests/unit_tests/rolling_median.cpp +++ b/tests/unit_tests/rolling_median.cpp @@ -143,7 +143,7 @@ TEST(rolling_median, order) m.insert(random[i]); ASSERT_EQ(med, m.median()); - std::shuffle(random.begin(), random.end(), std::default_random_engine(crypto::rand<unsigned>())); + std::shuffle(random.begin(), random.end(), crypto::random_device{}); m.clear(); for (int i = 0; i < 1000; ++i) m.insert(random[i]); |