def test_transaction_seq_exist() -> None: source_addr = "fake_source_addr" source_subaddr = "fake_source_subaddr" assert not storage.get_transaction_by_details( source_address=source_addr, source_subaddress=source_subaddr, sequence=0 ) storage.add_transaction( amount=100, currency=DiemCurrency.Coin1, payment_type=TransactionType.INTERNAL, status=TransactionStatus.COMPLETED, source_address=source_addr, source_subaddress=source_subaddr, sequence=0, ) assert storage.get_transaction_by_details( source_address=source_addr, source_subaddress=source_subaddr, sequence=0 )
def test_process_incoming_travel_rule_txn() -> None: account = create_account("fake_account") sender_addr = "46db232847705e05525db0336fd9f337" receiver_addr = "lrw_vasp" sender_subaddr = generate_new_subaddress(account.id) amount = 1000 * 1_000_000 sender = account_address(sender_addr) sequence = 1 currency = DiemCurrency.XUS blockchain_version = 1 off_chain_reference_id = "off_chain_reference_id" metadata, _ = travel_rule(off_chain_reference_id, sender, amount) storage.add_transaction( amount=amount, currency=currency, payment_type=TransactionType.OFFCHAIN, status=TransactionStatus.OFF_CHAIN_READY, source_id=account.id, source_address=sender_addr, source_subaddress=sender_subaddr, destination_address=receiver_addr, reference_id=off_chain_reference_id, ) process_incoming_transaction( sender_address=sender_addr, receiver_address=receiver_addr, sequence=sequence, amount=amount, currency=currency, metadata=diem_types.Metadata__TravelRuleMetadata.bcs_deserialize( metadata), blockchain_version=blockchain_version, ) # successfully parse meta and sequence tx = storage.get_transaction_by_details(source_address=sender_addr, source_subaddress=sender_subaddr, sequence=sequence) assert tx is not None assert tx.sequence == sequence assert tx.blockchain_version == blockchain_version
def test_process_incoming_general_txn() -> None: account = create_account("fake_account") sender_addr = "46db232847705e05525db0336fd9f337" subaddr = generate_new_subaddress(account.id) meta = general_metadata(to_subaddress=sub_address(subaddr)) process_incoming_transaction( sender_address=sender_addr, receiver_address="lrw_vasp", sequence=1, amount=100, currency=DiemCurrency.XUS, metadata=diem_types.Metadata__GeneralMetadata.bcs_deserialize(meta), blockchain_version=1, ) # successfully parse meta and sequence tx = storage.get_transaction_by_details(source_address=sender_addr, source_subaddress=None, sequence=1) assert tx is not None