class Testcases(unittest.TestCase): def setUp(self): fixture_data() self.chain = Blockchain(mode="head") def test_is_irv(self): self.assertFalse(self.chain.is_irreversible_mode()) def test_info(self): info = self.chain.info() for i in [ "time", "dynamic_flags", "head_block_id", "head_block_number", "last_budget_time", ]: self.assertIn(i, info) def test_parameters(self): info = self.chain.chainParameters() for i in [ "worker_budget_per_day", "maintenance_interval", ]: self.assertIn(i, info) def test_network(self): info = self.chain.get_network() for i in [ "chain_id", "core_symbol", "prefix", ]: self.assertIn(i, info) def test_props(self): info = self.chain.get_chain_properties() for i in [ "id", "chain_id", "immutable_parameters", ]: self.assertIn(i, info) def test_block_num(self): num = self.chain.get_current_block_num() self.assertTrue(num > 100) def test_block(self): block = self.chain.get_current_block() self.assertIsInstance(block, Block) self.chain.block_time(1) self.chain.block_timestamp(1) def test_list_accounts(self): for account in self.chain.get_all_accounts(): self.assertIsInstance(account, str) # Break already break
def fees(ctx, currency): """ List fees """ from bitsharesbase.operationids import getOperationNameForId from bitshares.market import Market market = Market("%s:%s" % (currency, "BTS")) ticker = market.ticker() if "quoteSettlement_price" in ticker: price = ticker.get("quoteSettlement_price") else: price = ticker.get("latest", 0) price.invert() chain = Blockchain(bitshares_instance=ctx.bitshares) feesObj = chain.chainParameters().get("current_fees") fees = feesObj["parameters"] t = [["Operation", "Type", "Fee", currency]] for fee in fees: for f in fee[1]: data = [ highlight(getOperationNameForId(fee[0])), detail(f), detail(Amount({"amount": fee[1].get(f, 0), "asset_id": "1.3.0"})), detail( price * Amount({"amount": fee[1].get(f, 0), "asset_id": "1.3.0"}) ), ] t.append(data) print_table(t)
def fees(ctx, currency): """ List fees """ from bitsharesbase.operationids import getOperationNameForId from bitshares.market import Market market = Market("%s:%s" % (currency, "BTS")) ticker = market.ticker() if "quoteSettlement_price" in ticker: price = ticker.get("quoteSettlement_price") else: price = ticker.get("latest", 0) chain = Blockchain(bitshares_instance=ctx.bitshares) feesObj = chain.chainParameters().get("current_fees") scale = feesObj["scale"] fees = feesObj["parameters"] t = PrettyTable(["Operation", "Type", "Fee", currency]) t.align = "l" t.align["Fee"] = "r" t.align[currency] = "r" for fee in fees: for f in fee[1]: t.add_row([ getOperationNameForId(fee[0]), f, str(Amount({ "amount": fee[1].get(f, 0), "asset_id": "1.3.0" })), str(price * Amount({ "amount": fee[1].get(f, 0), "asset_id": "1.3.0" })) ]) click.echo(t)
def get_shuffle_round_time(self): """ returns time in seconds of one round of block creation of every active witness """ btschain = Blockchain() wits = len(Witnesses(bitshares_instance=self.bts)) intv = btschain.chainParameters().get("block_interval") return wits * intv
class Testcases(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.bts = BitShares( "wss://node.testnet.bitshares.eu", nobroadcast=True, ) self.bts.set_default_account("init0") set_shared_bitshares_instance(self.bts) self.chain = Blockchain(mode="head") def test_is_irv(self): self.assertFalse(self.chain.is_irreversible_mode()) def test_info(self): info = self.chain.info() for i in [ "time", "dynamic_flags", "head_block_id", "head_block_number", "last_budget_time" ]: self.assertIn(i, info) def test_parameters(self): info = self.chain.chainParameters() for i in [ "worker_budget_per_day", "maintenance_interval", ]: self.assertIn(i, info) def test_network(self): info = self.chain.get_network() for i in [ "chain_id", "core_symbol", "prefix", ]: self.assertIn(i, info) def test_props(self): info = self.chain.get_chain_properties() for i in [ "id", "chain_id", "immutable_parameters", ]: self.assertIn(i, info) def test_block_num(self): num = self.chain.get_current_block_num() self.assertTrue(num > 100) def test_block(self): block = self.chain.get_current_block() self.assertIsInstance(block, Block) self.chain.block_time(1) self.chain.block_timestamp(1) def test_list_accounts(self): for account in self.chain.get_all_accounts(): self.assertIsInstance(account, str) # Break already break