def test_to_xdr(self, selling, buying, amount, price, source, xdr): op = CreatePassiveSellOffer(selling, buying, amount, price, source) xdr_obj = op.to_xdr_object() assert xdr_obj.to_xdr() == xdr from_instance = Operation.from_xdr_object(xdr_obj) assert isinstance(from_instance, CreatePassiveSellOffer) assert from_instance.source == source assert from_instance.buying == buying assert from_instance.selling == selling assert Decimal(from_instance.amount) == Decimal(amount) if not isinstance(price, Price): price = Price.from_raw_price(price) assert from_instance.price == price
def test_to_xdr(self, selling, buying, amount, price, offer_id, source, xdr): op = ManageBuyOffer(selling, buying, amount, price, offer_id, source) xdr_obj = op.to_xdr_object() assert xdr_obj.to_xdr() == xdr from_instance = Operation.from_xdr_object(xdr_obj) assert isinstance(from_instance, ManageBuyOffer) assert from_instance.source == source assert from_instance.buying == buying assert from_instance.selling == selling assert from_instance.amount == amount if not isinstance(price, Price): price = Price.from_raw_price(price) assert from_instance.price == price assert from_instance.offer_id == offer_id
def _read_price(price: Union["Price", str, Decimal]) -> "Price": # In the coming stellar-sdk 6.x, the type of price must be Price, # at that time we can remove this function if isinstance(price, Price): return price return Price.from_raw_price(price)