From bfe5f0a10be0f041d4d16fa5d71169e4d461be9c Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 27 Feb 2018 15:25:14 +0300 Subject: [PATCH] unit_tests: wallet addresses as variables --- tests/unit_tests/serialization.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 4c927064d..ca4fb9580 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -49,6 +49,10 @@ #include "gtest/gtest.h" using namespace std; +namespace { + static const string ADDRESS1 = "F8ER6NJ6zka6keUKJjX8ry44mVaXuQeVg5dPsuW3gyWRDzxCXpwuHVkMCNmrXZEMVHMFo5zEkoNTeb95hkqWgzMDSWFvana"; + static const string ADDRESS2 = "F85wjfH5DH6Hyo27TbCG98aBDw5J7xEYpJL2QC2cj5TTdinKu3XE6z1Uojry6aa9py94H9RCnQu4gdM6ywERTvCHVfDcMoE"; +} struct Struct { @@ -1156,7 +1160,7 @@ TEST(Serialization, portability_unsigned_tx) // tcd.change_dts ASSERT_TRUE(tcd.change_dts.amount == 7784000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, tcd.change_dts.addr) == "F8ER6NJ6zka6keUKJjX8ry44mVaXuQeVg5dPsuW3gyWRDzxCXpwuHVkMCNmrXZEMVHMFo5zEkoNTeb95hkqWgzMDSWFvana"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, tcd.change_dts.addr) == ADDRESS1); @@ -1168,8 +1172,8 @@ TEST(Serialization, portability_unsigned_tx) ASSERT_TRUE(splitted_dst0.amount == 1000000000000); ASSERT_TRUE(splitted_dst1.amount == 7784000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst0.addr) == "F85wjfH5DH6Hyo27TbCG98aBDw5J7xEYpJL2QC2cj5TTdinKu3XE6z1Uojry6aa9py94H9RCnQu4gdM6ywERTvCHVfDcMoE"); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst1.addr) == "F8ER6NJ6zka6keUKJjX8ry44mVaXuQeVg5dPsuW3gyWRDzxCXpwuHVkMCNmrXZEMVHMFo5zEkoNTeb95hkqWgzMDSWFvana"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst0.addr) == ADDRESS2); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst1.addr) == ADDRESS1); // tcd.selected_transfers ASSERT_TRUE(tcd.selected_transfers.size() == 2); ASSERT_TRUE(tcd.selected_transfers.front() == 0); @@ -1183,7 +1187,7 @@ TEST(Serialization, portability_unsigned_tx) ASSERT_TRUE(tcd.dests.size() == 1); auto& dest = tcd.dests[0]; ASSERT_TRUE(dest.amount == 1000000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, dest.addr) == "F85wjfH5DH6Hyo27TbCG98aBDw5J7xEYpJL2QC2cj5TTdinKu3XE6z1Uojry6aa9py94H9RCnQu4gdM6ywERTvCHVfDcMoE"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, dest.addr) == ADDRESS2); // transfers ASSERT_TRUE(exported_txs.transfers.size() == 2); auto& td0 = exported_txs.transfers[0]; @@ -1273,7 +1277,7 @@ TEST(Serialization, portability_signed_tx) ASSERT_FALSE(ptx.dust_added_to_fee); // ptx.change.{amount, addr} ASSERT_TRUE(ptx.change_dts.amount == 7784000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, ptx.change_dts.addr) == "F8ER6NJ6zka6keUKJjX8ry44mVaXuQeVg5dPsuW3gyWRDzxCXpwuHVkMCNmrXZEMVHMFo5zEkoNTeb95hkqWgzMDSWFvana"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, ptx.change_dts.addr) == ADDRESS1); // ptx.selected_transfers ASSERT_TRUE(ptx.selected_transfers.size() == 2); @@ -1284,7 +1288,7 @@ TEST(Serialization, portability_signed_tx) // ptx.dests ASSERT_TRUE(ptx.dests.size() == 1); ASSERT_TRUE(ptx.dests[0].amount == 1000000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, ptx.dests[0].addr) == "F85wjfH5DH6Hyo27TbCG98aBDw5J7xEYpJL2QC2cj5TTdinKu3XE6z1Uojry6aa9py94H9RCnQu4gdM6ywERTvCHVfDcMoE"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, ptx.dests[0].addr) == ADDRESS2); // ptx.construction_data auto& tcd = ptx.construction_data; ASSERT_TRUE(tcd.sources.size() == 2); @@ -1315,15 +1319,15 @@ TEST(Serialization, portability_signed_tx) ASSERT_TRUE(epee::string_tools::pod_to_hex(tse.mask) == "796309c7e57439028f111714bd04c8bbe22167bd2f7c04c21dc99b0c16478003"); // ptx.construction_data.change_dts ASSERT_TRUE(tcd.change_dts.amount == 7784000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, tcd.change_dts.addr) == "F8ER6NJ6zka6keUKJjX8ry44mVaXuQeVg5dPsuW3gyWRDzxCXpwuHVkMCNmrXZEMVHMFo5zEkoNTeb95hkqWgzMDSWFvana"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, tcd.change_dts.addr) == ADDRESS1); // ptx.construction_data.splitted_dsts ASSERT_TRUE(tcd.splitted_dsts.size() == 2); auto& splitted_dst0 = tcd.splitted_dsts[0]; auto& splitted_dst1 = tcd.splitted_dsts[1]; ASSERT_TRUE(splitted_dst0.amount == 1000000000000); ASSERT_TRUE(splitted_dst1.amount == 7784000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst0.addr) == "F85wjfH5DH6Hyo27TbCG98aBDw5J7xEYpJL2QC2cj5TTdinKu3XE6z1Uojry6aa9py94H9RCnQu4gdM6ywERTvCHVfDcMoE"); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst1.addr) == "F8ER6NJ6zka6keUKJjX8ry44mVaXuQeVg5dPsuW3gyWRDzxCXpwuHVkMCNmrXZEMVHMFo5zEkoNTeb95hkqWgzMDSWFvana"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst0.addr) == ADDRESS2); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, splitted_dst1.addr) == ADDRESS1); // ptx.construction_data.selected_transfers ASSERT_TRUE(tcd.selected_transfers.size() == 2); ASSERT_TRUE(tcd.selected_transfers.front() == 0); @@ -1336,7 +1340,7 @@ TEST(Serialization, portability_signed_tx) ASSERT_TRUE(tcd.dests.size() == 1); auto& dest = tcd.dests[0]; ASSERT_TRUE(dest.amount == 1000000000000); - ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, dest.addr) == "F85wjfH5DH6Hyo27TbCG98aBDw5J7xEYpJL2QC2cj5TTdinKu3XE6z1Uojry6aa9py94H9RCnQu4gdM6ywERTvCHVfDcMoE"); + ASSERT_TRUE(cryptonote::get_account_address_as_str(testnet, dest.addr) == ADDRESS2); // key_images ASSERT_TRUE(exported_txs.key_images.size() == 2); auto& ki0 = exported_txs.key_images[0];