def test_transaction_hashable_fail(): test_time = int(time.time()) block_time = int(time.time()) transaction_1 = Transaction('block_hash_test', '', 'to_steven_test', 'from_matt_test', 1, test_time) transaction_2 = Transaction('block_hash_test2', '', 'to_matt_test', 'from_steven_test', 1, test_time) block = Block('_hash_test', '','', 'LAST_BLOCK', 0, [ transaction_1, transaction_2 ], [], [], [], [], [], block_time) actual = block.get_hashable() expected = { 'owner': '', 'prev_block': 'LAST_BLOCK', 'height': 0, 'signature': '', 'transactions': [ transaction_1.get_sendable(), transaction_2.get_sendable() ], 'pos_transactions': [], 'contract_transactions': [], 'contracts': [], 'signed_contracts': [], 'terminated_contracts': [], 'timestamp': block_time } assert actual == expected
def test_sendable_fail(): test_time = int(time.time()) transaction = Transaction('block_send_test', '', 'to_steven_test', 'from_matt_test', 1, 0, test_time) actual = transaction.get_sendable() not_expected = { 'signature': '', 'to_addr': 'to_steven_test', 'from_addr': 'from_matt_test', 'amount': '2.00000000', 'timestamp': test_time, '_hash': 'block_send_test' } assert actual != not_expected
def test_sendable_json(): test_time = int(time.time()) transaction = Transaction('block_send_test', '', 'to_steven_test', 'from_matt_test', 1, 0, test_time) actual = json.dumps(transaction.get_sendable(), sort_keys=True, separators=(',', ':')) expected = json.dumps( { 'signature': '', 'amount': '1.00000000', 'to_addr': 'to_steven_test', 'from_addr': 'from_matt_test', '_hash': 'block_send_test', 'timestamp': test_time }, sort_keys=True, separators=(',', ':')) assert actual == expected