def test_find_refund_reference_event(): # None for no transaction given assert txnmetadata.find_refund_reference_event(None, None) is None receiver = utils.account_address("f72589b71ff4f8d139674a3f7369c69b") txn = jsonrpc.Transaction() txn.events.add(data=jsonrpc.EventData(type="unknown", receiver="f72589b71ff4f8d139674a3f7369c69b")) txn.events.add(data=jsonrpc.EventData(type="receivedpayment", receiver="unknown")) # None for not found event = txnmetadata.find_refund_reference_event(txn, receiver) assert event is None txn.events.add(data=jsonrpc.EventData(type="receivedpayment", receiver="f72589b71ff4f8d139674a3f7369c69b")) event = txnmetadata.find_refund_reference_event(txn, receiver) assert event is not None assert event.data.type == "receivedpayment" assert event.data.receiver == "f72589b71ff4f8d139674a3f7369c69b"
def test_decode_transaction_script(): script_bytes = "e001a11ceb0b010000000701000202020403061004160205181d0735600895011000000001010000020001000003020301010004010300010501060c0108000506080005030a020a020005060c05030a020a020109000b4469656d4163636f756e741257697468647261774361706162696c6974791b657874726163745f77697468647261775f6361706162696c697479087061795f66726f6d1b726573746f72655f77697468647261775f6361706162696c69747900000000000000000000000000000001010104010c0b0011000c050e050a010a020b030b0438000b05110202010700000000000000000000000000000001035855530358555300040393e341892c775c38fd524757d641f0a20100e1f5050000000004000400" script_call = utils.decode_transaction_script(script_bytes) assert type(script_call).__name__ == "ScriptCall__PeerToPeerWithMetadata" assert script_call.amount == 100_000_000 script_call = utils.decode_transaction_script( jsonrpc.TransactionData(script_bytes=script_bytes)) assert type(script_call).__name__ == "ScriptCall__PeerToPeerWithMetadata" assert script_call.amount == 100_000_000 script_call = utils.decode_transaction_script( jsonrpc.Transaction(transaction=jsonrpc.TransactionData( script_bytes=script_bytes))) assert type(script_call).__name__ == "ScriptCall__PeerToPeerWithMetadata" assert script_call.amount == 100_000_000 with pytest.raises(TypeError): utils.decode_transaction_script(False)
def test_decode_transaction_script(): script_bytes = "e101a11ceb0b010000000701000202020403061004160205181d0735610896011000000001010000020001000003020301010004010300010501060c0108000506080005030a020a020005060c05030a020a020109000c4c696272614163636f756e741257697468647261774361706162696c6974791b657874726163745f77697468647261775f6361706162696c697479087061795f66726f6d1b726573746f72655f77697468647261775f6361706162696c69747900000000000000000000000000000001010104010c0b0011000c050e050a010a020b030b0438000b05110202010700000000000000000000000000000001034c4252034c42520004031f4ed0531ff357402ac222b01f7c67860140420f000000000004000400" script_call = utils.decode_transaction_script(script_bytes) assert type(script_call).__name__ == "ScriptCall__PeerToPeerWithMetadata" assert script_call.amount == 1_000_000 script_call = utils.decode_transaction_script( jsonrpc.TransactionData(script_bytes=script_bytes)) assert type(script_call).__name__ == "ScriptCall__PeerToPeerWithMetadata" assert script_call.amount == 1_000_000 script_call = utils.decode_transaction_script( jsonrpc.Transaction(transaction=jsonrpc.TransactionData( script_bytes=script_bytes))) assert type(script_call).__name__ == "ScriptCall__PeerToPeerWithMetadata" assert script_call.amount == 1_000_000 with pytest.raises(TypeError): utils.decode_transaction_script(False)
def jsonrpc_txn_sample(*args): return jsonrpc.Transaction( version=3232, transaction=jsonrpc.TransactionData(sequence_number=5), hash="3232-hash", )