Search in sources :

Example 1 with SnowBlossomNode

use of snowblossom.node.SnowBlossomNode 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 SnowBlossomNode

use of snowblossom.node.SnowBlossomNode 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 3 with SnowBlossomNode

use of snowblossom.node.SnowBlossomNode 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 4 with SnowBlossomNode

use of snowblossom.node.SnowBlossomNode in project snowblossom by snowblossomcoin.

the class SpoonTestBasic method spoonTest.

/**
 * More of a giant orbital space platform full of weasels
 * than a unit test
 */
@Test
public void spoonTest() throws Exception {
    File snow_path = setupSnow();
    Random rnd = new Random();
    int port = 20000 + rnd.nextInt(30000);
    SnowBlossomNode node = startNode(port);
    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);
    testMinedBlocks(node);
    SnowBlossomClient client = startClient(port);
    testConsolidateFunds(node, client, key_pair, to_addr);
    SnowBlossomNode node2 = startNode(port + 1);
    node2.getPeerage().connectPeer("localhost", port);
    testMinedBlocks(node2);
    miner.stop();
    Thread.sleep(500);
    node.stop();
    node2.stop();
}
Also used : KeyPair(java.security.KeyPair) SnowBlossomMiner(snowblossom.miner.SnowBlossomMiner) SnowBlossomNode(snowblossom.node.SnowBlossomNode) SnowBlossomClient(snowblossom.client.SnowBlossomClient) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) Test(org.junit.Test)

Example 5 with SnowBlossomNode

use of snowblossom.node.SnowBlossomNode in project snowblossom by snowblossomcoin.

the class SpoonTestPool 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);
    PoolMiner miner = startPoolMiner(plow.getGrpcPort(), to_addr, snow_path);
    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);
    PoolMiner miner2 = startPoolMiner(plow.getGrpcPort(), to_addr3, snow_path);
    // Second miner getting paid
    waitForFunds(client, to_addr3, 30);
    miner.stop();
    miner2.stop();
    Thread.sleep(500);
    plow.stop();
    node.stop();
}
Also used : PoolMiner(snowblossom.miner.PoolMiner) KeyPair(java.security.KeyPair) SnowBlossomNode(snowblossom.node.SnowBlossomNode) SnowBlossomClient(snowblossom.client.SnowBlossomClient) MrPlow(snowblossom.miner.plow.MrPlow) File(java.io.File) AddressSpecHash(snowblossom.lib.AddressSpecHash) Test(org.junit.Test)

Aggregations

SnowBlossomNode (snowblossom.node.SnowBlossomNode)11 File (java.io.File)9 AddressSpecHash (snowblossom.lib.AddressSpecHash)9 KeyPair (java.security.KeyPair)8 Test (org.junit.Test)8 SnowBlossomMiner (snowblossom.miner.SnowBlossomMiner)7 SnowBlossomClient (snowblossom.client.SnowBlossomClient)4 ByteString (com.google.protobuf.ByteString)2 ConfigMem (duckutil.ConfigMem)2 PoolMiner (snowblossom.miner.PoolMiner)2 MrPlow (snowblossom.miner.plow.MrPlow)2 TreeMap (java.util.TreeMap)1 NetworkParamsRegShard (snowblossom.lib.NetworkParamsRegShard)1 StatusLogger (snowblossom.node.StatusLogger)1