Search in sources :

Example 6 with SnowFall

use of snowblossom.lib.SnowFall in project snowblossom by snowblossomcoin.

the class SpoonTest method setupSnow.

protected File setupSnow(String network) throws Exception {
    TreeMap<String, String> config_map = new TreeMap<>();
    config_map.put("network", network);
    NetworkParams params = NetworkParams.loadFromConfig(new ConfigMem(config_map));
    String test_folder_base = test_folder.newFolder().getPath();
    File snow_path = new File(test_folder.newFolder(), "snow");
    for (int i = 0; i < 4; i++) {
        SnowFieldInfo info = params.getSnowFieldInfo(i);
        String name = network + "." + i;
        File field_path = new File(snow_path, name);
        field_path.mkdirs();
        File field = new File(field_path, name + ".snow");
        new SnowFall(field.getPath(), name, info.getLength());
        ByteString root_hash = new SnowMerkle(field_path, name, true).getRootHash();
        Assert.assertEquals(info.getMerkleRootHash(), root_hash);
    }
    return snow_path;
}
Also used : SnowMerkle(snowblossom.lib.SnowMerkle) SnowFieldInfo(snowblossom.lib.SnowFieldInfo) ByteString(com.google.protobuf.ByteString) NetworkParams(snowblossom.lib.NetworkParams) SnowFall(snowblossom.lib.SnowFall) ByteString(com.google.protobuf.ByteString) ConfigMem(duckutil.ConfigMem) File(java.io.File)

Aggregations

File (java.io.File)6 SnowFall (snowblossom.lib.SnowFall)6 SnowMerkle (snowblossom.lib.SnowMerkle)6 ByteString (com.google.protobuf.ByteString)5 SnowMerkleProof (snowblossom.miner.SnowMerkleProof)3 SnowPowProof (snowblossom.proto.SnowPowProof)3 SnowFieldInfo (snowblossom.lib.SnowFieldInfo)2 ConfigMem (duckutil.ConfigMem)1 MessageDigest (java.security.MessageDigest)1 LinkedList (java.util.LinkedList)1 Random (java.util.Random)1 Test (org.junit.Test)1 NetworkParams (snowblossom.lib.NetworkParams)1