Exemple #1
0
 def test_asset_to_dict(self):
     native = Asset('XLM')
     assert native.to_dict() == {'code': 'XLM', 'type': 'native'}
     assert self.cny.to_dict() == {
         'code': 'CNY',
         'issuer': self.source,
         'type': 'credit_alphanum4'
     }
def test_manage_offer_dict_price_raises():
    msg = "You need pass `price` params as `str` or `{'n': numerator, 'd': denominator}`"
    with pytest.raises(NotValidParamError, match=msg):
        ManageOffer(
            selling=Asset('beer', SOURCE),
            buying=Asset('beer', DEST),
            amount="100",
            price={},
            offer_id=1,
        ).xdr()
 def test_createPassiveOffer_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAQAAAABYmVlcgAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAFiZWVyAAAAAK2uFogrxa/78nU4lG0kBdB8JKhKz/MHOgVEGr96kkCOAAAAADuaygAABMsvAAGGoAAAAAAAAAABzT4TYwAAAECvQiQXbKoZxYnF4qVL8GNBEzECgKUc0lNLJLYF/ML3mwPYkYRyldfxZ8h04P3iSjBmE+3srS05Ncajuy7+qugL'
     assert (result == self.do(
         setup.network,
         op=CreatePassiveOffer(
             selling=Asset('beer', self.source),
             buying=Asset('beer', self.dest),
             amount="100",
             price=3.14159,
         )))
 def test_manageOffer_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAMAAAABYmVlcgAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAFiZWVyAAAAAK2uFogrxa/78nU4lG0kBdB8JKhKz/MHOgVEGr96kkCOAAAAADuaygAABMsvAAGGoAAAAAAAAAABAAAAAAAAAAHNPhNjAAAAQCvR7B7vbXDy1ShEhYhlNzRIZRJ2DSmVhWe5kCDLWf9GTNhiSEfigaVs7UrPSeDWqPUVyzYx7Igu9JG6OL6WMwM='
     assert (result == self.do(
         setup.network,
         op=ManageOffer(
             selling=Asset('beer', self.source),
             buying=Asset('beer', self.dest),
             amount="100",
             price=3.14159,
             offer_id=1,
         )))
 def test_createPassiveOffer_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAQAAAABYmVlcgAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAFiZWVyAAAAAK2uFogrxa/78nU4lG0kBdB8JKhKz/MHOgVEGr96kkCOAAAAAACYloAABMsvAAGGoAAAAAAAAAABzT4TYwAAAECHcqJBPR2A4wLrJ5uc7ubrK/zcyLPj2XbPvEVZgVkVA/L4jD564uZpclEELdCN7pIyMwgJqvJ6vsmn3ENG6zEC'
     generated_result = self.do(
         setup.network,
         op=CreatePassiveOffer(
             selling=Asset('beer', self.source),
             buying=Asset('beer', self.dest),
             amount="100",
             price=3.14159,
         ))
     assert result == generated_result
 def test_manageOffer_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAMAAAABYmVlcgAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAFiZWVyAAAAAK2uFogrxa/78nU4lG0kBdB8JKhKz/MHOgVEGr96kkCOAAAAAACYloAABMsvAAGGoAAAAAAAAAABAAAAAAAAAAHNPhNjAAAAQFLiIbhd97SZ79ilXZvqL+WpJsZ0J5PmrrEQVtogAGFnRAOAUO1fi1nKgnBWYw0WtLpnv66wGljFzBVaGVG4TQw='
     generated_result = self.do(
         setup.network,
         op=ManageOffer(
             selling=Asset('beer', self.source),
             buying=Asset('beer', self.dest),
             amount="100",
             price=3.14159,
             offer_id=1,
         ))
     assert result == generated_result
 def test_pathPayment_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAIAAAAAAAAAAACYloAAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAACYloAAAAAAAAAAAAAAAAHNPhNjAAAAQI1tBUmMqDa497gw9JJVgucfaiKr2e8VNWg/Pw9jM1d9qNWHBvEHxTLtBDyFKuJEguV1KVS7vBjFznlVCnKC3AI='
     assert (result == self.do(
         setup.network,
         op=PathPayment(
             source=self.source,
             destination=self.dest,
             send_asset=Asset.native(),
             dest_asset=Asset.native(),
             send_max=self.amount,
             dest_amount=self.amount,
             path=[],
         )))
 def test_mix_2(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAABkAAAAAAAAAACAAAAAAAAAAAAAAAEAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABRVVSAAAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAjhvJvwQAAAAAAAAAAAAcAAAAA01KM3XCt1+LHD7jDTOYpe/HGKSDoQoyL1JbUOc0+E2MAAAABRVVSAAAAAAEAAAAAAAAAAQAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAFFVVIAAAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjACOG8m/BAAAAAAAAAAAAAc0+E2MAAABAKHsltQKqjdueu13k7PI7cLg4Tya2aOFH+1Sc9qeK4z0AXxropuRVHhyuriPu/ZXHIRVDvD5xQ0SmMFPVFtU0BA=='
     assert (result == self.make_envelope(
         setup.network,
         SetOptions(set_flags=1),
         ChangeTrust(
             asset=Asset('EUR', self.address), limit="1000000000"),
         AllowTrust(
             authorize=True, asset_code='EUR',
             trustor=self.address),
         Payment(
             destination=self.accounts[0]['address'],
             asset=Asset('EUR', self.address),
             amount="1000000000")))
 def test_pathPayment_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAIAAAAAAAAAAAABhqAAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAAABhqAAAAAAAAAAAAAAAAHNPhNjAAAAQGWG1c11+P5HUofw6Wm0X1JpLtlTUA/z3keudcwVFBt0rjqi2xNHcBdon2yeVDrAdJy6ekEfUIrSW+WopWlUlAw='
     generated_result = self.do(
         setup.network,
         op=PathPayment(
             source=self.source,
             destination=self.dest,
             send_asset=Asset.native(),
             dest_asset=Asset.native(),
             send_max=self.amount,
             dest_amount=self.amount,
             path=[],
         ))
     assert result == generated_result
 def test_mix_2(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAABkAAAAAAAAAACAAAAAAAAAAAAAAAEAAAAAAAAAAUAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABRVVSAAAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAWvMQekAAAAAAAAAAAAcAAAAA01KM3XCt1+LHD7jDTOYpe/HGKSDoQoyL1JbUOc0+E2MAAAABRVVSAAAAAAEAAAAAAAAAAQAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAFFVVIAAAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAABa8xB6QAAAAAAAAAAAAc0+E2MAAABAPHgIBJbGKmNALe+2h/ZXDkKQejZi717P2UKV7jt4EMh81QPX0+PMINIJsZDhZokawfQsXw157pnxe0z28c5MAA=='
     generated_result = self.make_envelope(
         setup.network,
         SetOptions(set_flags=1),
         ChangeTrust(
             asset=Asset('EUR', self.address), limit="1000000000"),
         AllowTrust(
             authorize=True, asset_code='EUR',
             trustor=self.address),
         Payment(
             destination=self.accounts[0]['address'],
             asset=Asset('EUR', self.address),
             amount="1000000000"))
     assert result == generated_result
 def test_double_payment(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAyAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAAAAAAAvrwgAAAAAAAAAAAQAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAAAAAAAF9eEAAAAAAAAAAABzT4TYwAAAEAC/EENKQWCZFsKcNMEpWi7TVstQF0JbmBj/+QwkQXW8q/isCHX+UikrhxXJpI5NDKdagnH0godVShWxK1PENAC'
     assert (result == self.make_envelope(
         setup.network,
         Payment(
             destination=self.accounts[0]['address'],
             asset=Asset.native(),
             amount=self.amount,
         ),
         Payment(
             destination=self.accounts[1]['address'],
             asset=Asset.native(),
             amount="40",
         ),
     ))
 def test_double_payment(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAyAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAAAAAAAAehIAAAAAAAAAAAQAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAAAAAAAAD0JAAAAAAAAAAABzT4TYwAAAEB5lgq+jygYUAHyPNvDyhImdNJEInQ1H3dkWOMNX9x7s99Us+o23nx2yWDQAJcDOFMgwM2tbaFKijY3HQEopigI'
     generated_result = self.make_envelope(
         setup.network,
         Payment(
             destination=self.accounts[0]['address'],
             asset=Asset.native(),
             amount=self.amount,
         ),
         Payment(
             destination=self.accounts[1]['address'],
             asset=Asset.native(),
             amount="40",
         ),
     )
     assert result == generated_result
 def test_payment_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAACYloAAAAAAAAAAAc0+E2MAAABAlw7SoaRvm53xhs7ztskutJ3MlhBJ0ME2+uSBLiSCNV+wSolCAIIlWlMF376ciT5V9J6iWMcW1hVrZAQSI4cjDw=='
     assert (result == self.do(
         setup.network,
         op=Payment(
             source=self.source,
             destination=self.dest,
             asset=Asset.native(),
             amount=self.amount,
         )))
 def test_payment_short_asset(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAABVVNENAAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAAAmJaAAAAAAAAAAAHNPhNjAAAAQJHNNenCn8ZIQMoYh86u6dVxZ20ZIsPeZFqRlNpzwgp4P5a0w82Q/pcg2vdG5h6xVClY7zKqK1JSIU1/RDlCvA0='
     assert (result == self.do(
         setup.network,
         op=Payment(
             source=self.source,
             destination=self.dest,
             asset=Asset('USD4', self.source),
             amount=self.amount,
         )))
 def test_payment_long_asset(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAACU05BQ0tTNzg5QUJDAAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAAACYloAAAAAAAAAAAc0+E2MAAABAvtmMm0ySPn7q3SXccCPVa/J58MsWiL5ID/LlPRHtPP6A6N6LeLkB2PG0AXUv4d0t5Z29rKzCW3tlaJbGciYAAA=='
     assert (result == self.do(
         setup.network,
         op=Payment(
             source=self.source,
             destination=self.dest,
             asset=Asset('SNACKS789ABC', self.source),
             amount=self.amount,
         )))
 def test_payment_short_asset(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAABVVNENAAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAAAAYagAAAAAAAAAAHNPhNjAAAAQGdGYF96SPGbe+PoSXejnYdR/ZqcAI+L17V3Dhn7/Munj/cCY6fWHxUR9i3Z8z7/YJpyWIVId1X4C2RDo0TTDQE='
     generated_result = self.do(
         setup.network,
         op=Payment(
             source=self.source,
             destination=self.dest,
             asset=Asset('USD4', self.source),
             amount=self.amount,
         ))
     assert result == generated_result
 def test_payment_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAAABhqAAAAAAAAAAAc0+E2MAAABA38jqPW3m8yeamMmzG65hUsjz5PqJwi4zW5LwOcs7vJVk+lPGOSpG5Qvbe0m7eZN9glfZQRfj5UYyB6bWJgxXAw=='
     generated_result = self.do(
         setup.network,
         op=Payment(
             source=self.source,
             destination=self.dest,
             asset=Asset.native(),
             amount=self.amount,
         ))
     assert result == generated_result
 def test_payment_long_asset(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAACU05BQ0tTNzg5QUJDAAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAAAABhqAAAAAAAAAAAc0+E2MAAABAVZAZ6qnMRld3XMKazaRyQWzJ5c2fGPCwFFJAtIWtGCJE3jGeRzfagQPDRZS+dze+jyp1iNztV2XVhIAaWddJAA=='
     generated_result = self.do(
         setup.network,
         op=Payment(
             source=self.source,
             destination=self.dest,
             asset=Asset('SNACKS789ABC', self.source),
             amount=self.amount,
         ))
     assert result == generated_result
 def test_mix_1(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAADhAAAAAAAAAACAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAAB6EgAAAAAAAAAABAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAAAAAAAAAHoSAAAAAAAAAAAIAAAAAAAAAAAAehIAAAAAAoEATyhnfBjtgSGL5Fr4oHlw/X4bIYnH44zIpor2MQbUAAAAAAAAAAAAehIAAAAAAAAAAAAAAAAMAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAFiZWVyAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAAACYloAABMsvAAGGoAAAAAAAAAABAAAAAAAAAAQAAAABYmVlcgAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAFiZWVyAAAAAKBAE8oZ3wY7YEhi+Ra+KB5cP1+GyGJx+OMyKaK9jEG1AAAAAACYloAABMsvAAGGoAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+H//////////AAAAAAAAAAcAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAABYmVlcgAAAAEAAAAAAAAACAAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAAAAAABzT4TYwAAAEA2ATIf8i+oHGbZqbzRrz9la4N83uIIvlkDwzvSG3P9IQnDnmu3SsvmmE62ldxqLAOmkNDzsARFno2ki3ZS8jIE'
     generated_result = self.make_envelope(
         setup.network,
         CreateAccount(
             destination=self.accounts[0]['address'],
             starting_balance=self.amount,
         ),
         Payment(
             destination=self.accounts[1]['address'],
             asset=Asset.native(),
             amount=self.amount,
         ),
         PathPayment(
             destination=self.accounts[2]['address'],
             send_asset=Asset.native(),
             dest_asset=Asset.native(),
             send_max=self.amount,
             dest_amount=self.amount,
             path=[],
         ),
         ManageOffer(
             selling=Asset('beer', self.accounts[0]['address']),
             buying=Asset('beer', self.accounts[1]['address']),
             amount="100",
             price=3.14159,
             offer_id=1,
         ),
         CreatePassiveOffer(
             selling=Asset('beer', self.accounts[1]['address']),
             buying=Asset('beer', self.accounts[2]['address']),
             amount="100",
             price=3.14159,
         ), SetOptions(),
         ChangeTrust(
             asset=Asset('beer', self.accounts[0]['address']), ),
         AllowTrust(
             trustor=self.accounts[0]['address'],
             asset_code='beer',
             authorize=True,
         ), AccountMerge(destination=self.accounts[0]['address'], ))
     assert result == generated_result
 def test_mix_1(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAADhAAAAAAAAAACAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAC+vCAAAAAAAAAAABAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAAAAAAAAL68IAAAAAAAAAAAIAAAAAAAAAAAvrwgAAAAAAoEATyhnfBjtgSGL5Fr4oHlw/X4bIYnH44zIpor2MQbUAAAAAAAAAAAvrwgAAAAAAAAAAAAAAAAMAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAFiZWVyAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAADuaygAABMsvAAGGoAAAAAAAAAABAAAAAAAAAAQAAAABYmVlcgAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAFiZWVyAAAAAKBAE8oZ3wY7YEhi+Ra+KB5cP1+GyGJx+OMyKaK9jEG1AAAAADuaygAABMsvAAGGoAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+H//////////AAAAAAAAAAcAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAABYmVlcgAAAAEAAAAAAAAACAAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAAAAAABzT4TYwAAAEAY0YGZzC1qiKatKCWaCttK1fEs3P4DpVWw2AQCdvVBS4dkCyfxu7N7tpQPEZ4WqXzAiR0D7r5L6f848pmNsgIL'
     assert (result == self.make_envelope(
         setup.network,
         CreateAccount(
             destination=self.accounts[0]['address'],
             starting_balance=self.amount,
         ),
         Payment(
             destination=self.accounts[1]['address'],
             asset=Asset.native(),
             amount=self.amount,
         ),
         PathPayment(
             destination=self.accounts[2]['address'],
             send_asset=Asset.native(),
             dest_asset=Asset.native(),
             send_max=self.amount,
             dest_amount=self.amount,
             path=[],
         ),
         ManageOffer(
             selling=Asset('beer', self.accounts[0]['address']),
             buying=Asset('beer', self.accounts[1]['address']),
             amount="100",
             price=3.14159,
             offer_id=1,
         ),
         CreatePassiveOffer(
             selling=Asset('beer', self.accounts[1]['address']),
             buying=Asset('beer', self.accounts[2]['address']),
             amount="100",
             price=3.14159,
         ), SetOptions(),
         ChangeTrust(
             asset=Asset('beer', self.accounts[0]['address']), ),
         AllowTrust(
             trustor=self.accounts[0]['address'],
             asset_code='beer',
             authorize=True,
         ), AccountMerge(destination=self.accounts[0]['address'], )))
Exemple #21
0
def setup():
    class Struct:
        """Handy variable holder"""
        def __init__(self, **entries):
            self.__dict__.update(entries)

    issuer_keypair = Keypair.random()
    test_asset = Asset('TEST', issuer_keypair.address().decode())

    # local testnet (kinecosystem docker)
    from kin_base.network import NETWORKS
    # we will leave this passphrase instead of changing every envelop in the test suite
    NETWORKS['CUSTOM'] = 'Integration Test Network ; zulucrypto'
    return Struct(type='local',
                  network='CUSTOM',
                  issuer_keypair=issuer_keypair,
                  test_asset=test_asset,
                  horizon_endpoint_uri='http://localhost:8008',
                  friendbot_url='http://localhost:8001')
        async def create_payout_xdr(payout_info, start_date, end_date, src_wallet, write_directory, digital_service_id_kin_2, kin_2_amount, sequence_increment = 0):
                operations = []
                for ix, row in payout_info.iterrows():
                        if row['digital_service_id'] == digital_service_id_kin_2:
                                amt = str(round(row['total_payout'], 2) - kin_2_amount)
                        else:
                                amt = str(round(row['total_payout'], 2))
                        payment_op = Payment(
                            destination=row['wallet'],
                            amount=amt,
                            asset=Asset.native()
                        )
                        operations.append(payment_op)

                async with Horizon(horizon_uri='https://horizon.kinfederation.com') as horizon:
                        total_fee = len(payout_info.index) * 100
                        network_id = "PUBLIC"
                        account_result = await horizon.account(src_wallet)

                sequence = int(account_result['sequence']) + 1

                tx = Transaction(
                        source = src_wallet,
                        sequence = int(sequence) + sequence_increment,
                        time_bounds = {'minTime': 0, 'maxTime': 0},
                        fee = total_fee,
                        operations = operations,
                        memo = None
                )

                envelope = Te(tx=tx, network_id="PUBLIC")
                xdr = envelope.xdr() 
                f = open(write_directory + "/xdr" + str(sequence_increment) + ".xdr", "w")
                f.write(xdr.decode("utf-8"))
                f.close()
                print(xdr.decode("utf-8"))
Exemple #23
0
# See: https://www.stellar.org/developers/guides/issuing-assets.html

from kin_base.keypair import Keypair
from kin_base.asset import Asset
from kin_base.builder import Builder

# Keys for accounts to issue and receive the new asset
issuing_secret = 'SCBHQEGSNBTT4S7Y73YAF3M3JSVSTSNBGAVU5M4XVFGUF7664EUXQHFU'
issuing_public = Keypair.from_seed(issuing_secret).address().decode()

receiving_secret = 'SB6MJ6M3BPJZUGFP2QCODUIKWQWF6AIN4Z6L3J6PWL3QGDW4L6YR3QIU'
receiving_public = Keypair.from_seed(receiving_secret).address().decode()

# Create an object to represent the new asset
my_asset = Asset('Hello', issuing_public)

# First, the receiving account must trust the asset
builder = Builder(receiving_secret, network='TESTNET').append_trust_op(
    destination=my_asset.issuer, code=my_asset.code)
builder.sign()
resp = builder.submit()
print(resp)

# Second, the issuing account actually sends a payment using the asset
builder = Builder(issuing_secret, network='TESTNET').append_payment_op(
    destination=receiving_public,
    amount='1000',
    asset_code=my_asset.code,
    asset_issuer=my_asset.issuer)
builder.sign()
resp = builder.submit()
Exemple #24
0
 def test_unxdr(self):
     xdr = self.cny.xdr()
     cny_x = Asset.from_xdr(xdr)
     assert self.cny == cny_x
Exemple #25
0
 def test_no_issuer(self):
     with pytest.raises(
             Exception,
             match='Issuer cannot be `None` except native asset.'):
         Asset('beer', None)
Exemple #26
0
 def test_too_long(self):
     with pytest.raises(Exception, match='Asset code is invalid'):
         Asset('123456789012TooLong', self.source)
Exemple #27
0
 def test_is_native(self):
     native = Asset('XLM')
     assert native.is_native()
     assert not self.cny.is_native()
Exemple #28
0
 def test_native(self):
     assert 'XLM' == Asset.native().code
     assert Asset.native().issuer is None
     assert 'native' == Asset.native().type
Exemple #29
0
 def setUpClass(cls):
     cls.source = (
         'GDJVFDG5OCW5PYWHB64MGTHGFF57DRRJEDUEFDEL2SLNIOONHYJWHA3Z')
     cls.cny = Asset('CNY', cls.source)
 def test_changeTrust_min(self, setup):
     result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAYAAAABYmVlcgAAAACtrhaIK8Wv+/J1OJRtJAXQfCSoSs/zBzoFRBq/epJAjn//////////AAAAAAAAAAHNPhNjAAAAQEMLKLk6BmEehiEqR155eZoHTMf0bFoZcsvTZpv1KDPXkOdyJZlinNR6FHv7Odk/kvxV5pYET+zqrLCJUwhcjgs='
     generated_result = self.do(
         setup.network, op=ChangeTrust(asset=Asset('beer', self.dest), ))
     assert result == generated_result