Exemplo n.º 1
0
 def test_to_json(self, expected, version):
     transaction = Transfer('3N8TQ1NLN8KcwJnVZM777GUCdUnEZWZ85Rb',
                            120000000, 'hello')
     transaction.timestamp = 1326499200000
     transaction.version = version
     transaction.sign_with(self.account)
     assert transaction.to_json() == expected
Exemplo n.º 2
0
    def test_sponsor_with(self):
        transaction = Transfer('3N8TQ1NLN8KcwJnVZM777GUCdUnEZWZ85Rb', 10000)
        with pytest.raises(Exception):
            transaction.sponsor_with(self.account2)
        transaction.sign_with(self.account)

        transaction.sponsor_with(self.account2)
        assert transaction.sponsor == self.account2.address
        assert transaction.sponsor_public_key == base58.b58encode(
            self.account2.public_key.__bytes__())
        assert transaction.sponsor_key_type == 'ed25519'

        assert self.account2.verify_signature(transaction.to_binary(),
                                              transaction.proofs[1])

        json = transaction.to_json()
        assert json['sponsor'] == self.account2.address
        assert json['sponsorPublicKey'] == base58.b58encode(
            self.account2.public_key.__bytes__())
        assert json['sponsorKeyType'] == self.account2.key_type