def test_can_serialize_deserialize(forced_mock_blockchain, sample_signed_change_request):
    block = Block.create_from_signed_change_request(
        forced_mock_blockchain, sample_signed_change_request, get_node_signing_key()
    )
    serialized_dict = block.serialize_to_dict()
    deserialized_block = Block.deserialize_from_dict(serialized_dict)
    assert deserialized_block == block
    assert deserialized_block is not block
Beispiel #2
0
def test_node_serializes_without_identifier_in_block(memory_blockchain,
                                                     user_account_key_pair):
    account_number = user_account_key_pair.public
    node = baker.make(Node, identifier=account_number)

    request = NodeDeclarationSignedChangeRequest.create(
        network_addresses=['https://192.168.0.34:8555/'],
        fee_amount=3,
        signing_key=user_account_key_pair.private)
    block = Block.create_from_signed_change_request(memory_blockchain, request,
                                                    get_node_signing_key())

    serialized = block.serialize_to_dict()
    assert 'identifier' not in serialized['message']['updated_account_states'][
        account_number]['node']

    deserialized = Block.deserialize_from_dict(serialized)
    deserialized_node = deserialized.message.updated_account_states[
        account_number].node
    assert deserialized_node is not node
    assert deserialized_node.identifier == account_number