Search in sources :

Example 1 with SnowBlossomMiner

use of snowblossom.miner.SnowBlossomMiner in project snowblossom by snowblossomcoin.

the class ShardTestBasic method shardTest.

@Test
public void shardTest() throws Exception {
    File snow_path = setupSnow("regshard");
    SnowBlossomNode node = startNode(0, "regshard");
    int port = node.getServicePorts().get(0);
    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 miner = startMiner(port, to_addr, snow_path, "regshard");
    SnowBlossomMiner miner2 = startMiner(port, to_addr, snow_path, "regshard");
    waitForHeight(node, 0, 19, 75);
    waitForHeight(node, 1, 27, 35);
    waitForHeight(node, 2, 27, 25);
    waitForHeight(node, 3, 37, 35);
    waitForHeight(node, 4, 37, 25);
    waitForHeight(node, 5, 37, 25);
    waitForHeight(node, 6, 37, 25);
    miner.stop();
    miner2.stop();
    Thread.sleep(500);
    node.stop();
}
Also used : KeyPair(java.security.KeyPair) SnowBlossomMiner(snowblossom.miner.SnowBlossomMiner) SnowBlossomNode(snowblossom.node.SnowBlossomNode) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) Test(org.junit.Test)

Example 2 with SnowBlossomMiner

use of snowblossom.miner.SnowBlossomMiner in project snowblossom by snowblossomcoin.

the class ShardTestDuelPool method shardTest.

/**
 * Run two groups of nodes that don't trust each other
 */
@Test
public void shardTest() throws Exception {
    File snow_path = setupSnow("regshard");
    String trust_folder_base_a = test_folder.newFolder().getPath();
    String trust_folder_base_b = test_folder.newFolder().getPath();
    node_a_seed = startNode(0, "regshard", ImmutableMap.of("shards", "0", "trustnet_key_path", trust_folder_base_a));
    node_b_seed = startNode(0, "regshard", ImmutableMap.of("shards", "0", "trustnet_key_path", trust_folder_base_b));
    AddressSpecHash trust_addr_a = node_a_seed.getTrustnetAddress();
    String trust_str_a = AddressUtil.getAddressString("node", trust_addr_a);
    AddressSpecHash trust_addr_b = node_b_seed.getTrustnetAddress();
    String trust_str_b = AddressUtil.getAddressString("node", trust_addr_b);
    node_a_1 = startNode(0, "regshard", ImmutableMap.of("shards", "1", "trustnet_key_path", trust_folder_base_a, "trustnet_signers", trust_str_a));
    node_a_2 = startNode(0, "regshard", ImmutableMap.of("shards", "2", "trustnet_key_path", trust_folder_base_a, "trustnet_signers", trust_str_a));
    node_b_1 = startNode(0, "regshard", ImmutableMap.of("shards", "1", "trustnet_key_path", trust_folder_base_b, "trustnet_signers", trust_str_b));
    node_b_2 = startNode(0, "regshard", ImmutableMap.of("shards", "2", "trustnet_key_path", trust_folder_base_b, "trustnet_signers", trust_str_b));
    int seed_port = node_a_seed.getServicePorts().get(0);
    Thread.sleep(100);
    node_a_1.getPeerage().connectPeer("localhost", seed_port);
    node_a_2.getPeerage().connectPeer("localhost", seed_port);
    node_b_1.getPeerage().connectPeer("localhost", seed_port);
    node_b_2.getPeerage().connectPeer("localhost", seed_port);
    node_b_seed.getPeerage().connectPeer("localhost", seed_port);
    Thread.sleep(3000);
    KeyPair key_pair_a = KeyUtil.generateECCompressedKey();
    AddressSpec claim_a = AddressUtil.getSimpleSpecForKey(key_pair_a.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr_a = AddressUtil.getHashForSpec(claim_a);
    KeyPair key_pair_b = KeyUtil.generateECCompressedKey();
    AddressSpec claim_b = AddressUtil.getSimpleSpecForKey(key_pair_b.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
    AddressSpecHash to_addr_b = AddressUtil.getHashForSpec(claim_b);
    SnowBlossomMiner miner1 = startMiner(node_a_1.getServicePorts().get(0), to_addr_a, snow_path, "regshard");
    SnowBlossomMiner miner2 = startMiner(node_a_2.getServicePorts().get(0), to_addr_a, snow_path, "regshard");
    SnowBlossomMiner miner3 = startMiner(node_b_1.getServicePorts().get(0), to_addr_b, snow_path, "regshard");
    SnowBlossomMiner miner4 = startMiner(node_b_2.getServicePorts().get(0), to_addr_b, snow_path, "regshard");
    waitForHeight(node_b_seed, 3, 36, 100);
    waitForHeight(node_b_seed, 4, 36, 80);
    waitForHeight(node_b_seed, 5, 36, 80);
    waitForHeight(node_b_seed, 6, 36, 80);
    // waitForHeight(node0, 3, 36, 100);
    // waitForHeight(node0, 4, 36, 20);
    // waitForHeight(node0, 5, 36, 20);
    // waitForHeight(node0, 6, 36, 20);
    miner1.stop();
    miner2.stop();
    miner3.stop();
    miner4.stop();
    Thread.sleep(500);
    node_a_seed.stop();
    node_b_seed.stop();
    node_a_1.stop();
    node_a_2.stop();
    node_b_1.stop();
    node_b_2.stop();
}
Also used : KeyPair(java.security.KeyPair) SnowBlossomMiner(snowblossom.miner.SnowBlossomMiner) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) Test(org.junit.Test)

Example 3 with SnowBlossomMiner

use of snowblossom.miner.SnowBlossomMiner in project snowblossom by snowblossomcoin.

the class ShardTestFullClaw method shardTest.

@Test
public void shardTest() throws Exception {
    File snow_path = setupSnow("regshard");
    Random rnd = new Random();
    int port = 20000 + rnd.nextInt(30000);
    SnowBlossomNode node = startNode(port, "regshard");
    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 miner = startMiner(port, to_addr, snow_path, "regshard");
    Thread.sleep(60000);
    for (int i = 0; i <= Math.min(10, new NetworkParamsRegShard().getMaxShardId()); i++) {
        waitForShardHead(node, i);
    }
    miner.stop();
    Thread.sleep(500);
    node.stop();
}
Also used : KeyPair(java.security.KeyPair) SnowBlossomMiner(snowblossom.miner.SnowBlossomMiner) SnowBlossomNode(snowblossom.node.SnowBlossomNode) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) NetworkParamsRegShard(snowblossom.lib.NetworkParamsRegShard) Test(org.junit.Test)

