diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/functional_tests/blockchain.py | 12 | ||||
-rwxr-xr-x | tests/functional_tests/transfer.py | 59 | ||||
-rwxr-xr-x | tests/functional_tests/wallet_address.py | 5 | ||||
-rw-r--r-- | tests/unit_tests/blockchain_db.cpp | 4 | ||||
-rw-r--r-- | tests/unit_tests/epee_utils.cpp | 20 | ||||
-rw-r--r-- | tests/unit_tests/ringct.cpp | 4 | ||||
-rw-r--r-- | tests/unit_tests/rolling_median.cpp | 2 |
7 files changed, 98 insertions, 8 deletions
diff --git a/tests/functional_tests/blockchain.py b/tests/functional_tests/blockchain.py index 2bd7672c0..2c3f34c35 100755 --- a/tests/functional_tests/blockchain.py +++ b/tests/functional_tests/blockchain.py @@ -78,6 +78,12 @@ class BlockchainTest(): except: ok = True assert ok + res = daemon.get_fee_estimate() + assert res.fee == 234562 + assert res.quantization_mask == 10000 + res = daemon.get_fee_estimate(10) + assert res.fee <= 234562 + # generate blocks res_generateblocks = daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', blocks) @@ -229,6 +235,12 @@ class BlockchainTest(): assert res.histogram[i].unlocked_instances == 0 assert res.histogram[i].recent_instances == 0 + res = daemon.get_fee_estimate() + assert res.fee == 234560 + assert res.quantization_mask == 10000 + res = daemon.get_fee_estimate(10) + assert res.fee <= 234560 + def _test_alt_chains(self): print('Testing alt chains') daemon = Daemon() 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/functional_tests/wallet_address.py b/tests/functional_tests/wallet_address.py index 4ff059a6f..eda52b432 100755 --- a/tests/functional_tests/wallet_address.py +++ b/tests/functional_tests/wallet_address.py @@ -198,8 +198,9 @@ class WalletAddressTest(): try: wallet.close_wallet() except: pass languages = res.languages - for language in languages: - print('Creating ' + str(language) + ' wallet') + languages_local = res.languages_local + for language in languages + languages_local: + print('Creating ' + language.encode('utf8') + ' wallet') wallet.create_wallet(filename = '', language = language) res = wallet.query_key('mnemonic') wallet.close_wallet() 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 946731826..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 ) @@ -946,3 +947,20 @@ TEST(parsing, number) epee::misc_utils::parse::match_number(i, s.end(), val); ASSERT_EQ(val, "+9.34e+03"); } + +TEST(parsing, unicode) +{ + std::string bs; + std::string s; + std::string::const_iterator si; + + s = "\"\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, ""); + s = "\"\\u0000\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, std::string(1, '\0')); + s = "\"\\u0020\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, " "); + s = "\"\\u1\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs)); + s = "\"\\u12\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs)); + s = "\"\\u123\""; si = s.begin(); ASSERT_FALSE(epee::misc_utils::parse::match_string(si, s.end(), bs)); + s = "\"\\u1234\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "ሴ"); + s = "\"foo\\u1234bar\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "fooሴbar"); + s = "\"\\u3042\\u307e\\u3084\\u304b\\u3059\""; si = s.begin(); ASSERT_TRUE(epee::misc_utils::parse::match_string(si, s.end(), bs)); ASSERT_EQ(bs, "あまやかす"); +} 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]); |