diff --git a/crypto/identity/private_key.py b/crypto/identity/private_key.py index 6ff93a8f..647c269b 100644 --- a/crypto/identity/private_key.py +++ b/crypto/identity/private_key.py @@ -1,9 +1,15 @@ from binascii import hexlify from hashlib import sha256 from coincurve import PrivateKey as PvtKey +from Cryptodome.Hash import keccak from crypto.enums.constants import Constants +def keccak256(data: bytes) -> bytes: + """Keccak256 hash function""" + + return bytes.fromhex(keccak.new(data=data, digest_bits=256).hexdigest()) + class PrivateKey(object): def __init__(self, private_key: str): self.private_key = PvtKey.from_hex(private_key) @@ -31,7 +37,7 @@ def sign_compact(self, message: bytes) -> bytes: Returns: bytes: signature of the signed message """ - der = self.private_key.sign_recoverable(message) + der = self.private_key.sign_recoverable(message, hasher=keccak256) return bytes([der[64] + Constants.ETHEREUM_RECOVERY_ID_OFFSET.value]) + der[0:64] diff --git a/crypto/transactions/builder/evm_call_builder.py b/crypto/transactions/builder/evm_call_builder.py index 4a541dd7..7b30095d 100644 --- a/crypto/transactions/builder/evm_call_builder.py +++ b/crypto/transactions/builder/evm_call_builder.py @@ -1,11 +1,14 @@ from crypto.transactions.builder.base import AbstractTransactionBuilder from crypto.transactions.types.evm_call import EvmCall +from crypto.utils.transaction_utils import TransactionUtils class EvmCallBuilder(AbstractTransactionBuilder): def payload(self, payload: str): - payload = payload.lstrip('0x') # Remove '0x' prefix if present + payload = TransactionUtils.parse_hex_from_str(payload) # Remove '0x' prefix if present + self.transaction.data['data'] = payload + return self def get_transaction_instance(self, data: dict): - return EvmCall(data) \ No newline at end of file + return EvmCall(data) diff --git a/crypto/transactions/deserializer.py b/crypto/transactions/deserializer.py index ab21002b..125292ab 100644 --- a/crypto/transactions/deserializer.py +++ b/crypto/transactions/deserializer.py @@ -1,10 +1,12 @@ -import re from binascii import unhexlify from typing import Optional from crypto.enums.constants import Constants +from crypto.enums.contract_abi_type import ContractAbiType from crypto.transactions.types.abstract_transaction import AbstractTransaction from crypto.transactions.types.transfer import Transfer from crypto.transactions.types.evm_call import EvmCall +from crypto.transactions.types.username_registration import UsernameRegistration +from crypto.transactions.types.username_resignation import UsernameResignation from crypto.transactions.types.vote import Vote from crypto.transactions.types.unvote import Unvote from crypto.transactions.types.validator_registration import ValidatorRegistration @@ -13,6 +15,7 @@ from crypto.enums.abi_function import AbiFunction from crypto.utils.abi_decoder import AbiDecoder from crypto.utils.rlp_decoder import RlpDecoder +from crypto.utils.transaction_utils import TransactionUtils class Deserializer: SIGNATURE_SIZE = 64 @@ -59,30 +62,40 @@ def guess_transaction_from_data(self, data: dict) -> AbstractTransaction: if data['value'] != '0': return Transfer(data) - payload_data = self.decode_payload(data) + consensus_payload_data = self.decode_payload(data) + if consensus_payload_data is not None: + function_name = consensus_payload_data.get('functionName') + if function_name == AbiFunction.VOTE.value: + return Vote(data) - if payload_data is None: - return EvmCall(data) + if function_name == AbiFunction.UNVOTE.value: + return Unvote(data) - function_name = payload_data.get('functionName') - if function_name == AbiFunction.VOTE.value: - return Vote(data) - elif function_name == AbiFunction.UNVOTE.value: - return Unvote(data) - elif function_name == AbiFunction.VALIDATOR_REGISTRATION.value: - return ValidatorRegistration(data) - elif function_name == AbiFunction.VALIDATOR_RESIGNATION.value: - return ValidatorResignation(data) - else: - return EvmCall(data) + if function_name == AbiFunction.VALIDATOR_REGISTRATION.value: + return ValidatorRegistration(data) - def decode_payload(self, data: dict) -> Optional[dict]: + if function_name == AbiFunction.VALIDATOR_RESIGNATION.value: + return ValidatorResignation(data) + + username_payload_data = self.decode_payload(data, ContractAbiType.USERNAMES) + if username_payload_data is not None: + function_name = username_payload_data.get('functionName') + if function_name == AbiFunction.USERNAME_REGISTRATION.value: + return UsernameRegistration(data) + + if function_name == AbiFunction.USERNAME_RESIGNATION.value: + return UsernameResignation(data) + + return EvmCall(data) + + @staticmethod + def decode_payload(data: dict, abi_type: ContractAbiType = ContractAbiType.CONSENSUS) -> Optional[dict]: payload = data.get('data', '') if payload == '': return None - decoder = AbiDecoder() + decoder = AbiDecoder(abi_type) try: return decoder.decode_function_data(payload) except Exception as e: @@ -100,7 +113,7 @@ def parse_big_number(value: str) -> str: @staticmethod def parse_hex(value: str) -> str: - return re.sub(r'^0x', '', value) + return TransactionUtils.parse_hex_from_str(value) @staticmethod def parse_address(value: str) -> Optional[str]: diff --git a/crypto/transactions/transaction.py b/crypto/transactions/transaction.py deleted file mode 100644 index 306d06d5..00000000 --- a/crypto/transactions/transaction.py +++ /dev/null @@ -1,234 +0,0 @@ -import json -from hashlib import sha256 -from typing import Optional - -from binary.hex.writer import write_high -from binary.unsigned_integer.writer import write_bit8 - -from crypto.constants import TRANSACTION_VALIDATOR_REGISTRATION, TRANSACTION_MULTI_SIGNATURE_REGISTRATION, TRANSACTION_VOTE -from crypto.exceptions import ArkInvalidTransaction -from crypto.transactions.serializer import Serializer -from crypto.transactions.signature import Signature - -TRANSACTION_ATTRIBUTES = { - 'amount': 0, - 'asset': dict, - 'fee': None, - 'id': None, - 'network': None, - 'recipientId': None, - 'secondSignature': None, - 'senderPublicKey': None, - 'signature': None, - 'signatures': None, - 'signSignature': None, - 'nonce': None, - 'type': None, - 'typeGroup': None, - 'vendorField': None, - 'vendorFieldHex': None, - 'version': None, - 'lockTransactionId': None, - 'lockSecret': None, - 'expiration': None -} - -class Transaction(object): - id: str - type: int - fee: int - nonce: int - typeGroup: int - signatures: list - version: int - expiration: int - type: int - amount: int - recipientId: str - senderPublicKey: str - asset: dict - vendorField: Optional[bytes] - vendorFieldHex: bytes - network: int - - def __init__(self, **kwargs): - for attribute, attribute_value in TRANSACTION_ATTRIBUTES.items(): - if callable(attribute_value): - attribute_value = attribute_value() - if attribute in kwargs: - attribute_value = kwargs[attribute] - setattr(self, attribute, attribute_value) - - def get_id(self): - """Convert the byte representation to a unique identifier - - Returns: - str: - """ - return sha256(self.to_bytes(skip_signature=False, skip_second_signature=False, skip_multi_signature=False)).hexdigest() - - def to_dict(self): - """Convert the transaction into a dictionary representation - - Returns: - dict: only includes values that are set - """ - data = {} - for key in TRANSACTION_ATTRIBUTES.keys(): - attribute = getattr(self, key, None) - if attribute is None: - continue - # todo: get rid of the bytes check and handle this outside of the to_dict function - data[key] = attribute.decode() if isinstance(attribute, bytes) else attribute - return data - - def to_json(self): - data = self.to_dict() - return json.dumps(data) - - def to_bytes(self, skip_signature=True, skip_second_signature=True, skip_multi_signature=True) -> bytes: - """Convert the transaction to its byte representation - - Args: - skip_signature (bool, optional): do you want to skip the signature - skip_second_signature (bool, optional): do you want to skip the 2nd signature - skip_multi_signature (bool, optional): do you want to skip multi signature - - Returns: - bytes: bytes representation of the transaction - """ - return Serializer(self.to_dict()).serialize_bytes(skip_signature=skip_signature, - skip_second_signature=skip_second_signature, - skip_multi_signature=skip_multi_signature) - - def parse_signatures(self, serialized: str, start_offset: int): - """Parse the signature, second signature and multi signatures - - Args: - serialized (str): parses a given serialized string - start_offset (int): - """ - - signature_end_offset = start_offset + (64 * 2) - - if len(serialized) - signature_end_offset % 65 != 0: - self.signature = serialized[start_offset:signature_end_offset] - - second_signature_end_offset = signature_end_offset + (64 * 2) - if len(serialized) - signature_end_offset > 0 and (len(serialized) - signature_end_offset) % 64 == 0: - self.signSignature = serialized[signature_end_offset:second_signature_end_offset] - - if len(serialized) - second_signature_end_offset > 0 and (len(serialized) - signature_end_offset) % 65 == 0: - multi_sig_part = serialized[signature_end_offset:] - index = 0 - index_size = 2 - signature_size = 128 - - while index != len(multi_sig_part): - signature_index = multi_sig_part[index:index + index_size] - signature = multi_sig_part[index + index_size:index + index_size + signature_size] - index += index_size + signature_size - signature_formatted = signature_index + signature - self.signatures.append(signature_formatted) - - def serialize(self, skip_signature=True, skip_second_signature=True, skip_multi_signature=True) -> str: - """Perform AIP11 compliant serialization. - - Args: - skip_signature (bool, optional): do you want to skip the signature - skip_second_signature (bool, optional): do you want to skip the 2nd signature - skip_multi_signature (bool, optional): do you want to skip multi signature - - Returns: - str: Serialized string - """ - data = self.to_dict() - - return Serializer(data).serialize(skip_signature, skip_second_signature, skip_multi_signature) - - @staticmethod - def deserialize(serialized: bytes): - """Perform AIP11 compliant deserialization. - - Args: - serialized (bytes): parses a given serialized string - - Returns: - crypto.transactions.transaction.Transaction: Transaction - """ - from crypto.transactions.deserializer import Deserializer - - return Deserializer(serialized).deserialize() - - def verify_schnorr(self): - """Verify the transaction. Method will raise an exception if invalid, if it's valid it will - returns True - """ - is_valid = Signature.verify(self.signature, self.to_bytes(), self.senderPublicKey) - - if not is_valid: - raise ArkInvalidTransaction('Transaction could not be verified') - - return is_valid - - def verify_secondsig_schnorr(self, secondPublicKey: bytes): - """Verify the transaction. Method will raise an exception if invalid, if it's valid it will - returns True - """ - is_valid = Signature.verify(self.signSignature, self.to_bytes(False, True), secondPublicKey) - - if not is_valid: - raise ArkInvalidTransaction('Transaction could not be verified') - - return is_valid - - def verify_multisig_schnorr(self): - """Verify the multisignatures transaction. Method will raise an exception if invalid, it will - returns True - """ - is_valid = Signature.verify(self.signature, self.to_bytes(True, True, False), self.senderPublicKey) - - if not is_valid: - raise ArkInvalidTransaction('Transaction could not be verified') - - return is_valid - - def _handle_transaction_type(self, bytes_data) -> bytes: - """Handled each transaction type differently - - Args: - bytes_data (bytes): input the bytes data to which you want to append new bytes - - Raises: - NotImplementedError: raised only if the child transaction doesn't implement this - required method - """ - if self.type == TRANSACTION_VALIDATOR_REGISTRATION: - bytes_data += self.asset['validator']['username'].encode() - elif self.type == TRANSACTION_VOTE: - bytes_data += ''.join(self.asset['votes']).encode() - elif self.type == TRANSACTION_MULTI_SIGNATURE_REGISTRATION: - bytes_data += write_bit8(self.asset['multiSignature']['min']) - bytes_data += ''.join(self.asset['multiSignature']['publicKeys']).encode() - - return bytes_data - - def _handle_signature(self, bytes_data, skip_signature, skip_second_signature, skip_multi_signature) -> bytes: - """Internal method, used to handle the signature - - Args: - bytes_data (bytes): input the bytes data to which you want to append new bytes from - signature - skip_signature (bool): whether you want to skip it or not - skip_second_signature (bool): whether you want to skip it or not - - Returns: - bytes: bytes string - """ - if not skip_signature and self.signature: - bytes_data += write_high(self.signature) - if not skip_second_signature and self.signSignature: - bytes_data += write_high(self.signSignature) - if not skip_multi_signature and self.signatures: - bytes_data += write_high(self.signatures) - return bytes_data diff --git a/crypto/transactions/types/abstract_transaction.py b/crypto/transactions/types/abstract_transaction.py index d66ed034..c400cac5 100644 --- a/crypto/transactions/types/abstract_transaction.py +++ b/crypto/transactions/types/abstract_transaction.py @@ -3,6 +3,7 @@ from crypto.configuration.network import get_network from crypto.enums.constants import Constants +from crypto.enums.contract_abi_type import ContractAbiType from crypto.identity.address import address_from_public_key from crypto.identity.private_key import PrivateKey from crypto.utils.transaction_utils import TransactionUtils @@ -17,19 +18,8 @@ def __init__(self, data: Optional[dict] = None): def get_payload(self) -> str: return '' - def decode_payload(self, data: dict) -> Optional[dict]: - if 'data' not in data or data['data'] == '': - return None - - payload = data['data'] - decoder = AbiDecoder() - - decoded_data = decoder.decode_function_data(payload) - - return decoded_data - def refresh_payload_data(self): - self.data['data'] = self.get_payload().lstrip('0x') + self.data['data'] = TransactionUtils.parse_hex_from_str(self.get_payload()) def get_id(self) -> str: return TransactionUtils.get_id(self.data) @@ -105,3 +95,9 @@ def get_signature(self): return bytes.fromhex(r) + bytes.fromhex(s) + bytes([recover_id]) return None + + @staticmethod + def decode_payload(data: dict, abi_type: ContractAbiType = ContractAbiType.CONSENSUS) -> Optional[dict]: + from crypto.transactions.deserializer import Deserializer + + return Deserializer.decode_payload(data, abi_type) diff --git a/crypto/transactions/types/username_registration.py b/crypto/transactions/types/username_registration.py index 100333a8..12fb21a0 100644 --- a/crypto/transactions/types/username_registration.py +++ b/crypto/transactions/types/username_registration.py @@ -1,12 +1,13 @@ +from typing import Optional from crypto.enums.contract_abi_type import ContractAbiType from crypto.transactions.types.abstract_transaction import AbstractTransaction from crypto.utils.abi_encoder import AbiEncoder from crypto.enums.abi_function import AbiFunction class UsernameRegistration(AbstractTransaction): - def __init__(self, data: dict = None): + def __init__(self, data: Optional[dict] = None): data = data or {} - payload = self.decode_payload(data) + payload = self.decode_payload(data, ContractAbiType.USERNAMES) if payload: data['username'] = payload.get('args', [None])[0] if payload.get('args') else None diff --git a/crypto/transactions/types/validator_registration.py b/crypto/transactions/types/validator_registration.py index a8b8bf80..ecaf86ee 100644 --- a/crypto/transactions/types/validator_registration.py +++ b/crypto/transactions/types/validator_registration.py @@ -1,17 +1,19 @@ +from typing import Optional from crypto.transactions.types.abstract_transaction import AbstractTransaction from crypto.utils.abi_encoder import AbiEncoder from crypto.enums.abi_function import AbiFunction +from crypto.utils.transaction_utils import TransactionUtils class ValidatorRegistration(AbstractTransaction): - def __init__(self, data: dict = None): + def __init__(self, data: Optional[dict] = None): data = data or {} payload = self.decode_payload(data) if payload: - data['validatorPublicKey'] = payload.get('args', [None])[0].lstrip('0x') if payload.get('args') else None + data['validatorPublicKey'] = TransactionUtils.parse_hex_from_str(payload.get('args', [None])[0]) if payload.get('args') else None super().__init__(data) def get_payload(self) -> str: if 'validatorPublicKey' not in self.data: return '' encoder = AbiEncoder() - return encoder.encode_function_call(AbiFunction.VALIDATOR_REGISTRATION.value, ['0x' + self.data['validatorPublicKey']]) \ No newline at end of file + return encoder.encode_function_call(AbiFunction.VALIDATOR_REGISTRATION.value, ['0x' + self.data['validatorPublicKey']]) diff --git a/crypto/transactions/types/vote.py b/crypto/transactions/types/vote.py index 93e8428a..27124ef0 100644 --- a/crypto/transactions/types/vote.py +++ b/crypto/transactions/types/vote.py @@ -1,9 +1,10 @@ +from typing import Optional from crypto.transactions.types.abstract_transaction import AbstractTransaction from crypto.utils.abi_encoder import AbiEncoder from crypto.enums.abi_function import AbiFunction class Vote(AbstractTransaction): - def __init__(self, data: dict = None): + def __init__(self, data: Optional[dict] = None): data = data or {} payload = self.decode_payload(data) if payload: @@ -15,4 +16,4 @@ def get_payload(self) -> str: if 'vote' not in self.data: return '' encoder = AbiEncoder() - return encoder.encode_function_call(AbiFunction.VOTE.value, [self.data['vote']]) \ No newline at end of file + return encoder.encode_function_call(AbiFunction.VOTE.value, [self.data['vote']]) diff --git a/crypto/utils/transaction_utils.py b/crypto/utils/transaction_utils.py index 3cfbda5b..de663935 100644 --- a/crypto/utils/transaction_utils.py +++ b/crypto/utils/transaction_utils.py @@ -1,6 +1,8 @@ from binascii import unhexlify import hashlib +import re +from Cryptodome.Hash import keccak from crypto.enums.constants import Constants from crypto.utils.rlp_encoder import RlpEncoder @@ -8,7 +10,7 @@ class TransactionUtils: @classmethod def to_buffer(cls, transaction: dict, skip_signature: bool = False) -> bytes: # Process recipientAddress - hex_address = transaction.get('recipientAddress', '').lstrip('0x') + hex_address = cls.parse_hex_from_str(transaction.get('recipientAddress', '')) # Pad with leading zero if necessary if len(hex_address) % 2 != 0: @@ -25,7 +27,7 @@ def to_buffer(cls, transaction: dict, skip_signature: bool = False) -> bytes: cls.to_be_array(int(transaction['gasLimit'])), recipient_address, cls.to_be_array(int(transaction.get('value', 0))), - bytes.fromhex(transaction.get('data', '').lstrip('0x')) if transaction.get('data') else b'', + bytes.fromhex(cls.parse_hex_from_str(transaction.get('data', ''))) if transaction.get('data') else b'', [], ] @@ -42,7 +44,7 @@ def to_buffer(cls, transaction: dict, skip_signature: bool = False) -> bytes: @classmethod def to_hash(cls, transaction: dict, skip_signature: bool = False) -> str: - return hashlib.sha256(unhexlify(cls.to_buffer(transaction, skip_signature))).hexdigest() + return keccak.new(data=unhexlify(cls.to_buffer(transaction, skip_signature)), digest_bits=256).hexdigest() @classmethod def get_id(cls, transaction: dict) -> str: @@ -60,3 +62,7 @@ def to_be_array(value): return value raise TypeError("Unsupported type for to_be_array") + + @staticmethod + def parse_hex_from_str(value: str) -> str: + return re.sub(r'^0x', '', value) diff --git a/tests/conftest.py b/tests/conftest.py index db71646b..6e3ae9f5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -36,7 +36,7 @@ def _load_transaction_fixture(fixture_name): def passphrase(): """Passphrase used for tests""" - return 'my super secret passphrase' + return 'found lobster oblige describe ready addict body brave live vacuum display salute lizard combine gift resemble race senior quality reunion proud tell adjust angle' @pytest.fixture def transaction_type_0(): diff --git a/tests/fixtures/evm-sign.json b/tests/fixtures/evm-sign.json index a171db39..65ae60a0 100644 --- a/tests/fixtures/evm-sign.json +++ b/tests/fixtures/evm-sign.json @@ -1,18 +1,18 @@ { - "data": { - "network": 30, - "nonce": "1", - "gasPrice": 5, - "gasLimit": 1000000, - "value": "0", - "recipientAddress": "0xe536720791a7dadbebdbcd8c8546fb0791a11901", - "data": "a9059cbb00000000000000000000000027fa7caffaae77ddb9ab232fdbda56d5e5af23930000000000000000000000000000000000000000000000000000000000000064", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "id": "2cfa9d51e71f014f8054881052e41dc61267587f9dba04c59a31cc881f8ce35b", - "v": 27, - "r": "a56cf78a7203927af0c8216fdbc804182a0788569e460067efec519b6f7b2e55", - "s": "52ce951a20c7406a4a34707557f02e5a2af1451cc4e216645778c4ee0391a4cd" - }, - "serialized": "02f8a81e018005830f424094e536720791a7dadbebdbcd8c8546fb0791a1190180b844a9059cbb00000000000000000000000027fa7caffaae77ddb9ab232fdbda56d5e5af23930000000000000000000000000000000000000000000000000000000000000064c080a0a56cf78a7203927af0c8216fdbc804182a0788569e460067efec519b6f7b2e55a052ce951a20c7406a4a34707557f02e5a2af1451cc4e216645778c4ee0391a4cd" + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0xE536720791A7DaDBeBdBCD8c8546fb0791a11901", + "value": "0", + "data": "a9059cbb00000000000000000000000027fa7caffaae77ddb9ab232fdbda56d5e5af23930000000000000000000000000000000000000000000000000000000000000064", + "v": 28, + "r": "8cd7afafdfaaa6c4b6c97e49888dff89713c99f8b1324693ef4427ce88994bbe", + "s": "01c589bb8d3bc908aaee56d64ca35458f2cebf977bbc29180c574aba8bc12b0d", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "85cdc2ae6cd4569dd1b5b11df10fc409b3996864032d6acf87ff907286f40a03" + }, + "serialized": "02f8af822710018085012a05f20083030d4094e536720791a7dadbebdbcd8c8546fb0791a1190180b844a9059cbb00000000000000000000000027fa7caffaae77ddb9ab232fdbda56d5e5af23930000000000000000000000000000000000000000000000000000000000000064c001a08cd7afafdfaaa6c4b6c97e49888dff89713c99f8b1324693ef4427ce88994bbea001c589bb8d3bc908aaee56d64ca35458f2cebf977bbc29180c574aba8bc12b0d" } diff --git a/tests/fixtures/multipayment-empty.json b/tests/fixtures/multipayment-empty.json index 7a235183..a0dd6bd6 100644 --- a/tests/fixtures/multipayment-empty.json +++ b/tests/fixtures/multipayment-empty.json @@ -1,18 +1,18 @@ { - "data": { - "network": 30, - "nonce": "1", - "gasPrice": 5, - "gasLimit": 1000000, - "value": "0", - "recipientAddress": "0x83769BeEB7e5405ef0B7dc3C66C43E3a51A6d27f", - "data": "084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "id": "d816a0f8b51eb618c4497aeddcc9d4596f94fefc39de306282f50596c9e1c071", - "v": 28, - "r": "bfab2a6634cfbf8bc802d0259dea575b7618131e8de9e29ca7df1950e68ce8eb", - "s": "5e7eeb4c2f973a8397f38b68520123798b07b4f1bf251bbaaacafb36e8e05a55" - }, - "serialized": "02f8e81e018005830f42409483769beeb7e5405ef0b7dc3c66c43e3a51a6d27f80b884084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c001a0bfab2a6634cfbf8bc802d0259dea575b7618131e8de9e29ca7df1950e68ce8eba05e7eeb4c2f973a8397f38b68520123798b07b4f1bf251bbaaacafb36e8e05a55" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x00EFd0D4639191C49908A7BddbB9A11A994A8527", + "value": "0", + "data": "084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "v": 27, + "r": "cbec73e1cba1177789adf44fcd3cea797d132563635fae211c350acd7c328046", + "s": "216eabb6cd1eb5c0000e7eb74f66595bd5b688f43dd646f15f33e3827c8c966b", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "555fcaca65f9319c638ebb15c5ffdee0a5e41b7dc3b171aca3707bc43f40ed57" + }, + "serialized": "02f8ef822710018085012a05f20083030d409400efd0d4639191c49908a7bddbb9a11a994a852780b884084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c080a0cbec73e1cba1177789adf44fcd3cea797d132563635fae211c350acd7c328046a0216eabb6cd1eb5c0000e7eb74f66595bd5b688f43dd646f15f33e3827c8c966b" +} \ No newline at end of file diff --git a/tests/fixtures/multipayment-single.json b/tests/fixtures/multipayment-single.json index b2e6098b..65e4df03 100644 --- a/tests/fixtures/multipayment-single.json +++ b/tests/fixtures/multipayment-single.json @@ -1,18 +1,18 @@ { - "data": { - "network": 30, - "nonce": "1", - "gasPrice": 5, - "gasLimit": 1000000, - "value": "100000000", - "recipientAddress": "0x83769BeEB7e5405ef0B7dc3C66C43E3a51A6d27f", - "data": "084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008233f6df6449d7655f4643d2e752dc8d2283fad500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000005f5e100", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "id": "d3775117889fce2397bded88564427dda03c31f2b85a839567f98ae776e3ff4c", - "v": 28, - "r": "c00a8f6a658c1dda434bceb708c74d62d086ec143939c2373010284221d25995", - "s": "43f6e7e5988f37c4336638c1b6a0cf4aa6caeefd5bda6937aa03464bdf44536c" - }, - "serialized": "02f9012c1e018005830f42409483769beeb7e5405ef0b7dc3c66c43e3a51a6d27f8405f5e100b8c4084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008233f6df6449d7655f4643d2e752dc8d2283fad500000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000005f5e100c001a0c00a8f6a658c1dda434bceb708c74d62d086ec143939c2373010284221d25995a043f6e7e5988f37c4336638c1b6a0cf4aa6caeefd5bda6937aa03464bdf44536c" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x00EFd0D4639191C49908A7BddbB9A11A994A8527", + "value": "100000", + "data": "084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006f0182a0cc707b055322ccf6d4cb6a5aff1aeb22000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000186a0", + "v": 28, + "r": "e381eb89f21e450009706650346e3abfaee0c91c5685c8ec923d86b8212a2427", + "s": "5b3a7bfdec8ca69469e989805e7715f5d317bf62304f868a905224e7dabe7b37", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "1d0e3d567ffa39defba7904202941070b224f885f9399c817a58aeb36f4f3863" + }, + "serialized": "02f90132822710018085012a05f20083030d409400efd0d4639191c49908a7bddbb9a11a994a8527830186a0b8c4084ce7080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006f0182a0cc707b055322ccf6d4cb6a5aff1aeb22000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000186a0c001a0e381eb89f21e450009706650346e3abfaee0c91c5685c8ec923d86b8212a2427a05b3a7bfdec8ca69469e989805e7715f5d317bf62304f868a905224e7dabe7b37" +} \ No newline at end of file diff --git a/tests/fixtures/multipayment.json b/tests/fixtures/multipayment.json index 20e781c9..62e21f44 100644 --- a/tests/fixtures/multipayment.json +++ b/tests/fixtures/multipayment.json @@ -1,19 +1,18 @@ { - "data": { - "network": 30, - "nonce": "1", - "gasPrice": 5, - "gasLimit": 1000000, - "valaue": "3000000000000000000", - "value": "300000000", - "recipientAddress": "0x83769BeEB7e5405ef0B7dc3C66C43E3a51A6d27f", - "data": "084ce708000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008233f6df6449d7655f4643d2e752dc8d2283fad50000000000000000000000008233f6df6449d7655f4643d2e752dc8d2283fad500000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f5e100000000000000000000000000000000000000000000000000000000000bebc200", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "id": "8ef542e888c41642297bf3e4cb0f58cfe3a07e38adcb74cd2f121b5653c4db9e", - "v": 27, - "r": "39e6a6fb8c41c33d1c56c6b0f8c15f977582f9fcf626dbc84b82526db201c8dc", - "s": "285f0849073a3952511bdc34682668272799eacf3cd7556a9800f46d57e557ea" - }, - "serialized": "02f9016d1e018005830f42409483769beeb7e5405ef0b7dc3c66c43e3a51a6d27f8411e1a300b90104084ce708000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008233f6df6449d7655f4643d2e752dc8d2283fad50000000000000000000000008233f6df6449d7655f4643d2e752dc8d2283fad500000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000005f5e100000000000000000000000000000000000000000000000000000000000bebc200c080a039e6a6fb8c41c33d1c56c6b0f8c15f977582f9fcf626dbc84b82526db201c8dca0285f0849073a3952511bdc34682668272799eacf3cd7556a9800f46d57e557ea" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x00EFd0D4639191C49908A7BddbB9A11A994A8527", + "value": "300000", + "data": "084ce708000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006f0182a0cc707b055322ccf6d4cb6a5aff1aeb22000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000186a00000000000000000000000000000000000000000000000000000000000030d40", + "v": 27, + "r": "0c7cfc6e77249b44385decfd49b8d4deac3c4c49147a0a8d539d82d51da81581", + "s": "6af2959905394b401c87872f78ae321cf8cfdd03fe80a815a99bdd723cc90462", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "d2b7d9e8730de8ab788a37905974c11f6df1a7e5bea5f9a716bffbec17b1d3a8" + }, + "serialized": "02f90173822710018085012a05f20083030d409400efd0d4639191c49908a7bddbb9a11a994a8527830493e0b90104084ce708000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006f0182a0cc707b055322ccf6d4cb6a5aff1aeb22000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000186a00000000000000000000000000000000000000000000000000000000000030d40c080a00c7cfc6e77249b44385decfd49b8d4deac3c4c49147a0a8d539d82d51da81581a06af2959905394b401c87872f78ae321cf8cfdd03fe80a815a99bdd723cc90462" +} \ No newline at end of file diff --git a/tests/fixtures/transfer-0.json b/tests/fixtures/transfer-0.json index 8d69083d..261344bb 100644 --- a/tests/fixtures/transfer-0.json +++ b/tests/fixtures/transfer-0.json @@ -1,18 +1,18 @@ { - "data": { - "network": 30, - "nonce": "123", - "gasPrice": 5, - "gasLimit": 21000, - "recipientAddress": "0xb693449adda7efc015d87944eae8b7c37eb1690a", - "value": "0", - "data": "", - "v": 28, - "r": "f7bae93b75f06c39600f123ca6c805a38636db9643eac29d20d21c6bf0d2eca2", - "s": "17265ff237bff3fe0620c53ff1615c4b8ad9136fe3d61dca38562c60dc5fcae2", - "senderPublicKey": "03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd", - "senderAddress": "0x41aD2bc63A2059f9b623533d87fe99887D794847", - "id": "7d6ad61dabbc9907484080100096c9c7c6364c130ca003f9dd730901c112437f" - }, - "serialized": "02f8621e7b800582520894b693449adda7efc015d87944eae8b7c37eb1690a8080c001a0f7bae93b75f06c39600f123ca6c805a38636db9643eac29d20d21c6bf0d2eca2a017265ff237bff3fe0620c53ff1615c4b8ad9136fe3d61dca38562c60dc5fcae2" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 21000, + "recipientAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", + "value": "0", + "data": "", + "v": 27, + "r": "2c42ef45cb01b01c0a59b61a7e82d37c8566e0fc0f0f47c2a2825d1cbc8abefc", + "s": "455bb2aec9d8d038db506d5a964728c78eaa4f237e0d40666742e4d5d686f576", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "241ce787680623dea7b9acf2951e2f8b8afac5f92b33b9909ab2bfbadf4be92c" + }, + "serialized": "02f869822710018085012a05f200825208946f0182a0cc707b055322ccf6d4cb6a5aff1aeb228080c080a02c42ef45cb01b01c0a59b61a7e82d37c8566e0fc0f0f47c2a2825d1cbc8abefca0455bb2aec9d8d038db506d5a964728c78eaa4f237e0d40666742e4d5d686f576" +} \ No newline at end of file diff --git a/tests/fixtures/transfer-large-amount.json b/tests/fixtures/transfer-large-amount.json index 0fcee465..45a87c02 100644 --- a/tests/fixtures/transfer-large-amount.json +++ b/tests/fixtures/transfer-large-amount.json @@ -1,18 +1,18 @@ { - "data": { - "network": 30, - "nonce": "17", - "gasPrice": 5, - "gasLimit": 21000, - "recipientAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "value": "10000000000000000000", - "data": "", - "v": 27, - "r": "c741f8ccf811e7080216b71e0cbcad1138a4f187b08c749c5e8780568f1ff4bc", - "s": "530341bef473fa92db1fe96922758ed010ba8eb80f2e527c9441771fa4c5368b", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "id": "fb9e521867f484cae4b59585d55ac55a99a8c6adfa0cf8b8b50d242115cbb40d" - }, - "serialized": "02f86a1e118005825208946f0182a0cc707b055322ccf6d4cb6a5aff1aeb22888ac7230489e8000080c080a0c741f8ccf811e7080216b71e0cbcad1138a4f187b08c749c5e8780568f1ff4bca0530341bef473fa92db1fe96922758ed010ba8eb80f2e527c9441771fa4c5368b" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 21000, + "recipientAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", + "value": "10000000000000000000", + "data": "", + "v": 27, + "r": "62666b937e4c3f55c87c44ee72b5a228c1377adbdad44264dd953b3c2b878734", + "s": "2d8670a69ce09018cfac5604d59a2b74bee18c99a91cbd14ac33c3ccfe96a35a", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "0d22ff14b09da9c5fa975d8fe79b93086853d223000cf88ff923a57650c93e4a" + }, + "serialized": "02f871822710018085012a05f200825208946f0182a0cc707b055322ccf6d4cb6a5aff1aeb22888ac7230489e8000080c080a062666b937e4c3f55c87c44ee72b5a228c1377adbdad44264dd953b3c2b878734a02d8670a69ce09018cfac5604d59a2b74bee18c99a91cbd14ac33c3ccfe96a35a" +} \ No newline at end of file diff --git a/tests/fixtures/transfer.json b/tests/fixtures/transfer.json index 24a2b1aa..31647d8d 100644 --- a/tests/fixtures/transfer.json +++ b/tests/fixtures/transfer.json @@ -1,18 +1,18 @@ { - "data": { - "network": 30, - "nonce": "1", - "gasPrice": 5, - "gasLimit": 21000, - "recipientAddress": "0x6f0182a0cc707b055322ccf6d4cb6a5aff1aeb22", - "value": "100000000", - "data": "", - "v": 27, - "r": "0567c4def813a66e03fa1cd499a27c6922698a67e25e0b38458d8f4bb0e581fc", - "s": "25fcdf9d110b82bde15bae4a49118deb83cfc3ec1656c2a29286d7836d328abe", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "id": "0b8a05781cc5ea130573f33330a739f9a17f7d889bcfab519b09ee5ccc7f359d" - }, - "serialized": "02f8661e018005825208946f0182a0cc707b055322ccf6d4cb6a5aff1aeb228405f5e10080c080a00567c4def813a66e03fa1cd499a27c6922698a67e25e0b38458d8f4bb0e581fca025fcdf9d110b82bde15bae4a49118deb83cfc3ec1656c2a29286d7836d328abe" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 21000, + "recipientAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", + "value": "100000000", + "data": "", + "v": 28, + "r": "104665257d4dea61c4654e74c6c0f6cd0a398905781c3040bea67dc641a66da0", + "s": "46d718d04b2331f3b0561808549ed3f3f0d867a284acf6b334869078df7a9136", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "b7927d90b38cd1296351f26145b3d8b0674fdc9b8721bc1a10f71a12bcbccf60" + }, + "serialized": "02f86d822710018085012a05f200825208946f0182a0cc707b055322ccf6d4cb6a5aff1aeb228405f5e10080c001a0104665257d4dea61c4654e74c6c0f6cd0a398905781c3040bea67dc641a66da0a046d718d04b2331f3b0561808549ed3f3f0d867a284acf6b334869078df7a9136" +} \ No newline at end of file diff --git a/tests/fixtures/unvote.json b/tests/fixtures/unvote.json index 5dccb90f..3b099dbf 100644 --- a/tests/fixtures/unvote.json +++ b/tests/fixtures/unvote.json @@ -1,18 +1,18 @@ { - "data": { - "gasPrice": 5, - "network": 30, - "id": "4f43cc9b97433bfc86f3aaa55dbedfad1f15c76b527ec68f7a80fc15105d2e43", - "gasLimit": 1000000, - "nonce": "1", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "recipientAddress": "0x535b3d7a252fa034ed71f0c53ec0c6f784cb64e1", - "value": "0", - "data": "3174b689", - "v": 27, - "r": "2853135c30a6b131e9270ce1b52999b8d2bdc18b25bef5b1c13ef4ca8a20ce9e", - "s": "3999a9d5d1ff826efa13052394b28b101535c92dcd8744c916c003431e08744e" - }, - "serialized": "02f8671e018005830f424094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180843174b689c080a02853135c30a6b131e9270ce1b52999b8d2bdc18b25bef5b1c13ef4ca8a20ce9ea03999a9d5d1ff826efa13052394b28b101535c92dcd8744c916c003431e08744e" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1", + "value": "0", + "data": "3174b689", + "v": 27, + "r": "bd7f932c18b49e05600cd1603808fd0a19701ee4af99035fc7b1a9159458d08d", + "s": "18a4420edfdc90fcff7c6e4d062ae11dae7a62a7ab53f6499862f3e79d67a252", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "ed937a96f4edc0fa89e7d6146b88f17a3de71f86fc200da49c73e7c93eabfea9" + }, + "serialized": "02f86e822710018085012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180843174b689c080a0bd7f932c18b49e05600cd1603808fd0a19701ee4af99035fc7b1a9159458d08da018a4420edfdc90fcff7c6e4d062ae11dae7a62a7ab53f6499862f3e79d67a252" +} \ No newline at end of file diff --git a/tests/fixtures/username-registration.json b/tests/fixtures/username-registration.json index 46d03a63..77d6e66e 100644 --- a/tests/fixtures/username-registration.json +++ b/tests/fixtures/username-registration.json @@ -1,18 +1,18 @@ { - "data": { - "gasPrice": 5, - "network": 30, - "id": "6643b3dec8d2e8aaa188fb83b96c9ebf2ed21d547ff641f267ddc5ef29152f6b", - "gasLimit": 1000000, - "nonce": "1", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "recipientAddress": "0x2c1de3b4dbb4adebebb5dcecae825be2a9fc6eb6", - "value": "0", - "data": "36a94134000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000037068700000000000000000000000000000000000000000000000000000000000", - "v": 27, - "r": "48f36028509a88c8670b2baaac14b5ba6a8c88bbd90cce4149a3070e57f0fa42", - "s": "297fe9a4d2df4c682e8705311d1143d2df9c89dc8689853544c1eb96121f5e85" - }, - "serialized": "02f8c81e018005830f4240942c1de3b4dbb4adebebb5dcecae825be2a9fc6eb680b86436a94134000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000037068700000000000000000000000000000000000000000000000000000000000c080a048f36028509a88c8670b2baaac14b5ba6a8c88bbd90cce4149a3070e57f0fa42a0297fe9a4d2df4c682e8705311d1143d2df9c89dc8689853544c1eb96121f5e85" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x2c1DE3b4Dbb4aDebEbB5dcECAe825bE2a9fc6eb6", + "value": "0", + "data": "36a94134000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000076669787475726500000000000000000000000000000000000000000000000000", + "v": 28, + "r": "4564cc1adbde3e8a309bf9d3eb76b45fecfae62fbdc0604f70483197de4d66b3", + "s": "4d4573a50c9a80221c21d11ce51b9b8bd196f9e1ab1a805b7d8b8e56fcfe2003", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "781979a58ac75475b91a1e401b50f9cc52465b21fe83e1c30e05676aaeb6a806" + }, + "serialized": "02f8cf822710018085012a05f20083030d40942c1de3b4dbb4adebebb5dcecae825be2a9fc6eb680b86436a94134000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000076669787475726500000000000000000000000000000000000000000000000000c001a04564cc1adbde3e8a309bf9d3eb76b45fecfae62fbdc0604f70483197de4d66b3a04d4573a50c9a80221c21d11ce51b9b8bd196f9e1ab1a805b7d8b8e56fcfe2003" +} \ No newline at end of file diff --git a/tests/fixtures/username-resignation.json b/tests/fixtures/username-resignation.json index 2211eed3..8846b88c 100644 --- a/tests/fixtures/username-resignation.json +++ b/tests/fixtures/username-resignation.json @@ -1,17 +1,18 @@ { - "data": { - "gasPrice": 5, - "network": 30, - "id": "b9a6712e63dafc05583d89c0a31a7199d027f06a21369e9df79e2ae2f20dca7e", - "gasLimit": 1000000, - "nonce": "1", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "recipientAddress": "0x2c1DE3b4Dbb4aDebEbB5dcECAe825bE2a9fc6eb6", - "value": "0", - "data": "ebed6dab", - "v": 28, - "r": "76ade83c279901613b31e41b9cf0e55223ef728edc5d920d108d239929abf523", - "s": "0a8fe944d4217ebfe6afad28f1fce2f03e4cfe7aa90ea932c1dae4216603a82c" - }, - "serialized": "02f8671e018005830f4240942c1de3b4dbb4adebebb5dcecae825be2a9fc6eb68084ebed6dabc001a076ade83c279901613b31e41b9cf0e55223ef728edc5d920d108d239929abf523a00a8fe944d4217ebfe6afad28f1fce2f03e4cfe7aa90ea932c1dae4216603a82c" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x2c1DE3b4Dbb4aDebEbB5dcECAe825bE2a9fc6eb6", + "value": "0", + "data": "ebed6dab", + "v": 27, + "r": "c786beafa03da8c6485bc15870ea8512db27427e3aa38654a7b8d534b30c48da", + "s": "78b2b4568f4d0f5d482c670001e6877b282ed6e16cdcbea6bd29195ca2bb036d", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "d1647fe630bcf63a23bda6015295dafe246356b0e7930cdc8a52f216fa4429a5" + }, + "serialized": "02f86e822710018085012a05f20083030d40942c1de3b4dbb4adebebb5dcecae825be2a9fc6eb68084ebed6dabc080a0c786beafa03da8c6485bc15870ea8512db27427e3aa38654a7b8d534b30c48daa078b2b4568f4d0f5d482c670001e6877b282ed6e16cdcbea6bd29195ca2bb036d" +} \ No newline at end of file diff --git a/tests/fixtures/validator-registration.json b/tests/fixtures/validator-registration.json index 8b276b3d..9e2279b6 100644 --- a/tests/fixtures/validator-registration.json +++ b/tests/fixtures/validator-registration.json @@ -1,18 +1,18 @@ { - "data": { - "gasPrice": 5, - "network": 30, - "id": "7d7a6fcda2c5c16347f42f909e3002509c07780aabb7896f42e3172f2f25e92a", - "gasLimit": 1000000, - "nonce": "1", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "recipientAddress": "0x535b3d7a252fa034ed71f0c53ec0c6f784cb64e1", - "value": "0", - "data": "602a9eee00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030954f46d6097a1d314e900e66e11e0dad0a57cd03e04ec99f0dedd1c765dcb11e6d7fa02e22cf40f9ee23d9cc1c0624bd00000000000000000000000000000000", - "v": 27, - "r": "609cfbaf2a8195741dcf2054e73c88e93103d4c13e7f9d5fc83f881c01a38773", - "s": "79266d0b2c9bdaccbc3fba88c6dfad4538bcdcda803b8e0faa33cdd84b73abed" - }, - "serialized": "02f8e81e018005830f424094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180b884602a9eee00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030954f46d6097a1d314e900e66e11e0dad0a57cd03e04ec99f0dedd1c765dcb11e6d7fa02e22cf40f9ee23d9cc1c0624bd00000000000000000000000000000000c080a0609cfbaf2a8195741dcf2054e73c88e93103d4c13e7f9d5fc83f881c01a38773a079266d0b2c9bdaccbc3fba88c6dfad4538bcdcda803b8e0faa33cdd84b73abed" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1", + "value": "0", + "data": "602a9eee0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003030954f46d6097a1d314e900e66e11e0dad0a57cd03e04ec99f0dedd1c765dcb11e6d7fa02e22cf40f9ee23d9cc1c062400000000000000000000000000000000", + "v": 28, + "r": "57216346b5252f6db63a2c78b5bc0a3697d2247377e9d9ef1b67849a87eb2413", + "s": "66ea02477fc19671b3b626e3c4d33939a8ba43004f0a56e900efc1e580739d11", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "5064b50091b8e5d50ec1d1eb7c5b71cdcf9c7355bba18ee0efeaeacb0b1c95d5" + }, + "serialized": "02f8ef822710018085012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180b884602a9eee0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003030954f46d6097a1d314e900e66e11e0dad0a57cd03e04ec99f0dedd1c765dcb11e6d7fa02e22cf40f9ee23d9cc1c062400000000000000000000000000000000c001a057216346b5252f6db63a2c78b5bc0a3697d2247377e9d9ef1b67849a87eb2413a066ea02477fc19671b3b626e3c4d33939a8ba43004f0a56e900efc1e580739d11" +} \ No newline at end of file diff --git a/tests/fixtures/validator-resignation.json b/tests/fixtures/validator-resignation.json index 5cc76fdd..c494f176 100644 --- a/tests/fixtures/validator-resignation.json +++ b/tests/fixtures/validator-resignation.json @@ -1,18 +1,18 @@ { - "data": { - "gasPrice": 5, - "network": 30, - "id": "c4407fe1d819a689c0ad0f7f2a872a15bf26a099865f1d221bddc69f217c4038", - "gasLimit": 1000000, - "nonce": "1", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "recipientAddress": "0x535b3d7a252fa034ed71f0c53ec0c6f784cb64e1", - "value": "0", - "data": "b85f5da2", - "v": 27, - "r": "52d016bfb61cb3b57d36a7444ce26d3c557b2acb31a10b5951fc3c9e8d2e49a6", - "s": "4940013218020780485b24cea9afbc6c93249286a308af33735c0c87bdeb4b5a" - }, - "serialized": "02f8671e018005830f424094535b3d7a252fa034ed71f0c53ec0c6f784cb64e18084b85f5da2c080a052d016bfb61cb3b57d36a7444ce26d3c557b2acb31a10b5951fc3c9e8d2e49a6a04940013218020780485b24cea9afbc6c93249286a308af33735c0c87bdeb4b5a" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1", + "value": "0", + "data": "b85f5da2", + "v": 28, + "r": "5670e5d314906eeaf92da15b55eaeabbb92814874f2fe6c72bcbee7e13e7ff40", + "s": "32a34c8438e441d10e83180b5a8a84cf1bfb92fc0fe8b53cd23dc4105631b83d", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "2dc3b976d8dee25e2ecf341c1493670d9d087cc338ed63f764c0eb9e28869dc3" + }, + "serialized": "02f86e822710018085012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e18084b85f5da2c001a05670e5d314906eeaf92da15b55eaeabbb92814874f2fe6c72bcbee7e13e7ff40a032a34c8438e441d10e83180b5a8a84cf1bfb92fc0fe8b53cd23dc4105631b83d" +} \ No newline at end of file diff --git a/tests/fixtures/vote.json b/tests/fixtures/vote.json index be55d915..965df204 100644 --- a/tests/fixtures/vote.json +++ b/tests/fixtures/vote.json @@ -1,18 +1,18 @@ { - "data": { - "gasPrice": 5, - "network": 30, - "id": "991a3a63dc47be84d7982acb4c2aae488191373f31b8097e07d3ad95c0997e69", - "gasLimit": 1000000, - "nonce": "1", - "senderPublicKey": "023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3", - "senderAddress": "0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22", - "recipientAddress": "0x535b3d7a252fa034ed71f0c53ec0c6f784cb64e1", - "value": "0", - "data": "6dd7d8ea000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763", - "v": 27, - "r": "1e0b168c7520f39fb99f9bf1ea7c0086a3a9e78f215da5a7e997fd8ef5657f5f", - "s": "35019ef68773310144587b228dbc626e8cf3654377e92901f8d7f13119b0e09e" - }, - "serialized": "02f8871e018005830f424094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180a46dd7d8ea000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763c080a01e0b168c7520f39fb99f9bf1ea7c0086a3a9e78f215da5a7e997fd8ef5657f5fa035019ef68773310144587b228dbc626e8cf3654377e92901f8d7f13119b0e09e" -} + "data": { + "network": 10000, + "nonce": "1", + "gasPrice": 5000000000, + "gasLimit": 200000, + "recipientAddress": "0x535B3D7A252fa034Ed71F0C53ec0C6F784cB64E1", + "value": "0", + "data": "6dd7d8ea000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763", + "v": 27, + "r": "67734fadb38bd9cd584d39fc08af836f15dd6337b05511b312add11a3586451a", + "s": "08ba89cec57c38b1e1f488d3507b9cbe1a21aa3f441482e62bd9c1eef61d3bd9", + "senderPublicKey": "0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d", + "senderAddress": "0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd", + "id": "351114ee096ad8a02ddb7abee6f4fe283b8dadceff17157722d7a8153de710c1" + }, + "serialized": "02f88e822710018085012a05f20083030d4094535b3d7a252fa034ed71f0c53ec0c6f784cb64e180a46dd7d8ea000000000000000000000000c3bbe9b1cee1ff85ad72b87414b0e9b7f2366763c080a067734fadb38bd9cd584d39fc08af836f15dd6337b05511b312add11a3586451aa008ba89cec57c38b1e1f488d3507b9cbe1a21aa3f441482e62bd9c1eef61d3bd9" +} \ No newline at end of file diff --git a/tests/identity/conftest.py b/tests/identity/conftest.py index faa90bb6..ebda2616 100644 --- a/tests/identity/conftest.py +++ b/tests/identity/conftest.py @@ -6,12 +6,14 @@ def identity(): """ data = { 'data': { - 'private_key': 'bef98d4c0e58d0e4695560594f91a349421b7cdc3e63a560470ccb259f99f087', - 'public_key': '023efc1da7f315f3c533a4080e491f32cd4219731cef008976c3876539e1f192d3', - 'address': '0x6F0182a0cc707b055322CcF6d4CB6a5Aff1aEb22', - 'wif': 'SFyRYRYL1DddchRpuhp94hKN1tpYjzAEkLuUDAMjGJBkoAaz2RQk' - }, - 'passphrase': 'my super secret passphrase' + 'private_key': '50829dd3b7ffbe2df401d730b5e60cea7520ba3f3a18e5b1490707667fb43fae', + 'public_key': '0243333347c8cbf4e3cbc7a96964181d02a2b0c854faa2fef86b4b8d92afcf473d', + 'address': '0x1E6747BEAa5B4076a6A98D735DF8c35a70D18Bdd', + 'wif': 'UZYnRZ8qpeQWTLeCNzw93guWSdKLmr2vHEWGG4sNv7TJofL7TZvy', + 'validatorPublicKey': 'b209f4a7454ae17c5808991dffbf204c747b851f351d2ce72a6e18903d0e2f609e0328ebbc3fb97cd4d3660b4bc156f1', + 'validatorPrivateKey': '6ec4993df152b10e672567c1fdf854a4cee50708fa30986a7d9b259673099175', + }, + 'passphrase': 'found lobster oblige describe ready addict body brave live vacuum display salute lizard combine gift resemble race senior quality reunion proud tell adjust angle' } return data @@ -21,13 +23,13 @@ def sign_compact(): """ data = { 'data': { - 'serialized': '1b0567c4def813a66e03fa1cd499a27c6922698a67e25e0b38458d8f4bb0e581fc25fcdf9d110b82bde15bae4a49118deb83cfc3ec1656c2a29286d7836d328abe', - 'message': '02e31e018005825208946f0182a0cc707b055322ccf6d4cb6a5aff1aeb228405f5e10080c0', - 'v': 27, - 'r': '0567c4def813a66e03fa1cd499a27c6922698a67e25e0b38458d8f4bb0e581fc', - 's': '25fcdf9d110b82bde15bae4a49118deb83cfc3ec1656c2a29286d7836d328abe', + 'serialized': '1c104665257d4dea61c4654e74c6c0f6cd0a398905781c3040bea67dc641a66da046d718d04b2331f3b0561808549ed3f3f0d867a284acf6b334869078df7a9136', + 'message': '02ea822710018085012a05f200825208946f0182a0cc707b055322ccf6d4cb6a5aff1aeb228405f5e10080c0', + 'v': 28, + 'r': '104665257d4dea61c4654e74c6c0f6cd0a398905781c3040bea67dc641a66da0', + 's': '46d718d04b2331f3b0561808549ed3f3f0d867a284acf6b334869078df7a9136', }, - 'passphrase': 'my super secret passphrase' + 'passphrase': 'found lobster oblige describe ready addict body brave live vacuum display salute lizard combine gift resemble race senior quality reunion proud tell adjust angle' } return data diff --git a/tests/identity/test_wif.py b/tests/identity/test_wif.py index ddb7b936..ec3b12e6 100644 --- a/tests/identity/test_wif.py +++ b/tests/identity/test_wif.py @@ -1,6 +1,10 @@ +from crypto.configuration.network import set_network from crypto.identity.wif import wif_from_passphrase +from crypto.networks.testnet import Testnet def test_wif_from_passphrase(identity): + set_network(Testnet) + result = wif_from_passphrase(identity['passphrase']) assert result == identity['data']['wif'] diff --git a/tests/transactions/builder/conftest.py b/tests/transactions/builder/conftest.py index 374172f8..c819610c 100644 --- a/tests/transactions/builder/conftest.py +++ b/tests/transactions/builder/conftest.py @@ -4,4 +4,16 @@ def passphrase(): """Passphrase used for tests""" - return 'my super secret passphrase' + return 'found lobster oblige describe ready addict body brave live vacuum display salute lizard combine gift resemble race senior quality reunion proud tell adjust angle' + +@pytest.fixture +def validator_public_key(): + """BLS Public used for validator tests""" + + return '30954f46d6097a1d314e900e66e11e0dad0a57cd03e04ec99f0dedd1c765dcb11e6d7fa02e22cf40f9ee23d9cc1c0624' + +@pytest.fixture +def username(): + """Username used for tests""" + + return 'fixture' diff --git a/tests/transactions/builder/test_username_registration_builder.py b/tests/transactions/builder/test_username_registration_builder.py index c8536466..5befa727 100644 --- a/tests/transactions/builder/test_username_registration_builder.py +++ b/tests/transactions/builder/test_username_registration_builder.py @@ -1,7 +1,7 @@ from crypto.exceptions import InvalidUsernameException from crypto.transactions.builder.username_registration_builder import UsernameRegistrationBuilder -def test_username_registration_transaction(passphrase, load_transaction_fixture): +def test_username_registration_transaction(passphrase, username, load_transaction_fixture): fixture = load_transaction_fixture('username-registration') builder = ( @@ -10,7 +10,7 @@ def test_username_registration_transaction(passphrase, load_transaction_fixture) .nonce(fixture['data']['nonce']) .network(fixture['data']['network']) .gas_limit(fixture['data']['gasLimit']) - .username('php') + .username(username) .sign(passphrase) ) diff --git a/tests/transactions/builder/test_validator_registration_builder.py b/tests/transactions/builder/test_validator_registration_builder.py index 284cd43a..34d5b80d 100644 --- a/tests/transactions/builder/test_validator_registration_builder.py +++ b/tests/transactions/builder/test_validator_registration_builder.py @@ -1,6 +1,6 @@ from crypto.transactions.builder.validator_registration_builder import ValidatorRegistrationBuilder -def test_validator_registration_transaction(passphrase, load_transaction_fixture): +def test_validator_registration_transaction(passphrase, validator_public_key, load_transaction_fixture): fixture = load_transaction_fixture('validator-registration') builder = ( @@ -9,11 +9,12 @@ def test_validator_registration_transaction(passphrase, load_transaction_fixture .nonce(fixture['data']['nonce']) .network(fixture['data']['network']) .gas_limit(fixture['data']['gasLimit']) - .validator_public_key('954f46d6097a1d314e900e66e11e0dad0a57cd03e04ec99f0dedd1c765dcb11e6d7fa02e22cf40f9ee23d9cc1c0624bd') + .validator_public_key(validator_public_key) .recipient_address(fixture['data']['recipientAddress']) .sign(passphrase) ) + assert builder.transaction.serialize().hex() == fixture['serialized'] assert builder.transaction.data['gasPrice'] == fixture['data']['gasPrice'] assert builder.transaction.data['nonce'] == fixture['data']['nonce'] assert builder.transaction.data['network'] == fixture['data']['network'] diff --git a/tests/transactions/test_deserializer.py b/tests/transactions/test_deserializer.py index 4c4c44ba..f5b1d895 100644 --- a/tests/transactions/test_deserializer.py +++ b/tests/transactions/test_deserializer.py @@ -1,5 +1,7 @@ from crypto.transactions.deserializer import Deserializer from crypto.transactions.types.transfer import Transfer +from crypto.transactions.types.username_registration import UsernameRegistration +from crypto.transactions.types.username_resignation import UsernameResignation from crypto.transactions.types.vote import Vote from crypto.transactions.types.unvote import Unvote from crypto.transactions.types.validator_registration import ValidatorRegistration @@ -27,7 +29,7 @@ def test_deserialize_vote(load_transaction_fixture): assert isinstance(transaction, Vote) assert transaction.data['vote'].lower() == '0xc3bbe9b1cee1ff85ad72b87414b0e9b7f2366763' - assert transaction.data['id'] == '991a3a63dc47be84d7982acb4c2aae488191373f31b8097e07d3ad95c0997e69' + assert transaction.data['id'] == fixture['data']['id'] def test_deserialize_unvote(load_transaction_fixture): fixture = load_transaction_fixture('unvote') @@ -47,6 +49,18 @@ def test_deserialize_validator_resignation(load_transaction_fixture): assert isinstance(transaction, ValidatorResignation) +def test_deserialize_username_registration(load_transaction_fixture): + fixture = load_transaction_fixture('username-registration') + transaction = assert_deserialized(fixture, ['id', 'nonce', 'gasPrice', 'gasLimit', 'v', 'r', 's']) + + assert isinstance(transaction, UsernameRegistration) + +def test_deserialize_username_resignation(load_transaction_fixture): + fixture = load_transaction_fixture('username-resignation') + transaction = assert_deserialized(fixture, ['id', 'nonce', 'gasPrice', 'gasLimit', 'v', 'r', 's']) + + assert isinstance(transaction, UsernameResignation) + def test_parse_number(): assert Deserializer.parse_number('0x01') == 1 assert Deserializer.parse_number('0x0100') == 256 diff --git a/tests/utils/test_rpl_decoder.py b/tests/utils/test_rpl_decoder.py index e896c426..2dc000c1 100644 --- a/tests/utils/test_rpl_decoder.py +++ b/tests/utils/test_rpl_decoder.py @@ -7,18 +7,18 @@ def test_decode_function_call(load_transaction_fixture): decoded_rlp = RlpDecoder.decode('0x' + fixture['serialized'][2:]) assert len(decoded_rlp) == 12 - assert decoded_rlp[0] == '0x1e' + assert decoded_rlp[0] == '0x2710' assert decoded_rlp[1] == '0x01' assert decoded_rlp[2] == '0x' - assert decoded_rlp[3] == '0x05' + assert decoded_rlp[3] == '0x012a05f200' assert decoded_rlp[4] == '0x5208' assert decoded_rlp[5] == '0x6f0182a0cc707b055322ccf6d4cb6a5aff1aeb22' assert decoded_rlp[6] == '0x05f5e100' assert decoded_rlp[7] == '0x' assert decoded_rlp[8] == [] - assert decoded_rlp[9] == '0x' - assert decoded_rlp[10] == '0x0567c4def813a66e03fa1cd499a27c6922698a67e25e0b38458d8f4bb0e581fc' - assert decoded_rlp[11] == '0x25fcdf9d110b82bde15bae4a49118deb83cfc3ec1656c2a29286d7836d328abe' + assert decoded_rlp[9] == '0x01' + assert decoded_rlp[10] == '0x104665257d4dea61c4654e74c6c0f6cd0a398905781c3040bea67dc641a66da0' + assert decoded_rlp[11] == '0x46d718d04b2331f3b0561808549ed3f3f0d867a284acf6b334869078df7a9136' def test_decoding_str(): decoded = RlpDecoder.decode('0x8774657374696e67')