Add stoffu fixes to rename

This commit is contained in:
jwinterm 2018-06-04 19:33:16 -07:00
parent be6320b1a2
commit 3c4e299b34
2 changed files with 31 additions and 31 deletions

View File

@ -10167,13 +10167,13 @@ std::string wallet2::make_uri(const std::string &address, const std::string &pay
//----------------------------------------------------------------------------------------------------
bool wallet2::parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector<std::string> &unknown_parameters, std::string &error)
{
if (uri.substr(0, 7) != "wownero:")
if (uri.substr(0, 8) != "wownero:")
{
error = std::string("URI has wrong scheme (expected \"wownero:\"): ") + uri;
return false;
}
std::string remainder = uri.substr(7);
std::string remainder = uri.substr(8);
const char *ptr = strchr(remainder.c_str(), '?');
address = ptr ? remainder.substr(0, ptr-remainder.c_str()) : remainder;

View File

@ -48,7 +48,7 @@ TEST(uri, empty_string)
TEST(uri, no_scheme)
{
PARSE_URI("monero", false);
PARSE_URI("wownero", false);
}
TEST(uri, bad_scheme)
@ -58,75 +58,75 @@ TEST(uri, bad_scheme)
TEST(uri, scheme_not_first)
{
PARSE_URI(" monero:", false);
PARSE_URI(" wownero:", false);
}
TEST(uri, no_body)
{
PARSE_URI("monero:", false);
PARSE_URI("wownero:", false);
}
TEST(uri, no_address)
{
PARSE_URI("monero:?", false);
PARSE_URI("wownero:?", false);
}
TEST(uri, bad_address)
{
PARSE_URI("monero:44444", false);
PARSE_URI("wownero:44444", false);
}
TEST(uri, good_address)
{
PARSE_URI("monero:" TEST_ADDRESS, true);
PARSE_URI("wownero:" TEST_ADDRESS, true);
ASSERT_EQ(address, TEST_ADDRESS);
}
TEST(uri, good_integrated_address)
{
PARSE_URI("monero:" TEST_INTEGRATED_ADDRESS, true);
PARSE_URI("wownero:" TEST_INTEGRATED_ADDRESS, true);
}
TEST(uri, parameter_without_inter)
{
PARSE_URI("monero:" TEST_ADDRESS"&amount=1", false);
PARSE_URI("wownero:" TEST_ADDRESS"&amount=1", false);
}
TEST(uri, parameter_without_equals)
{
PARSE_URI("monero:" TEST_ADDRESS"?amount", false);
PARSE_URI("wownero:" TEST_ADDRESS"?amount", false);
}
TEST(uri, parameter_without_value)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_amount=", false);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_amount=", false);
}
TEST(uri, negative_amount)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_amount=-1", false);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_amount=-1", false);
}
TEST(uri, bad_amount)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_amount=alphanumeric", false);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_amount=alphanumeric", false);
}
TEST(uri, duplicate_parameter)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_amount=1&tx_amount=1", false);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_amount=1&tx_amount=1", false);
}
TEST(uri, unknown_parameter)
{
PARSE_URI("monero:" TEST_ADDRESS"?unknown=1", true);
PARSE_URI("wownero:" TEST_ADDRESS"?unknown=1", true);
ASSERT_EQ(unknown_parameters.size(), 1);
ASSERT_EQ(unknown_parameters[0], "unknown=1");
}
TEST(uri, unknown_parameters)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_amount=1&unknown=1&tx_description=desc&foo=bar", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_amount=1&unknown=1&tx_description=desc&foo=bar", true);
ASSERT_EQ(unknown_parameters.size(), 2);
ASSERT_EQ(unknown_parameters[0], "unknown=1");
ASSERT_EQ(unknown_parameters[1], "foo=bar");
@ -134,84 +134,84 @@ TEST(uri, unknown_parameters)
TEST(uri, empty_payment_id)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_payment_id=", false);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_payment_id=", false);
}
TEST(uri, bad_payment_id)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_payment_id=1234567890", false);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_payment_id=1234567890", false);
}
TEST(uri, short_payment_id)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_payment_id=1234567890123456", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_payment_id=1234567890123456", true);
ASSERT_EQ(address, TEST_ADDRESS);
ASSERT_EQ(payment_id, "1234567890123456");
}
TEST(uri, long_payment_id)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_payment_id=1234567890123456789012345678901234567890123456789012345678901234", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_payment_id=1234567890123456789012345678901234567890123456789012345678901234", true);
ASSERT_EQ(address, TEST_ADDRESS);
ASSERT_EQ(payment_id, "1234567890123456789012345678901234567890123456789012345678901234");
}
TEST(uri, payment_id_with_integrated_address)
{
PARSE_URI("monero:" TEST_INTEGRATED_ADDRESS"?tx_payment_id=1234567890123456", false);
PARSE_URI("wownero:" TEST_INTEGRATED_ADDRESS"?tx_payment_id=1234567890123456", false);
}
TEST(uri, empty_description)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_description=", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_description=", true);
ASSERT_EQ(description, "");
}
TEST(uri, empty_recipient_name)
{
PARSE_URI("monero:" TEST_ADDRESS"?recipient_name=", true);
PARSE_URI("wownero:" TEST_ADDRESS"?recipient_name=", true);
ASSERT_EQ(recipient_name, "");
}
TEST(uri, non_empty_description)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_description=foo", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_description=foo", true);
ASSERT_EQ(description, "foo");
}
TEST(uri, non_empty_recipient_name)
{
PARSE_URI("monero:" TEST_ADDRESS"?recipient_name=foo", true);
PARSE_URI("wownero:" TEST_ADDRESS"?recipient_name=foo", true);
ASSERT_EQ(recipient_name, "foo");
}
TEST(uri, url_encoding)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_description=foo%20bar", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_description=foo%20bar", true);
ASSERT_EQ(description, "foo bar");
}
TEST(uri, non_alphanumeric_url_encoding)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_description=foo%2x", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_description=foo%2x", true);
ASSERT_EQ(description, "foo%2x");
}
TEST(uri, truncated_url_encoding)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_description=foo%2", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_description=foo%2", true);
ASSERT_EQ(description, "foo%2");
}
TEST(uri, percent_without_url_encoding)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_description=foo%", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_description=foo%", true);
ASSERT_EQ(description, "foo%");
}
TEST(uri, url_encoded_once)
{
PARSE_URI("monero:" TEST_ADDRESS"?tx_description=foo%2020", true);
PARSE_URI("wownero:" TEST_ADDRESS"?tx_description=foo%2020", true);
ASSERT_EQ(description, "foo 20");
}