<commit_before>// Copyright (c) 2016-2018 The Syscoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <test/test_syscoin_services.h>
#include <util/time.h>
#include <util/system.h>
#include <amount.h>
#include <rpc/server.h>
#include <services/asset.h>
#include <services/assetallocation.h>
#include <wallet/crypter.h>
#include <random.h>
#include <base58.h>
#include <chainparams.h>
#include <core_io.h>
#include <key_io.h>
#include <memory>
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
#include <bech32.h>
#include <rpc/util.h>
#include <services/rpc/assetrpc.h>
static int node1LastBlock = 0;
static int node2LastBlock = 0;
static int node3LastBlock = 0;
static bool node1Online = false;
static bool node2Online = false;
static bool node3Online = false;
std::map<string, string> mapNodes;
// create a map between node alias names and URLs to be used in testing for example CallRPC("mynode", "getblockchaininfo") would call getblockchaininfo on the node alias mynode which would be pushed as a URL here.
// it is assumed RPC ports are open and u:p is the authentication
void InitNodeURLMap() {
	mapNodes.clear();
	mapNodes["node1"] = "http://127.0.0.1:28379";
	mapNodes["node2"] = "http://127.0.0.1:38379";
	mapNodes["node3"] = "http://127.0.0.1:48379";

}
// lookup the URL based on node passed in
string LookupURL(const string& node) {
	if (mapNodes.find(node) != mapNodes.end())
		return mapNodes[node];
	return "";
}
// SYSCOIN testing setup
void StartNodes()
{
	printf("Stopping any test nodes that are running...\n");
	InitNodeURLMap();
	StopNodes();
    if (boost::filesystem::exists(boost::filesystem::system_complete("node1/regtest")))
        boost::filesystem::remove_all(boost::filesystem::system_complete("node1/regtest")); 
    if (boost::filesystem::exists(boost::filesystem::system_complete("node2/regtest")))
        boost::filesystem::remove_all(boost::filesystem::system_complete("node2/regtest"));  
    if (boost::filesystem::exists(boost::filesystem::system_complete("node3/regtest")))
        boost::filesystem::remove_all(boost::filesystem::system_complete("node3/regtest"));                     
	node1LastBlock = 0;
	node2LastBlock = 0;
	node3LastBlock = 0;
	//StopMainNetNodes();
	printf("Starting 3 nodes in a regtest setup...\n");
	StartNode("node1");
    BOOST_CHECK_NO_THROW(CallExtRPC("node1", "generate", "5"));
	StartNode("node2");
	StartNode("node3");

}
void StartMainNetNodes()
{
	StopMainNetNodes();
	printf("Starting 2 nodes in mainnet setup...\n");
	StartNode("mainnet1", false);
	SelectParams(CBaseChainParams::MAIN);

}
void StopMainNetNodes()
{
	printf("Stopping mainnet1..\n");
	StopNode("mainnet1", false);
	printf("Done!\n");
}
void StopNodes()
{
	StopNode("node1");
	StopNode("node2");
	StopNode("node3");
	printf("Done!\n");
}
void StartNode(const string &dataDir, bool regTest, const string& extraArgs, bool reindex)
{
	boost::filesystem::path fpath = boost::filesystem::system_complete("../syscoind");
	string nodePath = fpath.string() + string(" -unittest -tpstest -assetindex -daemon -server -debug=syscoin -concurrentprocessing=1 -datadir=") + dataDir;
	if (regTest)
		nodePath += string(" -regtest");
	if (reindex)
		nodePath += string(" -reindex");		
	if (!extraArgs.empty())
		nodePath += string(" ") + extraArgs;

	boost::thread t(runCommand, nodePath);
	printf("Launching %s, waiting 1 second before trying to ping...\n", nodePath.c_str());
	MilliSleep(1000);
	UniValue r;
	while (1)<commit_msg>remove debug<commit_after>// Copyright (c) 2016-2018 The Syscoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <test/test_syscoin_services.h>
#include <util/time.h>
#include <util/system.h>
#include <amount.h>
#include <rpc/server.h>
#include <services/asset.h>
#include <services/assetallocation.h>
#include <wallet/crypter.h>
#include <random.h>
#include <base58.h>
#include <chainparams.h>
#include <core_io.h>
#include <key_io.h>
#include <memory>
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
#include <bech32.h>
#include <rpc/util.h>
#include <services/rpc/assetrpc.h>
static int node1LastBlock = 0;
static int node2LastBlock = 0;
static int node3LastBlock = 0;
static bool node1Online = false;
static bool node2Online = false;
static bool node3Online = false;
std::map<string, string> mapNodes;
// create a map between node alias names and URLs to be used in testing for example CallRPC("mynode", "getblockchaininfo") would call getblockchaininfo on the node alias mynode which would be pushed as a URL here.
// it is assumed RPC ports are open and u:p is the authentication
void InitNodeURLMap() {
	mapNodes.clear();
	mapNodes["node1"] = "http://127.0.0.1:28379";
	mapNodes["node2"] = "http://127.0.0.1:38379";
	mapNodes["node3"] = "http://127.0.0.1:48379";

}
// lookup the URL based on node passed in
string LookupURL(const string& node) {
	if (mapNodes.find(node) != mapNodes.end())
		return mapNodes[node];
	return "";
}
// SYSCOIN testing setup
void StartNodes()
{
	printf("Stopping any test nodes that are running...\n");
	InitNodeURLMap();
	StopNodes();
    if (boost::filesystem::exists(boost::filesystem::system_complete("node1/regtest")))
        boost::filesystem::remove_all(boost::filesystem::system_complete("node1/regtest")); 
    if (boost::filesystem::exists(boost::filesystem::system_complete("node2/regtest")))
        boost::filesystem::remove_all(boost::filesystem::system_complete("node2/regtest"));  
    if (boost::filesystem::exists(boost::filesystem::system_complete("node3/regtest")))
        boost::filesystem::remove_all(boost::filesystem::system_complete("node3/regtest"));                     
	node1LastBlock = 0;
	node2LastBlock = 0;
	node3LastBlock = 0;
	//StopMainNetNodes();
	printf("Starting 3 nodes in a regtest setup...\n");
	StartNode("node1");
    BOOST_CHECK_NO_THROW(CallExtRPC("node1", "generate", "5"));
	StartNode("node2");
	StartNode("node3");

}
void StartMainNetNodes()
{
	StopMainNetNodes();
	printf("Starting 2 nodes in mainnet setup...\n");
	StartNode("mainnet1", false);
	SelectParams(CBaseChainParams::MAIN);

}
void StopMainNetNodes()
{
	printf("Stopping mainnet1..\n");
	StopNode("mainnet1", false);
	printf("Done!\n");
}
void StopNodes()
{
	StopNode("node1");
	StopNode("node2");
	StopNode("node3");
	printf("Done!\n");
}
void StartNode(const string &dataDir, bool regTest, const string& extraArgs, bool reindex)
{
	boost::filesystem::path fpath = boost::filesystem::system_complete("../syscoind");
	string nodePath = fpath.string() + string(" -unittest -tpstest -assetindex -daemon -server -debug=0 -concurrentprocessing=1 -datadir=") + dataDir;
	if (regTest)
		nodePath += string(" -regtest");
	if (reindex)
		nodePath += string(" -reindex");		
	if (!extraArgs.empty())
		nodePath += string(" ") + extraArgs;

	boost::thread t(runCommand, nodePath);
	printf("Launching %s, waiting 1 second before trying to ping...\n", nodePath.c_str());
	MilliSleep(1000);
	UniValue r;
	while (1)
{'fraction_non_alphanumeric': 0.15943409059991837, 'fraction_numerical': 0.024350428513127464, 'mean_word_length': 5.381944444444445, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6796244', 'n_tokens_mistral': 2574, 'n_tokens_neox': 2447, 'n_words': 586}