Switched from lists to tuples for const data type

Closes #2
This commit is contained in:
Piotr Lizonczyk
2017-10-08 00:54:54 +02:00
parent d4c4d2e1bd
commit 7e51c3a6f7
2 changed files with 6 additions and 6 deletions

View File

@@ -60,7 +60,7 @@ class Pattern(object):
def get_required_keypairs(self, initiator: bool) -> list:
required = []
if initiator:
if self.name[0] in ['K', 'X', 'I']:
if self.name[0] in ('K', 'X', 'I'):
required.append('s')
if self.one_way or self.name[1] == 'K':
required.append('rs')

View File

@@ -15,10 +15,10 @@ vector_files = [
# As in test vectors specification (https://github.com/noiseprotocol/noise_wiki/wiki/Test-vectors)
# We use this to cast read strings into bytes
byte_fields = ['protocol_name']
hexbyte_fields = ['init_prologue', 'init_static', 'init_ephemeral', 'init_remote_static', 'resp_static',
'resp_prologue', 'resp_ephemeral', 'resp_remote_static', 'handshake_hash']
list_fields = ['init_psks', 'resp_psks']
byte_field = 'protocol_name'
hexbyte_fields = ('init_prologue', 'init_static', 'init_ephemeral', 'init_remote_static', 'resp_static',
'resp_prologue', 'resp_ephemeral', 'resp_remote_static', 'handshake_hash')
list_fields = ('init_psks', 'resp_psks')
dict_field = 'messages'
@@ -31,7 +31,7 @@ def _prepare_test_vectors():
for vector in vectors_list:
for key, value in vector.copy().items():
if key in byte_fields:
if key == byte_field:
vector[key] = value.encode()
if key in hexbyte_fields:
vector[key] = bytes.fromhex(value)