| 
 | 1 | +import unittest  | 
 | 2 | +from _ucoinpy_test.api.webserver import WebFunctionalSetupMixin  | 
 | 3 | +from ucoinpy.api.bma.ws import Block, Peer  | 
 | 4 | + | 
 | 5 | + | 
 | 6 | +class Test_BMA_Websocket(WebFunctionalSetupMixin, unittest.TestCase):  | 
 | 7 | + | 
 | 8 | +    def test_block_014(self):  | 
 | 9 | +        json_sample = """  | 
 | 10 | +{  | 
 | 11 | +"documentType":"block",  | 
 | 12 | +"version":1,  | 
 | 13 | +"currency":"meta_brouzouf",  | 
 | 14 | +"nonce":567093,  | 
 | 15 | +"number":49191,  | 
 | 16 | +"parameters":"",  | 
 | 17 | +"previousHash":"0000084665ABA60118B6D302C9A9BA4BCCA94852",  | 
 | 18 | +"previousIssuer":"HBSSmqZjT4UQKsCntTSmZbu7iRP14HYtifLE6mW1PsBD",  | 
 | 19 | +"issuer":"HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk",  | 
 | 20 | +"identities":[],"joiners":[],"actives":[],"leavers":[],"excluded":[],  | 
 | 21 | +"membersCount":18,  | 
 | 22 | +"certifications":[],  | 
 | 23 | +"transactions":[],  | 
 | 24 | +"powMin":5,  | 
 | 25 | +"medianTime":1454058545,  | 
 | 26 | +"time":1454072945,  | 
 | 27 | +"signature":"Bk2lo/MAVgEwCr7pEopMs9DdN3TylwPH45MZg80h/V5IsuYwcVmPOstty6Z8XXqFCSfiCuYPUS7NhxGHOcnxDw==",  | 
 | 28 | +"hash":"0000011D7A92E746F9B2D5B7035B98867F4A95A2",  | 
 | 29 | +"fork":false,  | 
 | 30 | +"monetaryMass":15431388469457603000,  | 
 | 31 | +"dividend":0,  | 
 | 32 | +"UDTime":1453979780,  | 
 | 33 | +"wrong":false  | 
 | 34 | +}  | 
 | 35 | +"""  | 
 | 36 | +        block = Block(None)  | 
 | 37 | +        block.parse_text(json_sample)  | 
 | 38 | + | 
 | 39 | +    def test_peer(self):  | 
 | 40 | +        json_sample = """{  | 
 | 41 | +  "version": "1",  | 
 | 42 | +  "currency": "beta_brouzouf",  | 
 | 43 | +  "pubkey": "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY",  | 
 | 44 | +  "endpoints": [  | 
 | 45 | +    "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9001",  | 
 | 46 | +    "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9002",  | 
 | 47 | +    "OTHER_PROTOCOL 88.77.66.55 9001"  | 
 | 48 | +    ],  | 
 | 49 | +  "signature": "42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r"  | 
 | 50 | +}  | 
 | 51 | +"""  | 
 | 52 | +        peer = Peer(None)  | 
 | 53 | +        data = peer.parse_text(json_sample)  | 
 | 54 | +        self.assertEqual(data["version"], "1")  | 
 | 55 | +        self.assertEqual(data["currency"], "beta_brouzouf")  | 
 | 56 | +        self.assertEqual(data["pubkey"], "HsLShAtzXTVxeUtQd7yi5Z5Zh4zNvbu8sTEZ53nfKcqY")  | 
 | 57 | +        self.assertEqual(len(data["endpoints"]), 3)  | 
 | 58 | +        self.assertEqual(data["signature"], "42yQm4hGTJYWkPg39hQAUgP6S6EQ4vTfXdJuxKEHL1ih6YHiDL2hcwrFgBHjXLRgxRhj2VNVqqc6b4JayKqTE14r")  | 
0 commit comments