Refactoring crypto base changes #1806
|
@ -24,3 +24,8 @@ sample_point = (
|
||||||
33567437183004486938355437500683826356288335339807546987348409590129959362313,
|
33567437183004486938355437500683826356288335339807546987348409590129959362313,
|
||||||
94730058721143827257669456336351159718085716196507891067256111928318063085006
|
94730058721143827257669456336351159718085716196507891067256111928318063085006
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sample_seed = 'TIGER, tiger, burning bright. In the forests of the night'
|
||||||
|
# Deterministic addresses with stream 1 and versions 3, 4
|
||||||
|
sample_deterministic_addr3 = 'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
||||||
|
sample_deterministic_addr4 = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
|
||||||
|
|
|
@ -10,6 +10,9 @@ from six.moves import xmlrpc_client # nosec
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
|
from .samples import (
|
||||||
|
sample_seed, sample_deterministic_addr3, sample_deterministic_addr4)
|
||||||
|
|
||||||
from .test_process import TestProcessProto
|
from .test_process import TestProcessProto
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,9 +61,7 @@ class TestAPIShutdown(TestAPIProto):
|
||||||
|
|
||||||
class TestAPI(TestAPIProto):
|
class TestAPI(TestAPIProto):
|
||||||
"""Main API test case"""
|
"""Main API test case"""
|
||||||
_seed = base64.encodestring(
|
_seed = base64.encodestring(sample_seed)
|
||||||
'TIGER, tiger, burning bright. In the forests of the night'
|
|
||||||
)
|
|
||||||
|
|
||||||
def _add_random_address(self, label):
|
def _add_random_address(self, label):
|
||||||
return self.api.createRandomAddress(base64.encodestring(label))
|
return self.api.createRandomAddress(base64.encodestring(label))
|
||||||
|
@ -108,7 +109,7 @@ class TestAPI(TestAPIProto):
|
||||||
def test_decode_address(self):
|
def test_decode_address(self):
|
||||||
"""Checking the return of API command 'decodeAddress'"""
|
"""Checking the return of API command 'decodeAddress'"""
|
||||||
result = json.loads(
|
result = json.loads(
|
||||||
self.api.decodeAddress('BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'))
|
self.api.decodeAddress(sample_deterministic_addr4))
|
||||||
self.assertEqual(result.get('status'), 'success')
|
self.assertEqual(result.get('status'), 'success')
|
||||||
self.assertEqual(result['addressVersion'], 4)
|
self.assertEqual(result['addressVersion'], 4)
|
||||||
self.assertEqual(result['streamNumber'], 1)
|
self.assertEqual(result['streamNumber'], 1)
|
||||||
|
@ -117,10 +118,10 @@ class TestAPI(TestAPIProto):
|
||||||
"""Test creation of deterministic addresses"""
|
"""Test creation of deterministic addresses"""
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.api.getDeterministicAddress(self._seed, 4, 1),
|
self.api.getDeterministicAddress(self._seed, 4, 1),
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK')
|
sample_deterministic_addr4)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.api.getDeterministicAddress(self._seed, 3, 1),
|
self.api.getDeterministicAddress(self._seed, 3, 1),
|
||||||
'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN')
|
sample_deterministic_addr3)
|
||||||
self.assertRegexpMatches(
|
self.assertRegexpMatches(
|
||||||
self.api.getDeterministicAddress(self._seed, 2, 1),
|
self.api.getDeterministicAddress(self._seed, 2, 1),
|
||||||
r'^API Error 0002:')
|
r'^API Error 0002:')
|
||||||
|
@ -150,7 +151,7 @@ class TestAPI(TestAPIProto):
|
||||||
self.api.createDeterministicAddresses(self._seed, 2, 4)
|
self.api.createDeterministicAddresses(self._seed, 2, 4)
|
||||||
)['addresses']
|
)['addresses']
|
||||||
self.assertEqual(len(addresses), 2)
|
self.assertEqual(len(addresses), 2)
|
||||||
self.assertEqual(addresses[0], 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK')
|
self.assertEqual(addresses[0], sample_deterministic_addr4)
|
||||||
for addr in addresses:
|
for addr in addresses:
|
||||||
self.assertEqual(self.api.deleteAddress(addr), 'success')
|
self.assertEqual(self.api.deleteAddress(addr), 'success')
|
||||||
|
|
||||||
|
@ -172,19 +173,18 @@ class TestAPI(TestAPIProto):
|
||||||
)
|
)
|
||||||
# Add known address
|
# Add known address
|
||||||
self.api.addAddressBookEntry(
|
self.api.addAddressBookEntry(
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK',
|
sample_deterministic_addr4,
|
||||||
base64.encodestring('tiger_4')
|
base64.encodestring('tiger_4')
|
||||||
)
|
)
|
||||||
# Check addressbook entry
|
# Check addressbook entry
|
||||||
entries = json.loads(
|
entries = json.loads(
|
||||||
self.api.listAddressBookEntries()).get('addresses')[0]
|
self.api.listAddressBookEntries()).get('addresses')[0]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
entries['address'], 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK')
|
entries['address'], sample_deterministic_addr4)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
base64.decodestring(entries['label']), 'tiger_4')
|
base64.decodestring(entries['label']), 'tiger_4')
|
||||||
# Remove known address
|
# Remove known address
|
||||||
self.api.deleteAddressBookEntry(
|
self.api.deleteAddressBookEntry(sample_deterministic_addr4)
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK')
|
|
||||||
# Addressbook should be empty again
|
# Addressbook should be empty again
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
json.loads(self.api.listAddressBookEntries()).get('addresses'),
|
json.loads(self.api.listAddressBookEntries()).get('addresses'),
|
||||||
|
@ -218,7 +218,7 @@ class TestAPI(TestAPIProto):
|
||||||
msg = base64.encodestring('test message')
|
msg = base64.encodestring('test message')
|
||||||
msg_subject = base64.encodestring('test_subject')
|
msg_subject = base64.encodestring('test_subject')
|
||||||
ackdata = self.api.sendMessage(
|
ackdata = self.api.sendMessage(
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK', addr, msg_subject, msg)
|
sample_deterministic_addr4, addr, msg_subject, msg)
|
||||||
try:
|
try:
|
||||||
# Check ackdata and message status
|
# Check ackdata and message status
|
||||||
int(ackdata, 16)
|
int(ackdata, 16)
|
||||||
|
@ -332,19 +332,12 @@ class TestAPI(TestAPIProto):
|
||||||
"""Testing chan creation/joining"""
|
"""Testing chan creation/joining"""
|
||||||
# Create chan with known address
|
# Create chan with known address
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.api.createChan(self._seed),
|
self.api.createChan(self._seed), sample_deterministic_addr4)
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
|
|
||||||
)
|
|
||||||
# cleanup
|
# cleanup
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.api.leaveChan('BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'),
|
self.api.leaveChan(sample_deterministic_addr4), 'success')
|
||||||
'success'
|
|
||||||
)
|
|
||||||
# Join chan with addresses of version 3 or 4
|
# Join chan with addresses of version 3 or 4
|
||||||
for addr in (
|
for addr in (sample_deterministic_addr4, sample_deterministic_addr3):
|
||||||
'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK',
|
|
||||||
'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
|
||||||
):
|
|
||||||
self.assertEqual(self.api.joinChan(self._seed, addr), 'success')
|
self.assertEqual(self.api.joinChan(self._seed, addr), 'success')
|
||||||
self.assertEqual(self.api.leaveChan(addr), 'success')
|
self.assertEqual(self.api.leaveChan(addr), 'success')
|
||||||
# Joining with wrong address should fail
|
# Joining with wrong address should fail
|
||||||
|
|
Reference in New Issue
Block a user