Example 4 with SnowBlossomMiner

use of snowblossom.miner.SnowBlossomMiner in project snowblossom by snowblossomcoin.

the class ShardTestJambo method shardTest.

/**
 * Run four nodes, each with some sub sets, but with overlap
 * so that blocks can be linked.
 * node-0 has no miner and views entire network.
 * using it as an easy way to see that network status
 * and as a p2p networking gateway
 */
// @Test
public void shardTest() throws Exception {
    File snow_path = setupSnow("regshard");
    SnowBlossomNode node0 = startNode(0, "regshard", ImmutableMap.of("shards", "0"));
    SnowBlossomNode node1 = startNode(0, "regshard", ImmutableMap.of("shards", "3,4,5"));
    SnowBlossomNode node2 = startNode(0, "regshard", ImmutableMap.of("shards", "3,4,6"));
    SnowBlossomNode node3 = startNode(0, "regshard", ImmutableMap.of("shards", "3,5,6"));
    SnowBlossomNode node4 = startNode(0, "regshard", ImmutableMap.of("shards", "4,5,6"));
    int[] ports = new int[5];
    ports[0] = node0.getServicePorts().get(0);
    ports[1] = node1.getServicePorts().get(0);
    ports[2] = node2.getServicePorts().get(0);
    ports[3] = node3.getServicePorts().get(0);
    ports[4] = node4.getServicePorts().get(0);
    Thread.sleep(100);
    node1.getPeerage().connectPeer("localhost", ports[0]);
    node2.getPeerage().connectPeer("localhost", ports[0]);
    node3.getPeerage().connectPeer("localhost", ports[0]);
    node4.getPeerage().connectPeer("localhost", ports[0]);
    Thread.sleep(1000);
    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(ports[1], to_addr, snow_path, "regshard");
    SnowBlossomMiner miner2 = startMiner(ports[2], to_addr, snow_path, "regshard");
    SnowBlossomMiner miner3 = startMiner(ports[3], to_addr, snow_path, "regshard");
    SnowBlossomMiner miner4 = startMiner(ports[4], to_addr, snow_path, "regshard");
    waitForHeight(node1, 3, 36, 180);
    waitForHeight(node2, 4, 36, 180);
    waitForHeight(node3, 5, 36, 180);
    waitForHeight(node4, 6, 36, 180);
    miner1.stop();
    miner2.stop();
    miner3.stop();
    miner4.stop();
    Thread.sleep(500);
    node0.stop();
    node1.stop();
    node2.stop();
    node3.stop();
    node4.stop();
}
Also used : KeyPair(java.security.KeyPair) SnowBlossomMiner(snowblossom.miner.SnowBlossomMiner) SnowBlossomNode(snowblossom.node.SnowBlossomNode) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash)

Example 5 with SnowBlossomMiner

use of snowblossom.miner.SnowBlossomMiner in project snowblossom by snowblossomcoin.

the class SpoonTest method startMiner.

protected SnowBlossomMiner startMiner(int port, AddressSpecHash mine_to, File snow_path, String network) throws Exception {
    Map<String, String> config_map = new TreeMap<>();
    config_map.put("node_host", "localhost");
    config_map.put("node_port", "" + port);
    config_map.put("threads", "1");
    config_map.put("snow_path", snow_path.getPath());
    config_map.put("network", network);
    NetworkParams params = NetworkParams.loadFromConfig(new ConfigMem(config_map));
    config_map.put("mine_to_address", mine_to.toAddressString(params));
    config_map.put("rate_limit", "10000.0");
    if (port % 2 == 1) {
        config_map.put("memfield", "true");
    }
    return new SnowBlossomMiner(new ConfigMem(config_map));
}
Also used : SnowBlossomMiner(snowblossom.miner.SnowBlossomMiner) NetworkParams(snowblossom.lib.NetworkParams) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem)

Aggregations

SnowBlossomMiner (snowblossom.miner.SnowBlossomMiner)10 File (java.io.File)9 AddressSpecHash (snowblossom.lib.AddressSpecHash)9 KeyPair (java.security.KeyPair)8 Test (org.junit.Test)8 SnowBlossomNode (snowblossom.node.SnowBlossomNode)7 ByteString (com.google.protobuf.ByteString)2 SnowBlossomClient (snowblossom.client.SnowBlossomClient)2 ConfigMem (duckutil.ConfigMem)1 NetworkParams (snowblossom.lib.NetworkParams)1 NetworkParamsRegShard (snowblossom.lib.NetworkParamsRegShard)1