Commit 92469608 authored by inso's avatar inso

Format under setup.py

parent d31b2a5d
language: python
python:
- "3.4"
# command to install dependencies
install:
- pip install -r requirements.txt
# command to run tests
script: setup.py test
\ No newline at end of file
......@@ -3,7 +3,7 @@ Created on 12 déc. 2014
@author: inso
'''
import pytest
import unittest
from ucoinpy.documents.block import Block
raw_block = """Version: 1
......@@ -71,95 +71,102 @@ Transactions:
"""
class Test_Block:
class Test_Block(unittest.TestCase):
def test_fromraw(self):
block = Block.from_signed_raw(raw_block)
assert block.version == 1
assert block.currency == "zeta_brouzouf"
assert block.noonce == 45079
assert block.number == 15
assert block.powmin == 4
assert block.time == 1418083330
assert block.mediantime == 1418080208
assert block.issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert block.prev_hash == "0000E73C340601ACA1AD5AAA5B5E56B03E178EF8"
assert block.prev_issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert block.members_count == 4
assert block.identities == []
assert block.joiners == []
assert block.actives == []
assert block.leavers == []
assert block.excluded == []
assert block.certifications == []
assert block.transactions == []
self.assertEquals(block.version, 1)
self.assertEquals(block.currency, "zeta_brouzouf")
self.assertEquals(block.noonce, 45079)
self.assertEquals(block.number, 15)
self.assertEquals(block.powmin, 4)
self.assertEquals(block.time, 1418083330)
self.assertEquals(block.mediantime, 1418080208)
self.assertEquals(block.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(block.prev_hash, "0000E73C340601ACA1AD5AAA5B5E56B03E178EF8")
self.assertEquals(block.prev_issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(block.members_count, 4)
self.assertEquals(block.identities, [])
self.assertEquals(block.joiners, [])
self.assertEquals(block.actives, [])
self.assertEquals(block.leavers, [])
self.assertEquals(block.excluded, [])
self.assertEquals(block.certifications, [])
self.assertEquals(block.transactions, [])
def test_from_signed_raw_block_zero(self):
block = Block.from_signed_raw(raw_block_zero)
assert block.version == 1
assert block.currency == "zeta_brouzouf"
assert block.noonce == 2125
assert block.number == 0
assert block.powmin == 3
assert block.time == 1418077277
assert block.mediantime == 1418077277
assert block.issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert block.parameters == ('0.01','302400','100','5259600','2629800','3','5',
'2629800','3','11','600','10','20','0.67')
assert block.members_count == 4
assert len(block.identities) == 4
assert len(block.joiners) == 4
assert block.actives == []
assert block.leavers == []
assert block.excluded == []
assert len(block.certifications) == 12
assert block.transactions == []
self.assertEquals(block.version, 1)
self.assertEquals(block.currency, "zeta_brouzouf")
self.assertEquals(block.noonce, 2125)
self.assertEquals(block.number, 0)
self.assertEquals(block.powmin, 3)
self.assertEquals(block.time, 1418077277)
self.assertEquals(block.mediantime, 1418077277)
self.assertEquals(block.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(block.parameters, ('0.01','302400','100','5259600','2629800','3','5',
'2629800','3','11','600','10','20','0.67'))
self.assertEquals(block.members_count, 4)
self.assertEquals(len(block.identities), 4)
self.assertEquals(len(block.joiners), 4)
self.assertEquals(block.actives, [])
self.assertEquals(block.leavers, [])
self.assertEquals(block.excluded, [])
self.assertEquals(len(block.certifications), 12)
self.assertEquals(block.transactions, [])
self.assertEqual(block.raw(), raw_block_zero)
def test_toraw_fromsignedraw(self):
block = Block.from_signed_raw(raw_block)
rendered_raw = block.signed_raw()
from_rendered_raw = Block.from_signed_raw(rendered_raw)
assert from_rendered_raw.version == 1
assert from_rendered_raw.currency == "zeta_brouzouf"
assert from_rendered_raw.noonce == 45079
assert from_rendered_raw.number == 15
assert from_rendered_raw.powmin == 4
assert from_rendered_raw.time == 1418083330
assert from_rendered_raw.mediantime == 1418080208
assert from_rendered_raw.issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert from_rendered_raw.prev_hash == "0000E73C340601ACA1AD5AAA5B5E56B03E178EF8"
assert from_rendered_raw.prev_issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert from_rendered_raw.members_count == 4
assert from_rendered_raw.identities == []
assert from_rendered_raw.joiners == []
assert from_rendered_raw.actives == []
assert from_rendered_raw.leavers == []
assert from_rendered_raw.excluded == []
assert from_rendered_raw.certifications == []
assert from_rendered_raw.transactions == []
self.assertEquals(from_rendered_raw.version, 1)
self.assertEquals(from_rendered_raw.currency, "zeta_brouzouf")
self.assertEquals(from_rendered_raw.noonce, 45079)
self.assertEquals(from_rendered_raw.number, 15)
self.assertEquals(from_rendered_raw.powmin, 4)
self.assertEquals(from_rendered_raw.time, 1418083330)
self.assertEquals(from_rendered_raw.mediantime, 1418080208)
self.assertEquals(from_rendered_raw.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(from_rendered_raw.prev_hash, "0000E73C340601ACA1AD5AAA5B5E56B03E178EF8")
self.assertEquals(from_rendered_raw.prev_issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(from_rendered_raw.members_count, 4)
self.assertEquals(from_rendered_raw.identities, [])
self.assertEquals(from_rendered_raw.joiners, [])
self.assertEquals(from_rendered_raw.actives, [])
self.assertEquals(from_rendered_raw.leavers, [])
self.assertEquals(from_rendered_raw.excluded, [])
self.assertEquals(from_rendered_raw.certifications, [])
self.assertEquals(from_rendered_raw.transactions, [])
self.assertEqual(block.raw(), raw_block)
def test_toraw_fromrawzero(self):
block = Block.from_signed_raw(raw_block_zero)
rendered_raw = block.signed_raw()
from_rendered_raw = block.from_signed_raw(rendered_raw)
assert from_rendered_raw.version == 1
assert from_rendered_raw.currency == "zeta_brouzouf"
assert from_rendered_raw.noonce == 2125
assert from_rendered_raw.number == 0
assert from_rendered_raw.powmin == 3
assert from_rendered_raw.time == 1418077277
assert from_rendered_raw.mediantime == 1418077277
assert from_rendered_raw.issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert from_rendered_raw.parameters == ('0.01','302400','100','5259600','2629800','3','5',
'2629800','3','11','600','10','20','0.67')
assert from_rendered_raw.members_count == 4
assert len(from_rendered_raw.identities) == 4
assert len(from_rendered_raw.joiners) == 4
assert from_rendered_raw.actives == []
assert from_rendered_raw.leavers == []
assert from_rendered_raw.excluded == []
assert len(from_rendered_raw.certifications) == 12
assert from_rendered_raw.transactions == []
self.assertEquals(from_rendered_raw.version, 1)
self.assertEquals(from_rendered_raw.currency, "zeta_brouzouf")
self.assertEquals(from_rendered_raw.noonce, 2125)
self.assertEquals(from_rendered_raw.number, 0)
self.assertEquals(from_rendered_raw.powmin, 3)
self.assertEquals(from_rendered_raw.time, 1418077277)
self.assertEquals(from_rendered_raw.mediantime, 1418077277)
self.assertEquals(from_rendered_raw.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(from_rendered_raw.parameters, ('0.01','302400','100','5259600','2629800','3','5',
'2629800','3','11','600','10','20','0.67'))
self.assertEquals(from_rendered_raw.members_count, 4)
self.assertEquals(len(from_rendered_raw.identities), 4)
self.assertEquals(len(from_rendered_raw.joiners), 4)
self.assertEquals(from_rendered_raw.actives, [])
self.assertEquals(from_rendered_raw.leavers, [])
self.assertEquals(from_rendered_raw.excluded, [])
self.assertEquals(len(from_rendered_raw.certifications), 12)
self.assertEquals(from_rendered_raw.transactions, [])
self.assertEqual(block.raw(), raw_block_zero)
if __name__ == '__main__':
unittest.main()
......@@ -4,7 +4,7 @@ Created on 6 déc. 2014
@author: inso
'''
import pytest
import unittest
from ucoinpy.documents.certification import SelfCertification, Certification
selfcert_inlines = ["HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:\
......@@ -20,7 +20,7 @@ cert_inlines = [
qn/XNJjaGIwfnR+wGrDME6YviCQbG+ywsQWnETlAsL6q7o3k1UhpR5ZTVY9dvejLKuC+1mUEXVTmH+8Ib55DBA==\n"
]
class Test_SelfCertification:
class Test_SelfCertification(unittest.TestCase):
'''
classdocs
'''
......@@ -29,31 +29,31 @@ class Test_SelfCertification:
version = 1
currency = "zeta_brousouf"
selfcert = SelfCertification.from_inline(version, currency, selfcert_inlines[0])
assert selfcert.pubkey == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert selfcert.signatures[0] == "h/H8tDIEbfA4yxMQcvfOXVDQhi1sUa9qYtPKrM59Bulv97ouwbAvAsEkC1Uyit1IOpeAV+CQQs4IaAyjE8F1Cw=="
assert selfcert.timestamp == 1416335620
assert selfcert.uid == "cgeek"
self.assertEquals(selfcert.pubkey, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(selfcert.signatures[0], "h/H8tDIEbfA4yxMQcvfOXVDQhi1sUa9qYtPKrM59Bulv97ouwbAvAsEkC1Uyit1IOpeAV+CQQs4IaAyjE8F1Cw==")
self.assertEquals(selfcert.timestamp, 1416335620)
self.assertEquals(selfcert.uid, "cgeek")
selfcert = SelfCertification.from_inline(version, currency, selfcert_inlines[1])
assert selfcert.pubkey == "RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS"
assert selfcert.signatures[0] == "Ah55O8cvdkGS4at6AGOKUjy+wrFwAq8iKRJ5xLIb6Xdi3M8WfGOUdMjwZA6GlSkdtlMgEhQPm+r2PMebxKrCBg=="
assert selfcert.timestamp == 1416428323
assert selfcert.uid == "vit"
self.assertEquals(selfcert.pubkey, "RdrHvL179Rw62UuyBrqy2M1crx7RPajaViBatS59EGS")
self.assertEquals(selfcert.signatures[0], "Ah55O8cvdkGS4at6AGOKUjy+wrFwAq8iKRJ5xLIb6Xdi3M8WfGOUdMjwZA6GlSkdtlMgEhQPm+r2PMebxKrCBg==")
self.assertEquals(selfcert.timestamp, 1416428323)
self.assertEquals(selfcert.uid, "vit")
def test_certifications(self):
version = 1
currency = "zeta_brousouf"
blockhash = "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
cert = Certification.from_inline(version, currency, blockhash, cert_inlines[0])
assert cert.pubkey_from == "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU"
assert cert.pubkey_to == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert cert.blocknumber == 0
assert cert.blockhash == blockhash
assert cert.signatures[0] == "TgmDuMxZdyutroj9jiLJA8tQp/389JIzDKuxW5+h7GIfjDu1ZbwI7HNm5rlUDhR2KreaV/QJjEaItT4Cf75rCQ=="
self.assertEquals(cert.pubkey_from, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
self.assertEquals(cert.pubkey_to, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(cert.blocknumber, 0)
self.assertEquals(cert.blockhash, blockhash)
self.assertEquals(cert.signatures[0], "TgmDuMxZdyutroj9jiLJA8tQp/389JIzDKuxW5+h7GIfjDu1ZbwI7HNm5rlUDhR2KreaV/QJjEaItT4Cf75rCQ==")
cert = Certification.from_inline(version, currency, blockhash, cert_inlines[1])
assert cert.pubkey_from == "9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y"
assert cert.pubkey_to == "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU"
assert cert.blocknumber == 0
assert cert.blockhash == blockhash
assert cert.signatures[0] == "qn/XNJjaGIwfnR+wGrDME6YviCQbG+ywsQWnETlAsL6q7o3k1UhpR5ZTVY9dvejLKuC+1mUEXVTmH+8Ib55DBA=="
self.assertEquals(cert.pubkey_from, "9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y")
self.assertEquals(cert.pubkey_to, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
self.assertEquals(cert.blocknumber, 0)
self.assertEquals(cert.blockhash, blockhash)
self.assertEquals(cert.signatures[0], "qn/XNJjaGIwfnR+wGrDME6YviCQbG+ywsQWnETlAsL6q7o3k1UhpR5ZTVY9dvejLKuC+1mUEXVTmH+8Ib55DBA==")
......@@ -3,7 +3,7 @@ Created on 12 déc. 2014
@author: inso
'''
import pytest
import unittest
from ucoinpy.documents.membership import Membership
membership_inline = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:\
......@@ -22,37 +22,37 @@ dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu8
"""
class Test_Membership:
class Test_Membership(unittest.TestCase):
def test_frominline(self):
membership = Membership.from_inline(1, "zeta_brousouf", 'IN', membership_inline)
assert membership.issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert membership.block_number == 0
assert membership.block_hash == "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
assert membership.cert_ts == 1416335620
assert membership.uid == "cgeek"
assert membership.signatures[0] == "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg=="
assert membership.membership_type == 'IN'
self.assertEquals(membership.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(membership.block_number, 0)
self.assertEquals(membership.block_hash, "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709")
self.assertEquals(membership.cert_ts, 1416335620)
self.assertEquals(membership.uid, "cgeek")
self.assertEquals(membership.signatures[0], "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==")
self.assertEquals(membership.membership_type, 'IN')
def test_fromraw(self):
membership = Membership.from_signed_raw(membership_raw)
assert membership.issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert membership.block_number == 0
assert membership.block_hash == "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
assert membership.cert_ts == 1416335620
assert membership.uid == "cgeek"
assert membership.signatures[0] == "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg=="
assert membership.membership_type == 'IN'
self.assertEquals(membership.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(membership.block_number, 0)
self.assertEquals(membership.block_hash, "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709")
self.assertEquals(membership.cert_ts, 1416335620)
self.assertEquals(membership.uid, "cgeek")
self.assertEquals(membership.signatures[0], "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==")
self.assertEquals(membership.membership_type, 'IN')
def test_fromraw_toraw(self):
membership = Membership.from_signed_raw(membership_raw)
rendered_membership = membership.signed_raw()
from_rendered_membership = Membership.from_signed_raw(rendered_membership)
assert from_rendered_membership.issuer == "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk"
assert from_rendered_membership.block_number == 0
assert from_rendered_membership.block_hash == "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"
assert from_rendered_membership.cert_ts == 1416335620
assert from_rendered_membership.uid == "cgeek"
assert from_rendered_membership.signatures[0] == "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg=="
assert from_rendered_membership.membership_type == 'IN'
self.assertEquals(from_rendered_membership.issuer, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
self.assertEquals(from_rendered_membership.block_number, 0)
self.assertEquals(from_rendered_membership.block_hash, "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709")
self.assertEquals(from_rendered_membership.cert_ts, 1416335620)
self.assertEquals(from_rendered_membership.uid, "cgeek")
self.assertEquals(from_rendered_membership.signatures[0], "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==")
self.assertEquals(from_rendered_membership.membership_type, 'IN')
......@@ -3,7 +3,7 @@ Created on 13 déc. 2014
@author: inso
'''
import pytest
import unittest
from ucoinpy.documents.peer import Peer, BMAEndpoint, UnknownEndpoint
......@@ -20,52 +20,52 @@ dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu8
"""
class TestPeer:
class TestPeer(unittest.TestCase):
def test_fromraw(self):
peer = Peer.from_signed_raw(rawpeer)
assert peer.currency == "beta_brousouf"
assert peer.pubkey == "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY"
assert peer.blockid == "8-1922C324ABC4AF7EF7656734A31F5197888DDD52"
assert len(peer.endpoints) == 3
assert type(peer.endpoints[0]) is BMAEndpoint
assert type(peer.endpoints[1]) is BMAEndpoint
assert type(peer.endpoints[2]) is UnknownEndpoint
self.assertEquals(peer.currency, "beta_brousouf")
self.assertEquals(peer.pubkey, "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY")
self.assertEquals(peer.blockid, "8-1922C324ABC4AF7EF7656734A31F5197888DDD52")
self.assertEquals(len(peer.endpoints), 3)
self.assertTrue(type(peer.endpoints[0]) is BMAEndpoint)
self.assertTrue(type(peer.endpoints[1]) is BMAEndpoint)
self.assertTrue(type(peer.endpoints[2]) is UnknownEndpoint)
assert peer.endpoints[0].server == "some.dns.name"
assert peer.endpoints[0].ipv4 == "88.77.66.55"
assert peer.endpoints[0].ipv6 == "2001:0db8:0000:85a3:0000:0000:ac1f"
assert peer.endpoints[0].port == 9001
self.assertEquals(peer.endpoints[0].server, "some.dns.name")
self.assertEquals(peer.endpoints[0].ipv4, "88.77.66.55")
self.assertEquals(peer.endpoints[0].ipv6, "2001:0db8:0000:85a3:0000:0000:ac1f")
self.assertEquals(peer.endpoints[0].port, 9001)
assert peer.endpoints[1].server == "some.dns.name"
assert peer.endpoints[1].ipv4 == "88.77.66.55"
assert peer.endpoints[1].ipv6 == "2001:0db8:0000:85a3:0000:0000:ac1f"
assert peer.endpoints[1].port == 9002
self.assertEquals(peer.endpoints[1].server, "some.dns.name")
self.assertEquals(peer.endpoints[1].ipv4, "88.77.66.55")
self.assertEquals(peer.endpoints[1].ipv6, "2001:0db8:0000:85a3:0000:0000:ac1f")
self.assertEquals(peer.endpoints[1].port, 9002)
assert peer.signatures[0] == "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg=="
self.assertEquals(peer.signatures[0], "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==")
def test_fromraw_toraw(self):
peer = Peer.from_signed_raw(rawpeer)
rendered_peer = peer.signed_raw()
from_rendered_peer = Peer.from_signed_raw(rendered_peer)
assert from_rendered_peer.currency == "beta_brousouf"
assert from_rendered_peer.pubkey == "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY"
assert from_rendered_peer.blockid == "8-1922C324ABC4AF7EF7656734A31F5197888DDD52"
assert len(from_rendered_peer.endpoints) == 3
assert type(from_rendered_peer.endpoints[0]) is BMAEndpoint
assert type(from_rendered_peer.endpoints[1]) is BMAEndpoint
assert type(from_rendered_peer.endpoints[2]) is UnknownEndpoint
self.assertEquals(from_rendered_peer.currency, "beta_brousouf")
self.assertEquals(from_rendered_peer.pubkey, "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY")
self.assertEquals(from_rendered_peer.blockid, "8-1922C324ABC4AF7EF7656734A31F5197888DDD52")
self.assertEquals(len(from_rendered_peer.endpoints), 3)
self.assertTrue(type(from_rendered_peer.endpoints[0]) is BMAEndpoint)
self.assertTrue(type(from_rendered_peer.endpoints[1]) is BMAEndpoint)
self.assertTrue(type(from_rendered_peer.endpoints[2]) is UnknownEndpoint)
assert from_rendered_peer.endpoints[0].server == "some.dns.name"
assert from_rendered_peer.endpoints[0].ipv4 == "88.77.66.55"
assert from_rendered_peer.endpoints[0].ipv6 == "2001:0db8:0000:85a3:0000:0000:ac1f"
assert from_rendered_peer.endpoints[0].port == 9001
self.assertEquals(from_rendered_peer.endpoints[0].server, "some.dns.name")
self.assertEquals(from_rendered_peer.endpoints[0].ipv4, "88.77.66.55")
self.assertEquals(from_rendered_peer.endpoints[0].ipv6, "2001:0db8:0000:85a3:0000:0000:ac1f")
self.assertEquals(from_rendered_peer.endpoints[0].port, 9001)
assert from_rendered_peer.endpoints[1].server == "some.dns.name"
assert from_rendered_peer.endpoints[1].ipv4 == "88.77.66.55"
assert from_rendered_peer.endpoints[1].ipv6 == "2001:0db8:0000:85a3:0000:0000:ac1f"
assert from_rendered_peer.endpoints[1].port == 9002
self.assertEquals(from_rendered_peer.endpoints[1].server, "some.dns.name")
self.assertEquals(from_rendered_peer.endpoints[1].ipv4, "88.77.66.55")
self.assertEquals(from_rendered_peer.endpoints[1].ipv6, "2001:0db8:0000:85a3:0000:0000:ac1f")
self.assertEquals(from_rendered_peer.endpoints[1].port, 9002)
assert from_rendered_peer.signatures[0] == "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg=="
self.assertEquals(from_rendered_peer.signatures[0], "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==")
......@@ -3,7 +3,7 @@ Created on 13 déc. 2014
@author: inso
'''
import pytest
import unittest
from ucoinpy.documents.status import Status
raw_status = """Version: 1
......@@ -17,22 +17,22 @@ dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu8
"""
class Test_Status:
class Test_Status(unittest.TestCase):
def test_fromraw(self):
status = Status.from_signed_raw(raw_status)
assert status.status == 'UP'
assert status.blockid == "8-1922C324ABC4AF7EF7656734A31F5197888DDD52"
assert status.sender == "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY"
assert status.recipient == "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU"
assert status.signatures[0] == "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg=="
self.assertEquals(status.status, 'UP')
self.assertEquals(status.blockid, "8-1922C324ABC4AF7EF7656734A31F5197888DDD52")
self.assertEquals(status.sender, "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY")
self.assertEquals(status.recipient, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
self.assertEquals(status.signatures[0], "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==")
def test_fromraw_toraw(self):
status = Status.from_signed_raw(raw_status)
rendered_status = status.signed_raw()
from_rendered_status = Status.from_signed_raw(rendered_status)
assert from_rendered_status.status == 'UP'
assert from_rendered_status.blockid == "8-1922C324ABC4AF7EF7656734A31F5197888DDD52"
assert from_rendered_status.sender == "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY"
assert from_rendered_status.recipient == "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU"
assert from_rendered_status.signatures[0] == "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg=="
self.assertEquals(from_rendered_status.status, 'UP')
self.assertEquals(from_rendered_status.blockid, "8-1922C324ABC4AF7EF7656734A31F5197888DDD52")
self.assertEquals(from_rendered_status.sender, "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY")
self.assertEquals(from_rendered_status.recipient, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
self.assertEquals(from_rendered_status.signatures[0], "dkaXIiCYUJtCg8Feh/BKvPYf4uFH9CJ/zY6J4MlA9BsjmcMe4YAblvNt/gJy31b1aGq3ue3h14mLMCu84rraDg==")
......@@ -3,7 +3,7 @@ Created on 12 déc. 2014
@author: inso
'''
import pytest
import unittest
from ucoinpy.documents.transaction import Transaction
......@@ -32,105 +32,105 @@ Comment:
"""
class Test_Transaction:
class Test_Transaction(unittest.TestCase):
def test_fromcompact(self):
tx = Transaction.from_compact("zeta_brousouf", tx_compact)
assert tx.version == 1
assert tx.currency == "zeta_brousouf"
assert len(tx.issuers) == 1
assert len(tx.inputs) == 3
assert len(tx.outputs) == 1
self.assertEquals(tx.version, 1)
self.assertEquals(tx.currency, "zeta_brousouf")
self.assertEquals(len(tx.issuers), 1)
self.assertEquals(len(tx.inputs), 3)
self.assertEquals(len(tx.outputs), 1)
assert tx.issuers[0] == "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY"
self.assertEquals(tx.issuers[0], "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY")
assert tx.inputs[0].index == 0
assert tx.inputs[0].source == 'T'
assert tx.inputs[0].number == 65
assert tx.inputs[0].txhash == "D717FEC1993554F8EAE4CEA88DE5FBB6887CFAE8"
assert tx.inputs[0].amount == 4
self.assertEquals(tx.inputs[0].index, 0)
self.assertEquals(tx.inputs[0].source, 'T')
self.assertEquals(tx.inputs[0].number, 65)
self.assertEquals(tx.inputs[0].txhash, "D717FEC1993554F8EAE4CEA88DE5FBB6887CFAE8")
self.assertEquals(tx.inputs[0].amount, 4)
assert tx.inputs[1].index == 0
assert tx.inputs[1].source == 'T'
assert tx.inputs[1].number == 77
assert tx.inputs[1].txhash == "F80993776FB55154A60B3E58910C942A347964AD"
assert tx.inputs[1].amount == 15
self.assertEquals(tx.inputs[1].index, 0)
self.assertEquals(tx.inputs[1].source, 'T')
self.assertEquals(tx.inputs[1].number, 77)
self.assertEquals(tx.inputs[1].txhash, "F80993776FB55154A60B3E58910C942A347964AD")
self.assertEquals(tx.inputs[1].amount, 15)
assert tx.inputs[2].index == 0
assert tx.inputs[2].source == 'D'
assert tx.inputs[2].number == 88
assert tx.inputs[2].txhash == "F4A47E39BC2A20EE69DCD5CAB0A9EB3C92FD8F7B"
assert tx.inputs[2].amount == 11
self.assertEquals(tx.inputs[2].index, 0)
self.assertEquals(tx.inputs[2].source, 'D')
self.assertEquals(tx.inputs[2].number, 88)
self.assertEquals(tx.inputs[2].txhash, "F4A47E39BC2A20EE69DCD5CAB0A9EB3C92FD8F7B")
self.assertEquals(tx.inputs[2].amount, 11)
assert tx.outputs[0].pubkey == "BYfWYFrsyjpvpFysgu19rGK3VHBkz4MqmQbNyEuVU64g"
assert tx.outputs[0].amount == 30
self.assertEquals(tx.outputs[0].pubkey, "BYfWYFrsyjpvpFysgu19rGK3VHBkz4MqmQbNyEuVU64g")
self.assertEquals(tx.outputs[0].amount, 30)
assert tx.signatures[0] == "42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r"
self.assertEquals(tx.signatures[0], "42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r")
def test_fromraw(self):
tx = Transaction.from_signed_raw(tx_raw)
assert tx.version == 1
assert tx.currency == "beta_brousouf"
assert len(tx.issuers) == 1
assert len(tx.inputs) == 3
assert len(tx.outputs) == 1
self.assertEquals(tx.version, 1)
self.assertEquals(tx.currency, "beta_brousouf")
self.assertEquals(len(tx.issuers), 1)
self.assertEquals(len(tx.inputs), 3)
self.assertEquals(len(tx.outputs), 1)
assert tx.issuers[0] == "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY"
self.assertEquals(tx.issuers[0], "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY")
assert tx.inputs[0].index == 0
assert tx.inputs[0].source == 'T'
assert tx.inputs[0].number == 65
assert tx.inputs[0].txhash == "D717FEC1993554F8EAE4CEA88DE5FBB6887CFAE8"
assert tx.inputs[0].amount == 4
self.assertEquals(tx.inputs[0].index, 0)
self.assertEquals(tx.inputs[0].source, 'T')
self.assertEquals(tx.inputs[0].number, 65)
self.assertEquals(tx.inputs[0].txhash, "D717FEC1993554F8EAE4CEA88DE5FBB6887CFAE8")
self.assertEquals(tx.inputs[0].amount, 4)
assert tx.inputs[1].index == 0
assert tx.inputs[1].source == 'T'
assert tx.inputs[1].number == 77
assert tx.inputs[1].txhash == "F80993776FB55154A60B3E58910C942A347964AD"
assert tx.inputs[1].amount == 15
self.assertEquals(tx.inputs[1].index, 0)
self