def test_get_block(): """ We should be able to fetch some blocks. """ h = Hived() for num in [1000, 1000000, 10000000, 20000000, 21000000]: b = h.get_block(num) assert b, 'block %d was blank' % num assert num == int(b['block_id'][:8], base=16) start = 21000000 for num in range(start, start + 50): b = h.get_block(num) assert b, 'block %d was blank' % num assert num == int(b['block_id'][:8], base=16) non_existent_block = 99999999 b = h.get_block(non_existent_block) assert not b, 'block %d expected to be blank' % non_existent_block
def test_transfer(): wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' c = Commit(hived_instance=Hived(nodes=[]), keys=[wif]) rpc_error = None try: c.transfer('test2', '1.000', 'HIVE', 'foo', 'test') except RPCError as e: rpc_error = str(e) else: raise Exception('expected RPCError') assert 'tx_missing_active_auth' in rpc_error
def test_claim_reward(): wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' c = Commit(hived_instance=Hived(nodes=[]), keys=[wif]) rpc_error = None try: c.claim_reward_balance(account='test', reward_hive='1.000 HIVE', reward_vests='0.000000 VESTS', reward_hbd='0.000 HBD') except RPCError as e: rpc_error = str(e) else: raise Exception('expected RPCError') assert 'tx_missing_posting_auth' in rpc_error
def test_witness_set_properties(): wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' c = Commit(hived_instance=Hived(nodes=[]), keys=[wif]) signing_key = 'STM1111111111111111111111111111111114T1Anm' props = [['account_creation_fee', 'd0070000000000000354455354530000'], [ 'key', ('032d2a4af3e23294e0a1d9dbc46e0272d' '8e1977ce2ae3349527cc90fe1cc9c5db9') ]] rpc_error = None try: c.witness_set_properties(signing_key=signing_key, props=props, account='test') except RPCError as e: rpc_error = str(e) else: raise Exception('expected RPCError') assert 'tx_missing_other_auth' in rpc_error
def test_witness_update(): wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3' c = Commit(hived_instance=Hived(nodes=[]), keys=[wif]) signing_key = 'STM1111111111111111111111111111111114T1Anm' props = { 'account_creation_fee': '0.500 HIVE', 'maximum_block_size': 65536, 'hbd_interest_rate': 0 } rpc_error = None try: c.witness_update(signing_key=signing_key, account='test', props=props, url='foo') except RPCError as e: rpc_error = str(e) else: raise Exception('expected RPCError') assert 'tx_missing_active_auth' in rpc_error
def test_get_version(): """ We should be able to call get_version on hived """ h = Hived() response = h.call('get_version', api='login_api') version = response['blockchain_version'] assert version[0:4] == '0.20'
def test_ensured_block_ranges(): """ Post should load correctly if passed a dict or string identifier. """ h = Hived() assert list(pluck('block_num', h.get_blocks_range(1000, 2000))) == list(range(1000, 2000))
def test_get_dgp(): """ We should be able to call get_dynamic_global_properties on hived """ h = Hived() response = h.call('get_dynamic_global_properties', api='database_api') assert response['head_block_number'] > 20e6