diff --git a/.gitignore b/.gitignore index ede3817d9434bba6a529b1c2f927751f27d09043..b28a8e4c4b6fe033bcfda0f719d3f2ad6f2924fd 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ build .DS_Store *.swp *.swo -*.json +/*.json *.conf # Packages @@ -56,5 +56,3 @@ build .Trashes ehthumbs.db Thumbs.db - - diff --git a/test/test-no-main-accounts-snapshot.json b/test/test-no-main-accounts-snapshot.json new file mode 100644 index 0000000000000000000000000000000000000000..342893df8d2895318e62074703584463fafd5aa9 --- /dev/null +++ b/test/test-no-main-accounts-snapshot.json @@ -0,0 +1,15 @@ +{ + "metadata":{ + "snapshot:semver":"0.2", + "snapshot:origin_api":"http://calculon.local" + }, + "dynamic_global_properties":{ + "total_vesting_fund_steem":{ + "amount":"196793227573", + "nai":"@@000000021", + "precision":3 + } + }, + "accounts":[], + "witnesses":[] +} diff --git a/test/txgen_test.py b/test/txgen_test.py index fad862797da80077926d8c6b288a6bc2741359bc..4c54047f733cca19d1f9c111f9c57cf81d13d680 100644 --- a/test/txgen_test.py +++ b/test/txgen_test.py @@ -47,7 +47,7 @@ FULL_CONF = { "STEEM_TEMP_ACCOUNT" : {"name" : "temp"} } } - + class TxgenTest(unittest.TestCase): def test_create_system_accounts_bad_args(self): @@ -262,3 +262,24 @@ class TxgenTest(unittest.TestCase): cmd, args = action self.assertIn('Unsupported snapshot', str(ctx.exception)) + + def test_build_actions_no_main_accounts_snapshot(self): + system_account_names = ["init-0", "init-1", "init-2", "init-3", "init-4", + "init-5", "init-6", "init-7", "init-8", "init-9", "init-10", "init-11", + "init-12", "init-13", "init-14", "init-15", "init-16", "init-17", + "init-18", "init-19", "init-20", "elect-0", "elect-1", "elect-2", + "elect-3", "elect-4", "elect-5", "elect-6", "elect-7", "elect-8", + "elect-9", "tnman", "porter"] + + shutil.copyfile("test-no-main-accounts-snapshot.json", "/tmp/test-no-main-accounts-snapshot.json") + conf = FULL_CONF.copy() + conf["snapshot_file"] = "/tmp/test-no-main-accounts-snapshot.json" + + for action in txgen.build_actions(conf): + cmd, args = action + + if cmd == "submit_transaction": + for type, value in args["tx"]["operations"]: + if type == 'account_create_operation': + new_account_name = value['new_account_name'] + self.assertIn(new_account_name, system_account_names) diff --git a/tinman/txgen.py b/tinman/txgen.py index 1982668844c884a52efe8a7953a8aad40a4689b6..492536f681e4a3db1e8f5fdc6280beb4453cff03 100755 --- a/tinman/txgen.py +++ b/tinman/txgen.py @@ -206,8 +206,16 @@ def get_proportions(account_stats, conf, silent=True): raise RuntimeError("Increase total_port_balance or decrease min_vesting_per_account") total_port_vesting = (avail_port_balance * total_vesting_steem) // (total_steem + total_vesting_steem) total_port_liquid = (avail_port_balance * total_steem) // (total_steem + total_vesting_steem) - vest_conversion_factor = (DENOM * total_port_vesting) // total_vests - steem_conversion_factor = (DENOM * total_port_liquid ) // total_steem + + if total_vests == 0: + vest_conversion_factor = 1 + else: + vest_conversion_factor = (DENOM * total_port_vesting) // total_vests + + if total_steem == 0: + steem_conversion_factor = 1 + else: + steem_conversion_factor = (DENOM * total_port_liquid ) // total_steem if not silent: print("total_vests:", total_vests) diff --git a/tinman/warden.py b/tinman/warden.py index 2b41ee1d1beb67f2a046d8e5559d80de7c052da6..226e5496daf6bfd3cb06557d89cf384bea258928 100644 --- a/tinman/warden.py +++ b/tinman/warden.py @@ -47,15 +47,6 @@ def main(argv): witness_schedule = steemd.database_api.get_witness_schedule(x=None) witnesses = witness_schedule["current_shuffled_witnesses"] - initminer = config["STEEM_INIT_MINER_NAME"] - - if initminer not in witnesses: - print("[√] witnesses: %s not present" % initminer) - passfail.append(PREFLIGHT_GO) - else: - print("[X] witnesses: %s present" % initminer) - passfail.append(PREFLIGHT_NOGO) - scheduled_witnesses = witness_schedule["num_scheduled_witnesses"] if scheduled_witnesses == config["STEEM_MAX_WITNESSES"]: