Fabcoin Core  0.16.2
P2P Digital Currency
icap.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #include <boost/test/unit_test.hpp>
23 #include <libethcore/ICAP.h>
25 
26 using namespace std;
27 using namespace dev;
28 using namespace dev::eth;
29 using namespace dev::test;
30 
32 
33 BOOST_AUTO_TEST_CASE(addressEncoding)
34 {
35  Address address("0x52dc504a422f0e2a9e7632a34a50f1a82f8224c7");
36  ICAP icap(address);
37  BOOST_CHECK_EQUAL(icap.encoded(), "XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7");
38 }
39 
40 BOOST_AUTO_TEST_CASE(addressEncodingRandomString)
41 {
42  Address address("0x11c5496aee77c1ba1f0854206a26dda82a81d6d8");
43  ICAP icap(address);
44  BOOST_CHECK_EQUAL(icap.encoded(), "XE1222Q908LN1QBBU6XUQSO1OHWJIOS46OO");
45 }
46 
47 BOOST_AUTO_TEST_CASE(addressEncodingWithZeroPrefix)
48 {
49  Address address("0x00c5496aee77c1ba1f0854206a26dda82a81d6d8");
50  ICAP icap(address);
51  BOOST_CHECK_EQUAL(icap.encoded(), "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS");
52 }
53 
54 BOOST_AUTO_TEST_CASE(addressDecoding)
55 {
56  Address address("0x52dc504a422f0e2a9e7632a34a50f1a82f8224c7");
57  ICAP icap = ICAP::decoded("XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7");
59 }
60 
61 BOOST_AUTO_TEST_CASE(addressDecodingRandomString)
62 {
63  Address address("0x11c5496aee77c1ba1f0854206a26dda82a81d6d8");
64  ICAP icap = ICAP::decoded("XE1222Q908LN1QBBU6XUQSO1OHWJIOS46OO");
66 }
67 
68 BOOST_AUTO_TEST_CASE(addressDecodingWithZeroPrefix)
69 {
70  Address address("0x00c5496aee77c1ba1f0854206a26dda82a81d6d8");
71  ICAP icap = ICAP::decoded("XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS");
73 }
74 
75 BOOST_AUTO_TEST_CASE(addressDecodingAndEncoding)
76 {
77  std::string encoded = "XE499OG1EH8ZZI0KXC6N83EKGT1BM97P2O7";
78  ICAP icap = ICAP::decoded(encoded);
79  BOOST_CHECK_EQUAL(icap.encoded(), encoded);
80 }
81 
std::string encoded() const
Definition: ICAP.cpp:110
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::hash for asio::adress
Definition: Common.h:323
BOOST_AUTO_TEST_CASE(addressEncoding)
Definition: icap.cpp:33
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
Encapsulation of an ICAP address.
Definition: ICAP.h:45
Address const & direct() const
Definition: ICAP.h:81
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
struct evm_uint160be address(struct evm_env *env)
Definition: capi.c:13
Helper functions to work with json::spirit and test files.