Exemple #1
0
 def test_offline(self):
     bts = DPay(node=self.nodelist.get_nodes(appbase=False),
                 offline=True,
                 data_refresh_time_seconds=900,
                 keys={"active": wif, "owner": wif, "memo": wif})
     bts.refresh_data()
     self.assertTrue(bts.get_reserve_ratio(use_stored_data=False) is None)
     self.assertTrue(bts.get_reserve_ratio(use_stored_data=True) is None)
     self.assertTrue(bts.get_feed_history(use_stored_data=False) is None)
     self.assertTrue(bts.get_feed_history(use_stored_data=True) is None)
     self.assertTrue(bts.get_reward_funds(use_stored_data=False) is None)
     self.assertTrue(bts.get_reward_funds(use_stored_data=True) is None)
     self.assertTrue(bts.get_current_median_history(use_stored_data=False) is None)
     self.assertTrue(bts.get_current_median_history(use_stored_data=True) is None)
     self.assertTrue(bts.get_hardfork_properties(use_stored_data=False) is None)
     self.assertTrue(bts.get_hardfork_properties(use_stored_data=True) is None)
     self.assertTrue(bts.get_network(use_stored_data=False) is None)
     self.assertTrue(bts.get_network(use_stored_data=True) is None)
     self.assertTrue(bts.get_witness_schedule(use_stored_data=False) is None)
     self.assertTrue(bts.get_witness_schedule(use_stored_data=True) is None)
     self.assertTrue(bts.get_config(use_stored_data=False) is None)
     self.assertTrue(bts.get_config(use_stored_data=True) is None)
     self.assertEqual(bts.get_block_interval(), 3)
     self.assertEqual(bts.get_blockchain_version(), '0.0.0')
Exemple #2
0
 def test_properties(self, node_param):
     if node_param == "non_appbase":
         bts = DPay(node=self.nodelist.get_nodes(appbase=False),
                     nobroadcast=True,
                     data_refresh_time_seconds=900,
                     keys={"active": wif, "owner": wif, "memo": wif},
                     num_retries=10)
     elif node_param == "appbase":
         bts = DPay(node=self.nodelist.get_nodes(normal=False, appbase=True),
                     nobroadcast=True,
                     data_refresh_time_seconds=900,
                     keys={"active": wif, "owner": wif, "memo": wif},
                     num_retries=10)
     self.assertTrue(bts.get_reserve_ratio(use_stored_data=False) is not None)
     self.assertTrue(bts.get_feed_history(use_stored_data=False) is not None)
     self.assertTrue(bts.get_reward_funds(use_stored_data=False) is not None)
     self.assertTrue(bts.get_current_median_history(use_stored_data=False) is not None)
     self.assertTrue(bts.get_hardfork_properties(use_stored_data=False) is not None)
     self.assertTrue(bts.get_network(use_stored_data=False) is not None)
     self.assertTrue(bts.get_witness_schedule(use_stored_data=False) is not None)
     self.assertTrue(bts.get_config(use_stored_data=False) is not None)
     self.assertTrue(bts.get_block_interval() is not None)
     self.assertTrue(bts.get_blockchain_version() is not None)
Exemple #3
0
from dpaygo import DPay
import numpy as np
from dpaygo.utils import reputation_to_score
from dpaygo.amount import Amount
from dpaygo.constants import DPAY_100_PERCENT
import matplotlib as mpl
# mpl.use('Agg')
# mpl.use('TkAgg')
import matplotlib.pyplot as plt

if __name__ == "__main__":
    stm = DPay()
    price = Amount(stm.get_current_median_history()["base"])
    reps = [0]
    for i in range(26, 91):
        reps.append(int(10**((i - 25) / 9 + 9)))
    # reps = np.logspace(9, 16, 60)
    used_power = stm._calc_resulting_vote()
    last_bp = 0
    bp_list = []
    rep_score_list = []
    for goal_rep in reps:
        score = reputation_to_score(goal_rep)
        rep_score_list.append(score)
        needed_rshares = int(goal_rep) << 6
        needed_vests = needed_rshares / used_power / 100
        needed_bp = stm.vests_to_bp(needed_vests)
        bp_list.append(needed_bp / 1000)
        # print("| %.1f | %.2f | %.2f  | " % (score, needed_bp / 1000, needed_bp / 1000 - last_bp / 1000))
        last_bp = needed_bp