use of snowblossom.node.SnowBlossomNode in project snowblossom by snowblossomcoin.
the class SpoonTestPoolTls method spoonPoolTest.
@Test
public void spoonPoolTest() throws Exception {
File snow_path = setupSnow();
Random rnd = new Random();
int port = 20000 + rnd.nextInt(30000);
SnowBlossomNode node = startNode(port);
Thread.sleep(2000);
KeyPair key_pair = KeyUtil.generateECCompressedKey();
AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
KeyPair key_pair2 = KeyUtil.generateECCompressedKey();
AddressSpec claim2 = AddressUtil.getSimpleSpecForKey(key_pair2.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr2 = AddressUtil.getHashForSpec(claim2);
KeyPair key_pair3 = KeyUtil.generateECCompressedKey();
AddressSpec claim3 = AddressUtil.getSimpleSpecForKey(key_pair3.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr3 = AddressUtil.getHashForSpec(claim3);
SnowBlossomClient client = startClient(port);
MrPlow plow = startMrPlow(port, to_addr2);
Thread.sleep(4000);
String uri = "grpc+tls://localhost:" + plow.getGrpcTlsPort();
PoolMiner miner = startPoolMinerUri(uri, to_addr, snow_path, "spoon");
Thread.sleep(25000);
waitForMoreBlocks(node, 10);
System.out.println("ShareMap: " + plow.getShareManager().getShareMap());
System.out.println("ShareMap pay: " + plow.getShareManager().getPayRatios());
// Pool getting paid
waitForFunds(client, to_addr2, 10);
// Miner getting paid
waitForFunds(client, to_addr, 30);
String uri_key = uri + "/?key=" + plow.getTlsKeyId();
PoolMiner miner2 = startPoolMinerUri(uri_key, to_addr3, snow_path, "spoon");
// Second miner getting paid
waitForFunds(client, to_addr3, 30);
miner.stop();
miner2.stop();
Thread.sleep(500);
plow.stop();
node.stop();
}
use of snowblossom.node.SnowBlossomNode in project snowblossom by snowblossomcoin.
the class SpoonTestReconsile method networkReconsileTest.
@Test
public void networkReconsileTest() throws Exception {
File snow_path = setupSnow();
Random rnd = new Random();
int port = 20000 + rnd.nextInt(30000);
SnowBlossomNode node1 = startNode(port);
SnowBlossomNode node2 = startNode(port + 1);
Thread.sleep(100);
KeyPair key_pair = KeyUtil.generateECCompressedKey();
AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
SnowBlossomMiner miner1 = startMiner(port, to_addr, snow_path);
SnowBlossomMiner miner2 = startMiner(port + 1, to_addr, snow_path);
testMinedBlocks(node1);
testMinedBlocks(node2);
// Two nodes are on different blocks, they are not connected
Assert.assertNotEquals(node1.getDB().getBlockHashAtHeight(2), node2.getDB().getBlockHashAtHeight(2));
// Connect them
node2.getPeerage().connectPeer("localhost", port);
Thread.sleep(2000);
miner1.stop();
miner2.stop();
Thread.sleep(500);
// Then they should be the same
Assert.assertEquals(node1.getDB().getBlockHashAtHeight(2), node2.getDB().getBlockHashAtHeight(2));
Thread.sleep(500);
node1.stop();
node2.stop();
}
use of snowblossom.node.SnowBlossomNode in project snowblossom by snowblossomcoin.
the class NodePanel method startNode.
private void startNode() throws Exception {
// There are too many side effects to try this more than once
start_attempt = true;
TreeMap<String, String> config_map = new TreeMap();
config_map.put("network", ice_leaf.getParams().getNetworkName());
config_map.put("service_port", ice_leaf_prefs.get("node_service_port", null));
config_map.put("tls_service_port", ice_leaf_prefs.get("node_tls_service_port", null));
config_map.put("db_path", ice_leaf_prefs.get("node_db_path", null));
config_map.put("db_type", "rocksdb");
config_map.put("tls_key_path", ice_leaf_prefs.get("node_tls_key_path", null));
config_map.put("tx_index", "" + ice_leaf_prefs.getBoolean("node_tx_index", true));
config_map.put("addr_index", "" + ice_leaf_prefs.getBoolean("node_addr_index", true));
setMessageBox(config_map.toString());
ConfigMem config = new ConfigMem(config_map);
node = new SnowBlossomNode(config, ImmutableList.of(new StatusLogger(), this));
setStatusBox("Node started");
setMessageBox("");
}
use of snowblossom.node.SnowBlossomNode in project snowblossom by snowblossomcoin.
the class ShardTestPeering method shardTest.
@Test
public void shardTest() throws Exception {
File snow_path = setupSnow("regshard");
Random rnd = new Random();
int port = 20000 + rnd.nextInt(30000);
SnowBlossomNode node1 = startNode(port, "regshard");
Thread.sleep(100);
SnowBlossomNode node2 = startNode(port + 1, "regshard");
Thread.sleep(100);
node2.getPeerage().connectPeer("localhost", port);
KeyPair key_pair = KeyUtil.generateECCompressedKey();
AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
SnowBlossomMiner miner = startMiner(port, to_addr, snow_path, "regshard");
waitForHeight(node1, 0, 19, 45);
waitForHeight(node1, 1, 28, 45);
waitForHeight(node1, 2, 28, 5);
waitForHeight(node2, 0, 19, 30);
waitForHeight(node2, 1, 28, 25);
waitForHeight(node2, 2, 28, 5);
miner.stop();
Thread.sleep(500);
node1.stop();
node2.stop();
}
use of snowblossom.node.SnowBlossomNode in project snowblossom by snowblossomcoin.
the class SpoonTest method startNode.
protected SnowBlossomNode startNode(int port, String network, Map<String, String> extra) throws Exception {
String test_folder_base = test_folder.newFolder().getPath();
Map<String, String> config_map = new TreeMap<>();
config_map.put("db_path", test_folder_base + "/db");
config_map.put("db_type", "rocksdb");
config_map.put("service_port", "" + port);
config_map.put("network", network);
config_map.put("tx_index", "true");
config_map.put("addr_index", "true");
config_map.put("peer_count", "64");
if (extra != null) {
config_map.putAll(extra);
}
return new SnowBlossomNode(new ConfigMem(config_map));
}
Aggregations