def test_to_xdr_obj_without_source(self): destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" starting_balance = "1000.00" op = CreateAccount(destination, starting_balance) assert (op.to_xdr_object().to_xdr() == "AAAAAAAAAAAAAAAAiZsoQO1WNsVt3F8Usjl" "1958bojiNJpTkxW7N3clg5e8AAAACVAvkAA==")
def test_to_xdr_obj(self): source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" starting_balance = "1000.00" op = CreateAccount(destination, starting_balance, source) assert ( op.to_xdr_object().to_xdr() == "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAA" "AAAAAAAiZsoQO1WNsVt3F8Usjl1958bojiNJpTkxW7N3clg5e8AAAACVAvkAA==")
def test_get_source_no_exist_from_xdr_obj(self): # BAD TEST destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" starting_balance = "1000.00" origin_op = CreateAccount(destination, starting_balance) origin_xdr_obj = origin_op.to_xdr_object() op = Operation.from_xdr_object(origin_xdr_obj) assert op.source == None assert op.starting_balance == "1000" assert op.destination == destination
def test_get_source_exist_from_xdr_obj(self): # BAD TEST source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" starting_balance = "1000.00" origin_op = CreateAccount(destination, starting_balance, source) origin_xdr_obj = origin_op.to_xdr_object() op = Operation.from_xdr_object(origin_xdr_obj) assert op.source == source assert op.starting_balance == "1000" assert op.destination == destination
def test_get_muxed_account_source_exist_from_xdr_obj(self): # BAD TEST source = "MAAAAAAAAAAAJURAAB2X52XFQP6FBXLGT6LWOOWMEXWHEWBDVRZ7V5WH34Y22MPFBHUHY" destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" starting_balance = "1000.00" origin_op = CreateAccount(destination, starting_balance, source) origin_xdr_obj = origin_op.to_xdr_object() op = Operation.from_xdr_object(origin_xdr_obj) assert op.source == source assert op.starting_balance == "1000" assert op.destination == destination
def test_to_xdr_obj_with_invalid_destination_raise(self): destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMINVALID" starting_balance = "1000.00" with pytest.raises( Ed25519PublicKeyInvalidError, match="Invalid Ed25519 Public Key: {}".format(destination), ): CreateAccount(destination, starting_balance)
def test_to_xdr_obj_with_invalid_starting_balance_raise(self): destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" starting_balance = "-1" with pytest.raises( ValueError, match="Value of '{}' must represent a positive number and " "the max valid value is 922337203685.4775807.".format(starting_balance), ): CreateAccount(destination, starting_balance)
def test_to_xdr_obj_with_invalid_source_raise(self): source = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLINVALID" destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" starting_balance = "1000.00" with pytest.raises( Ed25519PublicKeyInvalidError, match="Invalid Ed25519 Public Key: {}".format(source), ): CreateAccount(destination, starting_balance, source)
def test_get_source_muxed_from_xdr_obj(self): # BAD TEST destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ" source = "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB" source2 = "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV" starting_balance = "1000.00" origin_op = CreateAccount(destination, starting_balance, source) origin_xdr_obj = origin_op.to_xdr_object() op = Operation.from_xdr_object(origin_xdr_obj) assert op.to_xdr_object().to_xdr() == origin_xdr_obj.to_xdr() assert op.source == source assert ( op._source_muxed.to_xdr() == Keypair.from_public_key(source).xdr_muxed_account().to_xdr() ) op.source = source2 assert op.source == source2 assert op._source_muxed is None