use of snowblossom.lib.NetworkParamsRegtest in project snowblossom by snowblossomcoin.
the class ShardUtilTest method testBlockRewardNoShard.
@Test
public void testBlockRewardNoShard() {
NetworkParams params = new NetworkParamsRegtest();
long reward = ShardUtil.getBlockReward(params, BlockHeader.newBuilder().build());
Assert.assertEquals(PowUtil.getBlockReward(params, 0), reward);
}
use of snowblossom.lib.NetworkParamsRegtest in project snowblossom by snowblossomcoin.
the class AddressUtilTest method testAddressConversions.
@Test
public void testAddressConversions() throws ValidationException {
ArrayList<NetworkParams> plist = new ArrayList<NetworkParams>();
plist.add(new NetworkParamsProd());
plist.add(new NetworkParamsTestnet());
plist.add(new NetworkParamsRegtest());
byte[] buff = new byte[Globals.ADDRESS_SPEC_HASH_LEN];
Random rnd = new Random();
HashSet<String> addresses = new HashSet<>();
for (int i = 0; i < 1000; i++) {
if (i > 0) {
rnd.nextBytes(buff);
}
AddressSpecHash spec = new AddressSpecHash(buff);
for (NetworkParams p : plist) {
String addr = spec.toAddressString(p);
Assert.assertFalse(addresses.contains(addr));
addresses.add(addr);
System.out.println("Address: " + addr);
AddressSpecHash dec = new AddressSpecHash(addr, p);
Assert.assertEquals(spec, dec);
int colon = addr.indexOf(":");
String without = addr.substring(colon + 1);
AddressSpecHash dec2 = new AddressSpecHash(without, p);
Assert.assertEquals(spec, dec2);
}
}
}
use of snowblossom.lib.NetworkParamsRegtest in project snowblossom by snowblossomcoin.
the class PowUtilTest method testCalcNextTargetIncreasingFromAvg.
@Test
public void testCalcNextTargetIncreasingFromAvg() {
NetworkParams params = new NetworkParamsRegtest();
long time = System.currentTimeMillis();
// block solved slow
BlockHeader prev_header = BlockHeader.newBuilder().setTimestamp(time - params.getBlockTimeTarget() * 2).build();
BigInteger average_target = params.getMaxTarget().divide(BigInteger.valueOf(100));
BlockSummary bs = BlockSummary.newBuilder().setHeader(prev_header).setTargetAverage(average_target.toString()).setBlocktimeAverageMs(params.getBlockTimeTarget()).build();
BigInteger target = PowUtil.calcNextTarget(bs, params, System.currentTimeMillis());
System.out.println("Old: " + average_target + " new: " + target);
Assert.assertTrue(target.compareTo(average_target) > 0);
}
use of snowblossom.lib.NetworkParamsRegtest in project snowblossom by snowblossomcoin.
the class PowUtilTest method testCalcNextTargetDecreasing.
@Test
public void testCalcNextTargetDecreasing() {
NetworkParams params = new NetworkParamsRegtest();
long time = System.currentTimeMillis();
BlockHeader prev_header = BlockHeader.newBuilder().setTimestamp(time - params.getBlockTimeTarget() / 2).build();
BlockSummary bs = BlockSummary.newBuilder().setHeader(prev_header).setTargetAverage(params.getMaxTarget().toString()).setBlocktimeAverageMs(params.getBlockTimeTarget()).build();
BigInteger target = PowUtil.calcNextTarget(bs, params, System.currentTimeMillis());
Assert.assertTrue(target.compareTo(params.getMaxTarget()) < 0);
}
use of snowblossom.lib.NetworkParamsRegtest in project snowblossom by snowblossomcoin.
the class SpoonTest method genWallet.
public static WalletDatabase genWallet() {
TreeMap<String, String> config_map = new TreeMap<>();
config_map.put("key_count", "20");
WalletDatabase db = WalletUtil.makeNewDatabase(new ConfigMem(config_map), new NetworkParamsRegtest());
return db;
}
Aggregations