use of duckutil.ConfigMem in project snowblossom by snowblossomcoin.
the class PurseTest method testMarkRace.
@Test
public void testMarkRace() throws Exception {
File empty_sub = new File(test_folder.newFolder(), "new");
TreeMap<String, String> config_settings = new TreeMap<>();
config_settings.put("key_pool_size", "100");
ConfigMem config = new ConfigMem(config_settings);
NetworkParams params = new NetworkParamsRegtest();
WalletDatabase db = WalletUtil.makeNewDatabase(config, params);
db = WalletUtil.fillKeyPool(db, empty_sub, config, params);
Purse purse = new Purse(null, empty_sub, config, params);
purse.maintainKeys(false);
ThreadPoolExecutor exec = TaskMaster.getBasicExecutor(100, "test_fresh_race");
TaskMaster<AddressSpecHash> tm = new TaskMaster<>(exec);
for (int i = 0; i < 1000; i++) {
tm.addTask(new Callable() {
public AddressSpecHash call() throws Exception {
return purse.getUnusedAddress(true, false);
}
});
}
ArrayList<AddressSpecHash> list = tm.getResults();
Assert.assertEquals(1000, list.size());
HashSet<AddressSpecHash> set = new HashSet<>();
set.addAll(list);
Assert.assertEquals(1000, set.size());
Assert.assertEquals(1000, purse.getDB().getUsedAddressesCount());
Assert.assertEquals(1000, purse.getDB().getAddressesCount());
exec.shutdown();
}
use of duckutil.ConfigMem in project snowblossom by snowblossomcoin.
the class PurseTest method saveNew.
@Test
public void saveNew() throws Exception {
File empty_sub = new File(test_folder.newFolder(), "new");
TreeMap<String, String> config_settings = new TreeMap<>();
config_settings.put("key_pool_size", "19");
config_settings.put("key_mode", "standard");
ConfigMem config = new ConfigMem(config_settings);
NetworkParams params = new NetworkParamsRegtest();
WalletDatabase db = WalletUtil.makeNewDatabase(config, params);
db = WalletUtil.fillKeyPool(db, empty_sub, config, params);
Assert.assertEquals(19, db.getKeysCount());
Assert.assertEquals(19, db.getAddressesCount());
Assert.assertEquals(19, db.getAddressCreateTimeCount());
Assert.assertEquals(0, db.getUsedAddressesCount());
}
use of duckutil.ConfigMem in project snowblossom by snowblossomcoin.
the class WalletPanel method loadWallet.
private SnowBlossomClient loadWallet(String name, File db_dir, File config_file) throws Exception {
synchronized (client_map) {
if (client_map.containsKey(name))
return client_map.get(name);
}
TreeMap<String, String> config_map = new TreeMap<>();
config_map.put("wallet_path", db_dir.getPath());
config_map.put("network", ice_leaf.getParams().getNetworkName());
Config conf = new ConfigCat(new ConfigMem(config_map), new ConfigFile(config_file.getPath()));
SnowBlossomClient client = new SnowBlossomClient(conf, null, ice_leaf.getStubHolder());
synchronized (client_map) {
client_map.put(name, client);
}
return client;
}
use of duckutil.ConfigMem 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));
}
use of duckutil.ConfigMem 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