Skip to content

Commit

Permalink
Merge pull request #75 from BitHaru/master
Browse files Browse the repository at this point in the history
add official invited representatives
  • Loading branch information
BitHaru committed Jul 28, 2020
2 parents c10d055 + 2ea2652 commit 1e92c70
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
68 changes: 68 additions & 0 deletions invite/live.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"representatives": [
{
"account": "rai_3h5s5bgaf1jp1rofe5umxan84kiwxj3ppeuyids7zzaxahsohzchcyxqzwp6",
"description": "official node #1"
},
{
"account": "rai_1os5ozxsjajpnkdj6zghzdy5fjncpa6egkjisgggutxkbmqicc8mjjfy87ja",
"description": "official node #2"
},
{
"account": "rai_1khj7pa81ffn3o44jfqopeoq3apxpdagpjo9gu1nwc6x9ccpjggjouhifkkw",
"description": "official node #3"
},
{
"account": "rai_1b5wb8hs5d3u5q8cnesk5xprr4damryn9xmrju7grdrtq6sxpanrwjo4s4r3",
"description": "official node #4"
},
{
"account": "rai_391mam7h9gxedh3bg9ge44tmbt3c5mutott7ug99u6eqdouwgftzed1tz9i5",
"description": "official node #5"
},
{
"account": "rai_3fbshbikq9w5pz8hpm4bcp1ugzamkqq8sqpch6qd4oy1bwrwdzjpj6fyhbio",
"description": "official node #6"
},
{
"account": "rai_1pypba9m6biy44zhdw8csa5imd3aaw6w6nbhh58zijf4hrgfres44ate77ug",
"description": "official node #7"
},
{
"account": "rai_11nfiez6ubhgstcro88t8i3ucu9qze156tue5qg71fo3ghnoc1r8djbpnmqb",
"description": "official node #8"
},
{
"account": "rai_1gz6mxhbo444x383x1r4ea76nbwnnf4696ozwpfjkfuh5qi7wabu6fdemc6h",
"description": "official node #9"
},
{
"account": "rai_15m7mxx3guow47edzmiaoou1nqt88j63hnb6hjwi8i1k6wzsfz7i9kuyye8a",
"description": "official node #10"
},
{
"account": "rai_1p66d48udbjeea6at1aym7a5p9io966hrga4fnf13ywescic5toq58mu5sr8",
"description": "official node #11"
},
{
"account": "rai_1ytzjbtxwzxez5mh8px5sbns78tsfb1xn3ie5763uatrcpi3aqyt6wcdrpm1",
"description": "official node #12"
},
{
"account": "rai_3ich9rzfa33mofyunw4d31snjtu9ah74unjwkji1qwnak64j61a75e9kyzrf",
"description": "official node #13"
},
{
"account": "rai_3eyiwwhz9kzsiq651x5q3x5j4efzzh8muhw6e1bsxfu8gfcp71dbzy96eek3",
"description": "official node #14"
},
{
"account": "rai_3eiaxmgj374qw9wdrqdpdsu4uujx8z3utq8b8bwerrjc9mrthzcag3obydsd",
"description": "official node #15"
},
{
"account": "rai_1muooox7mmcbu1wjby4b1h9ckx6764cmp8ufi5das8bgbcz88rzenowa18tc",
"description": "official node #16"
}
]
}
1 change: 1 addition & 0 deletions rai/core_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_executable (core_test
lmdb.cpp
numbers.cpp
test_util.cpp
invite.cpp
)

#target_compile_definitions(core_test
Expand Down
94 changes: 94 additions & 0 deletions rai/core_test/invite.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <unordered_set>
#include <gtest/gtest.h>
#include <boost/filesystem.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <rai/common/util.hpp>
#include <rai/common/numbers.hpp>

TEST(invite, BETA)
{
try
{
boost::filesystem::path file_path = "../invite/beta.json";
ASSERT_TRUE(boost::filesystem::exists(file_path));

std::fstream fs;
fs.open(file_path.string(), std::ios_base::in);
ASSERT_FALSE(fs.fail());

rai::Ptree ptree;
boost::property_tree::read_json(fs, ptree);

std::unordered_set<rai::Account> reps;
rai::Ptree reps_ptree = ptree.get_child("representatives");
for (const auto& i : reps_ptree)
{
rai::Account rep;
auto account = i.second.get<std::string>("account");
bool error = rep.DecodeAccount(account);
if (error)
{
std::cout << "Invalid account field:" << account << std::endl;
ASSERT_FALSE(true);
}

if (reps.find(rep) != reps.end())
{
std::cout << "Duplicate account field :" << account
<< std::endl;
ASSERT_FALSE(true);
}

reps.insert(rep);
}
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
ASSERT_TRUE(false);
}
}

TEST(invite, LIVE)
{
try
{
boost::filesystem::path file_path = "../invite/live.json";
ASSERT_TRUE(boost::filesystem::exists(file_path));

std::fstream fs;
fs.open(file_path.string(), std::ios_base::in);
ASSERT_FALSE(fs.fail());

rai::Ptree ptree;
boost::property_tree::read_json(fs, ptree);

std::unordered_set<rai::Account> reps;
rai::Ptree reps_ptree = ptree.get_child("representatives");
for (const auto& i : reps_ptree)
{
rai::Account rep;
auto account = i.second.get<std::string>("account");
bool error = rep.DecodeAccount(account);
if (error)
{
std::cout << "Invalid account field:" << account << std::endl;
ASSERT_FALSE(true);
}

if (reps.find(rep) != reps.end())
{
std::cout << "Duplicate account field :" << account
<< std::endl;
ASSERT_FALSE(true);
}

reps.insert(rep);
}
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
ASSERT_TRUE(false);
}
}

0 comments on commit 1e92c70

Please sign in to comment.