Electroneum
Loading...
Searching...
No Matches
address_from_url.cpp File Reference
#include "gtest/gtest.h"
#include "wallet/wallet2.h"
#include "common/dns_utils.h"
#include "simplewallet/simplewallet.h"
#include <string>
Include dependency graph for address_from_url.cpp:

Go to the source code of this file.

Functions

 TEST (AddressFromTXT, Success)
 TEST (AddressFromTXT, Failure)
 TEST (AddressFromURL, Success)
 TEST (AddressFromURL, Failure)

Function Documentation

◆ TEST() [1/4]

TEST ( AddressFromTXT ,
Failure  )

Definition at line 72 of file address_from_url.cpp.

73{
74 std::string txtr = "oa1:etn recipient_address=not a real address";
75
77
78 ASSERT_STREQ("", res.c_str());
79
80 txtr += ";";
81
83 ASSERT_STREQ("", res.c_str());
84}
#define ASSERT_STREQ(s1, s2)
Definition gtest.h:2004
const char * res
std::string address_from_txt_record(const std::string &s)
Here is the call graph for this function:

◆ TEST() [2/4]

TEST ( AddressFromTXT ,
Success  )

Definition at line 39 of file address_from_url.cpp.

40{
41 std::string addr = "etnjwQwwEY65dhSMfKto64GgY7j7q2RUSZP1r8rXZ615J4egUC596R4crvZ5woWWTWBUztnKMUudzQ22E37LHiV48XWeJDFkkY";
42
43 std::string txtr = "oa1:etn";
44 txtr += " recipient_address=";
45 txtr += addr;
46 txtr += ";";
47
49
50 EXPECT_STREQ(addr.c_str(), res.c_str());
51
52 std::string txtr2 = "foobar";
53
54 txtr2 += txtr;
55
56 txtr2 += "more foobar";
57
59
60 EXPECT_STREQ(addr.c_str(), res.c_str());
61
62 std::string txtr3 = "foobar oa1:etn tx_description=\"Donation for Electroneum Development Fund\"; ";
63 txtr3 += "recipient_address=";
64 txtr3 += addr;
65 txtr3 += "; foobar";
66
68
69 EXPECT_STREQ(addr.c_str(), res.c_str());
70}
#define EXPECT_STREQ(s1, s2)
Definition gtest.h:1995
Here is the call graph for this function:

◆ TEST() [3/4]

TEST ( AddressFromURL ,
Failure  )

Definition at line 109 of file address_from_url.cpp.

110{
111 bool dnssec_result = false;
112
113 std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("example.veryinvalid", dnssec_result);
114
115 // for a non-existing domain such as "example.invalid", the non-existence is proved with NSEC records
116 ASSERT_TRUE(dnssec_result);
117
118 ASSERT_EQ(0, addresses.size());
119}
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
#define ASSERT_TRUE(condition)
Definition gtest.h:1865
std::vector< std::string > addresses_from_url(const std::string &url, bool &dnssec_valid)
gets a electroneum address from the TXT record of a DNS entry
Here is the call graph for this function:

◆ TEST() [4/4]

TEST ( AddressFromURL ,
Success  )

Definition at line 86 of file address_from_url.cpp.

87{
88 const std::string addr = ETN_DONATION_ADDR;
89
90 bool dnssec_result = false;
91
92 std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("donate.electroneum.com", dnssec_result);
93
94 EXPECT_EQ(1, addresses.size());
95 if (addresses.size() == 1)
96 {
97 EXPECT_STREQ(addr.c_str(), addresses[0].c_str());
98 }
99
100 // OpenAlias address with an @ instead of first .
101 addresses = tools::dns_utils::addresses_from_url("donate@electroneum.com", dnssec_result);
102 EXPECT_EQ(1, addresses.size());
103 if (addresses.size() == 1)
104 {
105 EXPECT_STREQ(addr.c_str(), addresses[0].c_str());
106 }
107}
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1922
constexpr const char ETN_DONATION_ADDR[]
Here is the call graph for this function: