class TestManageBuyOffer: @pytest.mark.parametrize( "selling, buying, amount, price, offer_id, source, xdr", [ ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "3.123456", "8.141592", 1, "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAwAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAAHcmgAAD4djAAHoSAAAAAAAAAAB", ), ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "8", "238.141592", 0, None, "AAAAAAAAAAwAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAATEtAABxjgTAAHoSAAAAAAAAAAA", ), ( Asset("PAYDEX"), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "3.123456", Price(11, 10), 1, "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAwAAAAAAAAAAVhDTgAAAAAAm466+JY4VR3PnqT3QyBxEGuHqw4ts9abdaU4InL3WdgAAAAAAdyaAAAAAAsAAAAKAAAAAAAAAAE=", ), ], ) 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
class TestCreatePassiveSellOffer: @pytest.mark.parametrize( "selling, buying, amount, price, source, xdr", [ ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "11.2782700", "3.07", "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAQAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAAa47WwAAAEzAAAAZA==", ), ( Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "8.000", "238.141592", None, "AAAAAAAAAAQAAAABVVNEAAAAAADNTrgPO19O0EsnYjSc333yWGLKEVxLyu1kfKjCKOz9ewAAAAFYQ04AAAAAAJuOuviWOFUdz56k90MgcRBrh6sOLbPWm3WlOCJy91nYAAAAAATEtAABxjgTAAHoSA==", ), ( Asset("PAYDEX"), Asset( "XCN", "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ), "11.2782700", Price(453, 4354), "GDL635DMMORJHKEHHQIIB4VPYM6YGEMPLORYHHM2DEHAUOUXLSTMHQDV", "AAAAAQAAAADX7fRsY6KTqIc8EIDyr8M9gxGPW6ODnZoZDgo6l1ymwwAAAAQAAAAAAAAAAVhDTgAAAAAAm466+JY4VR3PnqT3QyBxEGuHqw4ts9abdaU4InL3WdgAAAAABrjtbAAAAcUAABEC", ), ], ) 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, 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 test_to_xdr(self): sequence = 1 source = Account( "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", sequence ) builder = TransactionBuilder( source, Network.TESTNET_NETWORK_PASSPHRASE, base_fee=150 ) builder.add_text_memo("Paydex Python SDK") builder.add_time_bounds(1565590000, 1565600000) te = ( builder.append_create_account_op( "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", "5.5", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", ) .append_change_trust_op( "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "100000", ) .append_payment_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "12.25", "PAYDEX", ) .append_path_payment_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "PAYDEX", None, "100", "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "1000.5", [ Asset( "USD", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), Asset( "BTC", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), ], ) .append_path_payment_strict_receive_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "PAYDEX", None, "100", "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "1000.5", [ Asset( "USD", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), Asset( "BTC", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), ], ) .append_path_payment_strict_send_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", "PAYDEX", None, "100", "XCN", "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", "1000.5", [ Asset( "USD", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), Asset( "BTC", "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", ), ], ) .append_allow_trust_op( "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6", "XCN", True ) .append_set_options_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", 1, 6, 20, 20, 20, 20, "paydexcn.org", Signer.ed25519_public_key( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF", 10 ), "GDF5O4OWEMVBY5FLDHWA5RZTYSV2U276XGKZZ6VSHDDR3THSQ6OQS7UM", ) .append_ed25519_public_key_signer( "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", 5 ) .append_hashx_signer( bytes.fromhex( "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8000" ), 10, ) .append_pre_auth_tx_signer( bytes.fromhex( "2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cfa4fc5a000" ), 10, ) .append_inflation_op() .append_manage_data_op("hello", "overcat") .append_bump_sequence_op(10) .append_manage_buy_offer_op( "XCN", "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", "PAYDEX", None, "10.5", "11.25", ) .append_manage_sell_offer_op( "PAYDEX", None, "XCN", "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", "10.5", Price(8, 9), 10086, ) .append_create_passive_sell_offer_op( "XCN", "GCN4HBZGFPOAI5DF4YQIS6OBC6KJKDC7CJSS5B4FWEXMJSWOPEYABLSD", "PAYDEX", None, "10.5", "11.25", ) .append_account_merge_op( "GAXN7HZQTHIPW7N2HGPAXMR42LPJ5VLYXMCCOX4D3JC4CQZGID3UYUPF" ) .build() ) xdr = "AAAAAMvXcdYjKhx0qxnsDsczxKuqa/65lZz6sjjHHczyh50JAAAKjAAAAAAAAAACAAAAAQAAAABdUQHwAAAAAF1RKQAAAAABAAAAElN0ZWxsYXIgUHl0aG9uIFNESwAAAAAAEgAAAAEAAAAAy9dx1iMqHHSrGewOxzPEq6pr/rmVnPqyOMcdzPKHnQkAAAAAAAAAANspYkKUk/8Uke2IS7CdNxkxUCocYSU7D9+VRVRh1UTCAAAAAANHO8AAAAAAAAAABgAAAAFYQ04AAAAAAMvXcdYjKhx0qxnsDsczxKuqa/65lZz6sjjHHczyh50JAAAA6NSlEAAAAAAAAAAAAQAAAAAu358wmdD7fbo5nguyPNLentV4uwQnX4PaRcFDJkD3TAAAAAAAAAAAB00zoAAAAAAAAAACAAAAAAAAAAA7msoAAAAAAC7fnzCZ0Pt9ujmeC7I80t6e1Xi7BCdfg9pFwUMmQPdMAAAAAVhDTgAAAAAAy9dx1iMqHHSrGewOxzPEq6pr/rmVnPqyOMcdzPKHnQkAAAACVFgvQAAAAAIAAAABVVNEAAAAAADbKWJClJP/FJHtiEuwnTcZMVAqHGElOw/flUVUYdVEwgAAAAFCVEMAAAAAANspYkKUk/8Uke2IS7CdNxkxUCocYSU7D9+VRVRh1UTCAAAAAAAAAAIAAAAAAAAAADuaygAAAAAALt+fMJnQ+326OZ4LsjzS3p7VeLsEJ1+D2kXBQyZA90wAAAABWENOAAAAAADL13HWIyocdKsZ7A7HM8Srqmv+uZWc+rI4xx3M8oedCQAAAAJUWC9AAAAAAgAAAAFVU0QAAAAAANspYkKUk/8Uke2IS7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AAAQAAAAIzienw8aZfGXNsrPVEwuglMT6ER/VpIzu42zmqYHyAAAAAAAoAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEttLIsoBgRnFAnqAV4gT/89YLNpKqeMc2StDz6T8WgAAAAAAoAAAAAAAAACQAAAAAAAAAKAAAABWhlbGxvAAAAAAAAAQAAAAdvdmVyY2F0AAAAAAAAAAALAAAAAAAAAAoAAAAAAAAADAAAAAFYQ04AAAAAAJvDhyYr3AR0ZeYgiXnBF5SVDF8SZS6HhbEuxMrOeTAAAAAAAAAAAAAGQixAAAAALQAAAAQAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAFYQ04AAAAAAJvDhyYr3AR0ZeYgiXnBF5SVDF8SZS6HhbEuxMrOeTAAAAAAAAZCLEAAAAAIAAAACQAAAAAAACdmAAAAAAAAAAQAAAABWENOAAAAAACbw4cmK9wEdGXmIIl5wReUlQxfEmUuh4WxLsTKznkwAAAAAAAAAAAABkIsQAAAAC0AAAAEAAAAAAAAAAgAAAAALt+fMJnQ+326OZ4LsjzS3p7VeLsEJ1+D2kXBQyZA90wAAAAAAAAAAfKHnQkAAABAK4QrN2s/qldwTQG+XHZ/KgKmc1t3MoTE7wa34OuIBVCDdC58WChaHVaB40hcGGbR6Q9Y83Qdj+e1dPNLBQ18Bw==" signer = Keypair.from_secret( "SCCS5ZBI7WVIJ4SW36WGOQQIWJYCL3VOAULSXX3FB57USIO25EDOYQHH" ) te.sign(signer) assert te.to_xdr() == xdr_signed restore_te = TransactionBuilder.from_xdr( xdr_signed, Network.TESTNET_NETWORK_PASSPHRASE ).build() assert restore_te.to_xdr() == xdr assert source.sequence == sequence + 1
class TestOperationUtils: def test_check_source(self): check_source(None) check_source("GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY") @pytest.mark.parametrize( "source", ["GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RBAD", "", " ", 123], ) def test_check_source_raise(self, source): with pytest.raises( ValueError, match="Invalid Ed25519 Public Key: {}".format(source) ): check_source(source) def test_check_ed25519_public_key(self): check_ed25519_public_key( "GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY" ) @pytest.mark.parametrize( "source", ["GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RBAD", "", " ", 123], ) def test_check_ed25519_public_key_raise(self, source): with pytest.raises( ValueError, match="Invalid Ed25519 Public Key: {}".format(source) ): check_ed25519_public_key(source) @pytest.mark.parametrize( "amount", [ "0", "0.0000000", "922337203685.4775807", "123466", Decimal(12), Decimal("0.0000000"), Decimal("922337203685.4775807"), Decimal("123466"), ], ) def test_check_amount(self, amount): check_amount(amount) @pytest.mark.parametrize("amount", [234, Price(12, 34)]) def test_check_amount_type_raise(self, amount): with pytest.raises( TypeError, match="amount should be type of {} or {}.".format(str, Decimal) ): check_amount(amount) @pytest.mark.parametrize( "amount", [ "-0.1", "922337203685.4775808", Decimal("-0.1"), Decimal("922337203685.4775808"), ], ) def test_check_amount_exceed_raise(self, amount): with pytest.raises( ValueError, match="Value of '{}' must represent a positive " "number and the max valid value is 922337203685.4775807.".format(amount), ): check_amount(amount) @pytest.mark.parametrize( "amount", [ "0.00000000", "922337203685.47758001", Decimal("0.00000000"), Decimal("922337203685.47758001"), ], ) def test_check_amount_bad_precision_raise(self, amount): with pytest.raises( ValueError, match="must have at most 7 digits after the decimal.".format(amount), ): check_amount(amount) @pytest.mark.parametrize( "price", [ "0", "0.0000000", "922337203685.4775807", "123466", Decimal(12), Decimal("0.0000000"), Decimal("922337203685.4775807"), Decimal("123466"), Price(1, 2), ], ) def test_check_price(self, price): check_price(price) @pytest.mark.parametrize("price", [234, True]) def test_check_price_type_raise(self, price): with pytest.raises( TypeError, match="amount should be type of {}, {} or {}.".format(str, Decimal, Price), ): check_price(price) @pytest.mark.parametrize( "price", [ "-0.1", "922337203685.4775808", Decimal("-0.1"), Decimal("922337203685.4775808"), ], ) def test_check_price_exceed_raise(self, price): with pytest.raises( ValueError, match="Value of '{}' must represent a positive " "number and the max valid value is 922337203685.4775807.".format(price), ): check_price(price) @pytest.mark.parametrize( "price", [ "0.00000000", "922337203685.47758001", Decimal("0.00000000"), Decimal("922337203685.47758001"), ], ) def test_check_price_bad_precision_raise(self, price): with pytest.raises( ValueError, match="must have at most 7 digits after the decimal.".format(price), ): check_price(price) @pytest.mark.parametrize("asset_code", ["PAYDEX", "Bananana", "Bananananana"]) def test_check_asset_code(self, asset_code): check_asset_code(asset_code) @pytest.mark.parametrize("asset_code", ["", "Banananananan", "PAYDEX-XCN"]) def test_check_asset_code_raise(self, asset_code): with pytest.raises(AssetCodeInvalidError, match="Asset code is invalid"): check_asset_code(asset_code)