package serverResponse_test

import "seekia/internal/network/serverResponse"

import "seekia/internal/cryptocurrency/cardanoAddress"
import "seekia/internal/cryptocurrency/ethereumAddress"
import "seekia/internal/cryptography/csidh"
import "seekia/internal/cryptography/frodo"
import "seekia/internal/cryptography/mlkem"
import "seekia/internal/cryptography/nacl"
import "seekia/internal/generate"
import "seekia/internal/genetics/geneticReferences/traits"
import "seekia/internal/genetics/geneticReferences/monogenicDiseases"
import "seekia/internal/genetics/geneticReferences/polygenicDiseases"
import "seekia/internal/helpers"
import "seekia/internal/identity"
import "seekia/internal/parameters/readParameters"
import "seekia/internal/profiles/profileFormat"

import "crypto/rand"
import "testing"
import "time"
import "reflect"
import "maps"
import "slices"
import "errors"

//TODO: Test the None case for all responses where it is permissible

//TODO: Replace the Random retrieval of certain parameters with a for loop that will cycle through each option
//		For example, instead of choosing a profileType to retrieve by random, try all profileTypes
//		This way, the tests will not have to be run multiple times to test all profileTypes

func getNewRandomRequestIdentifier()([16]byte, error){

	var requestIdentifier [16]byte

	_, err := rand.Read(requestIdentifier[:])
	if (err != nil) { return [16]byte{}, err }

	return requestIdentifier, nil
}

func getNewRandomConnectionKey()([32]byte, error){

	var newKeyArray [32]byte

	_, err := rand.Read(newKeyArray[:])
	if (err != nil) { return [32]byte{}, err }

	return newKeyArray, nil
}


func TestCreateAndReadResponse_EstablishConnectionKey(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	requestorNaclPublicKey, requestorNaclPrivateKey, err := nacl.GetNewRandomPublicPrivateNaclKeys()
	if (err != nil) {
		t.Fatal("Failed to create random nacl keys: " + err.Error())
	}

	requestorMlkemPublicKey, requestorMlkemPrivateKey, err := mlkem.GetNewRandomPublicPrivateMlkemKeys()
	if (err != nil) {
		t.Fatal("Failed to create random mlkem keys: " + err.Error())
	}

	requestorCsidhPublicKey, requestorCsidhPrivateKey, err := csidh.GetNewRandomPublicPrivateCsidhKeys()
	if (err != nil) {
		t.Fatal("Failed to create random csidh keys: " + err.Error())
	}

	requestorFrodoPublicKey, requestorFrodoPrivateKey, err := frodo.GetNewRandomPublicPrivateFrodoKeys()
	if (err != nil) {
		t.Fatal("Failed to create random frodo keys: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	responseBytes, connectionKey, err := serverResponse.CreateServerResponse_EstablishConnectionKey(hostPublicIdentityKey, hostPrivateIdentityKey, requestIdentifier, requestorNaclPublicKey, requestorMlkemPublicKey, requestorCsidhPublicKey, requestorFrodoPublicKey)
	if (err != nil) {
		t.Fatal("Failed to create EstablishConnectionKey response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, connectionKey_Received, err := serverResponse.ReadServerResponse_EstablishConnectionKey(responseBytes, requestorNaclPublicKey, requestorNaclPrivateKey, requestorMlkemPrivateKey, requestorCsidhPrivateKey, requestorFrodoPrivateKey)
	if (err != nil) {
		t.Fatal("Failed to read EstablishConnectionKey response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read EstablishConnectionKey response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read EstablishConnectionKey response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read EstablishConnectionKey response: Mismatched hostIdentityHash.")
	}

	if (connectionKey != connectionKey_Received){
		t.Fatal("Failed to read EstablishConnectionKey response: Mismatched connectionKey.")
	}
}


func TestCreateAndReadResponse_GetParametersInfo(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	parametersTypesList := readParameters.GetAllParametersTypesList()

	helpers.RandomizeListOrder(parametersTypesList)

	parametersInfoMap := make(map[string]int64)

	for index, element := range parametersTypesList{
		
		randomBool := helpers.GetRandomBool()
		
		if (index == 0 || randomBool == true){

			parametersInfoMap[element] = time.Now().Unix()
		}
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetParametersInfo(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, parametersInfoMap)
	if (err != nil) {
		t.Fatal("Failed to create GetParametersInfo response.")
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, parametersInfoMap_Received, err := serverResponse.ReadServerResponse_GetParametersInfo(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetParametersInfo response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetParametersInfo response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetParametersInfo response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetParametersInfo response: Mismatched hostIdentityHash.")
	}

	areEqual := maps.Equal(parametersInfoMap, parametersInfoMap_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetParametersInfo response: mismatched parametersInfoMap")
	}
}

func TestCreateAndReadResponse_GetParameters(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys.")
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash.")
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	networkType, err := helpers.GetRandomByteWithinRange(1, 2)
	if (err != nil){
		t.Fatal("GetRandomByteWithinRange failed: " + err.Error())
	}

	parametersTypesList := readParameters.GetAllParametersTypesList()

	helpers.RandomizeListOrder(parametersTypesList)

	parametersList := make([][]byte, 0)

	for index, parametersType := range parametersTypesList{

		randomBool := helpers.GetRandomBool()
		
		if (index == 0 || randomBool == true){

			fakeParametersBytes, err := generate.GetFakeParameters(parametersType, networkType)
			if (err != nil) {
				t.Fatal("Failed to get fake parameters: " + err.Error())
			}

			parametersList = append(parametersList, fakeParametersBytes)
		}
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetParameters(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, parametersList)
	if (err != nil) {
		t.Fatal("Failed to create GetParameters response: " + err.Error())
	}
	
	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, parametersList_Received, err := serverResponse.ReadServerResponse_GetParameters(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetParameters response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetParameters response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetParameters response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetParameters response: Mismatched hostIdentityHash.")
	}

	areEqual := reflect.DeepEqual(parametersList, parametersList_Received)	
	if (areEqual == false){
		t.Fatal("Failed to read GetParameters response: mismatched parametersList.")
	}
}


func TestCreateAndReadResponse_GetProfilesInfo(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	randomProfileType, err := helpers.GetRandomItemFromList([]string{"Mate", "Host", "Moderator"})
	if (err != nil) {
		t.Fatal("Failed to get random profileType: " + err.Error())
	}

	profileInfoObjectsList := make([]serverResponse.ProfileInfoStruct, 0, 1000)

	for i:=0; i<1000; i++{

		profileHash, err := helpers.GetNewRandomProfileHash(true, randomProfileType, false, false)
		if (err != nil) {
			t.Fatal("Failed to create random profile hash: " + err.Error())
		}

		profileAuthor, err := identity.GetNewRandomIdentityHash(true, randomProfileType)
		if (err != nil) {
			t.Fatal("Failed to create random identity hash: " + err.Error())
		}

		profileCreationTime := time.Now().Unix()

		profileInfoObject := serverResponse.ProfileInfoStruct{
			ProfileHash: profileHash,
			ProfileAuthor: profileAuthor,
			ProfileCreationTime: profileCreationTime,
		}

		profileInfoObjectsList = append(profileInfoObjectsList, profileInfoObject)
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetProfilesInfo(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, profileInfoObjectsList)
	if (err != nil) {
		t.Fatal("Failed to create GetProfilesInfo response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, profilesInfoObjectsList_Received, err := serverResponse.ReadServerResponse_GetProfilesInfo(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetProfilesInfo response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetProfilesInfo response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetProfilesInfo response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetProfilesInfo response: Mismatched hostIdentityHash.")
	}
	
	areEqual := slices.Equal(profileInfoObjectsList, profilesInfoObjectsList_Received)
	if (areEqual == false){
		t.Fatal("Received profilesInfoObjectsList does not match original.")
	}

	//TODO: Add None case
}


func TestCreateAndReadResponse_GetProfiles(t *testing.T){

	monogenicDiseases.InitializeMonogenicDiseaseVariables()

	err := polygenicDiseases.InitializePolygenicDiseaseVariables()	
	if (err != nil) {
		t.Fatal("InitializePolygenicDiseaseVariables failed: " + err.Error())
	}

	err = traits.InitializeTraitVariables()
	if (err != nil) {
		t.Fatal("InitializeTraitVariables failed: " + err.Error())
	}

	err = profileFormat.InitializeProfileFormatVariables()
	if (err != nil) {
		t.Fatal("Failed to initialize profile format variables: " + err.Error())
	}

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	networkType, err := helpers.GetRandomByteWithinRange(1, 2)
	if (err != nil){
		t.Fatal("GetRandomByteWithinRange failed: " + err.Error())
	}

	profilesList := make([][]byte, 0, 10)

	for i:=0; i<10; i++{

		fakeProfileType, err := helpers.GetRandomItemFromList([]string{"Mate", "Host", "Moderator"})
		if (err != nil) {
			t.Fatal("Failed to get random profileType: " + err.Error())
		}

		profilePublicIdentityKey, profilePrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
		if (err != nil) {
			t.Fatal("Failed to create random identity keys: " + err.Error())
		}

		fakeProfileBytes, err := generate.GetFakeProfile(fakeProfileType, profilePublicIdentityKey, profilePrivateIdentityKey, networkType)
		if (err != nil) {
			t.Fatal("Failed to create fake profile: " + err.Error())
		}

		profilesList = append(profilesList, fakeProfileBytes)
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetProfiles(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, profilesList)
	if (err != nil) {
		t.Fatal("Failed to create GetProfiles response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, profilesList_Received, err := serverResponse.ReadServerResponse_GetProfiles(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetProfiles response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetProfiles response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetProfiles response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetProfiles response: Mismatched hostIdentityHash.")
	}

	areEqual := reflect.DeepEqual(profilesList, profilesList_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetProfiles response: mismatched profilesList.")
	}

	// Now we test empty list case

	emptyProfilesList := make([][]byte, 0)

	responseBytes, err = serverResponse.CreateServerResponse_GetProfiles(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, emptyProfilesList)
	if (err != nil) {
		t.Fatal("Failed to create GetProfiles response: " + err.Error())
	}
	
	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, profilesList_Received, err = serverResponse.ReadServerResponse_GetProfiles(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetProfiles response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetProfiles response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetProfiles response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetProfiles response: Mismatched hostIdentityHash.")
	}

	if (len(profilesList_Received) != 0){
		t.Fatal("Failed to read GetProfiles response: profiles list not empty.")
	}
}



func TestCreateAndReadResponse_GetMessageHashesList(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	messageHashesList := make([][26]byte, 0, 1000)

	for i:=0; i<1000; i++{

		messageHash, err := helpers.GetNewRandomMessageHash()
		if (err != nil) {
			t.Fatal("GetNewRandomMessageHash failed: " + err.Error())
		}

		messageHashesList = append(messageHashesList, messageHash)
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetMessageHashesList(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, messageHashesList)
	if (err != nil) {
		t.Fatal("Failed to create GetMessageHashesList response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, messageHashesList_Received, err := serverResponse.ReadServerResponse_GetMessageHashesList(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetMessageHashesList response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetMessageHashesList response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetMessageHashesList response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetMessageHashesList response: Mismatched hostIdentityHash.")
	}

	areEqual := slices.Equal(messageHashesList, messageHashesList_Received)	
	if (areEqual == false){
		t.Fatal("Failed to read GetMessageHashesList response: Received messageHashesList does not match.")
	}

	//TODO: Add None case

}



func TestCreateAndReadResponse_GetMessages(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	networkType, err := helpers.GetRandomByteWithinRange(1, 2)
	if (err != nil){
		t.Fatal("GetRandomByteWithinRange failed: " + err.Error())
	}

	messagesList := make([][]byte, 0, 10)

	for i:=0; i<10; i++{

		fakeMessageBytes, _, _, err := generate.GetFakeMessage(networkType, "Text")
		if (err != nil) {
			t.Fatal("Failed to create fake message: " + err.Error())
		}
	
		messagesList = append(messagesList, fakeMessageBytes)
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetMessages(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, messagesList)
	if (err != nil) {
		t.Fatal("Failed to create GetMessages response: " + err.Error())
	}
	
	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, messagesList_Received, err := serverResponse.ReadServerResponse_GetMessages(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetMessages response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetMessages response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetMessages response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetMessages response: Mismatched hostIdentityHash.")
	}

	areEqual := reflect.DeepEqual(messagesList, messagesList_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetMessages response: mismatched messagesList.")
	}

	// Now we test empty list case

	emptyMessagesList := make([][]byte, 0)

	responseBytes, err = serverResponse.CreateServerResponse_GetMessages(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, emptyMessagesList)
	if (err != nil) {
		t.Fatal("Failed to create GetMessages response: " + err.Error())
	}
	
	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, messagesList_Received, err = serverResponse.ReadServerResponse_GetMessages(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetMessages response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetMessages response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetMessages response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetMessages response: Mismatched hostIdentityHash.")
	}

	if (len(messagesList_Received) != 0){
		t.Fatal("Failed to read GetMessages response: messages list not empty.")
	}
}



func TestCreateAndReadResponse_GetIdentityReviewsInfo(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	// Map structure: Review Hash -> Reviewed hash
	reviewsInfoMap := make(map[[29]byte][]byte)

	for i:=0; i<1000; i++{

		// We randomly choose either a profile hash, identity hash, or attribute hash

		reviewedType, err := helpers.GetRandomItemFromList([]string{"Profile", "Identity", "Attribute"})
		if (err != nil) {

			t.Fatal("Failed to get random reviewedType: " + err.Error())

		}

		reviewHash, err := helpers.GetNewRandomReviewHash(true, reviewedType)
		if (err != nil){
			
			t.Fatal("Failed to get random review hash: " + err.Error())
		}

		if (reviewedType == "Profile"){

			randomProfileHash, err := helpers.GetNewRandomProfileHash(false, "", true, false)
			if (err != nil) {
				t.Fatal("Failed to get random profile Hash: " + err.Error())
			}

			reviewsInfoMap[reviewHash] = randomProfileHash[:]

		} else if (reviewedType == "Identity"){

			randomIdentityHash, err := identity.GetNewRandomIdentityHash(false, "")
			if (err != nil) {
				t.Fatal("Failed to create random identity hash: " + err.Error())
			}

			reviewsInfoMap[reviewHash] = randomIdentityHash[:]

		} else {
	
			//reviewedType == "Attribute"

			randomAttributeHash, err := helpers.GetNewRandomAttributeHash(false, "", false, false)
			if (err != nil){
				t.Fatal("Failed to get random attribute hash: " + err.Error())
			}

			reviewsInfoMap[reviewHash] = randomAttributeHash[:]
		}
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetIdentityReviewsInfo(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, reviewsInfoMap)
	if (err != nil) {
		t.Fatal("Failed to create GetIdentityReviewsInfo response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reviewsInfoMap_Received, err := serverResponse.ReadServerResponse_GetIdentityReviewsInfo(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetIdentityReviewsInfo response: " + err.Error())
	}
	if (ableToRead == false) {
		t.Fatal("Failed to read GetIdentityReviewsInfo response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetIdentityReviewsInfo response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetIdentityReviewsInfo response: Mismatched hostIdentityHash.")
	}

	areEqual := reflect.DeepEqual(reviewsInfoMap, reviewsInfoMap_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetIdentityReviewsInfo response: mismatched reviewsInfoMap")
	}

	//TODO: Add None case

}


func TestCreateAndReadResponse_GetMessageReviewsInfo(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	// Map structure: Review Hash -> Reviewed message hash
	reviewsInfoMap := make(map[[29]byte][26]byte)

	for i:=0; i<1000; i++{

		reviewHash, err := helpers.GetNewRandomReviewHash(true, "Message")
		if (err != nil){
			t.Fatal("Failed to get new random review hash: " + err.Error())
		}

		messageHash, err := helpers.GetNewRandomMessageHash()
		if (err != nil) {
			t.Fatal("GetNewRandomMessageHash failed: " + err.Error())
		}

		reviewsInfoMap[reviewHash] = messageHash
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetMessageReviewsInfo(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, reviewsInfoMap)
	if (err != nil) {
		t.Fatal("Failed to create GetMessageReviewsInfo response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reviewsInfoMap_Received, err := serverResponse.ReadServerResponse_GetMessageReviewsInfo(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetMessageReviewsInfo response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetMessageReviewsInfo response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetMessageReviewsInfo response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetMessageReviewsInfo response: Mismatched hostIdentityHash.")
	}

	areEqual := maps.Equal(reviewsInfoMap, reviewsInfoMap_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetMessageReviewsInfo response:  mismatched reviewsInfoMap")
	}

	//TODO: Add None case

}

func TestCreateAndReadResponse_GetReviews(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	networkType, err := helpers.GetRandomByteWithinRange(1, 2)
	if (err != nil){
		t.Fatal("GetRandomByteWithinRange failed: " + err.Error())
	}

	reviewsList := make([][]byte, 0, 10)

	for i:=0; i<10; i++{

		reviewType, err := helpers.GetRandomItemFromList([]string{"Profile", "Identity", "Message", "Attribute"})
		if (err != nil) {
			t.Fatal("Cannot get random reviewType: " + err.Error())
		}

		fakeReviewBytes, err := generate.GetFakeReview(reviewType, networkType)
		if (err != nil) {
			t.Fatal("Failed to create fake review: " + err.Error())
		}

		reviewsList = append(reviewsList, fakeReviewBytes)
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetReviews(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, reviewsList)
	if (err != nil) {
		t.Fatal("Failed to create GetReviews response: " + err.Error())
	}
	
	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reviewsList_Received, err := serverResponse.ReadServerResponse_GetReviews(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetReviews response: " + err.Error())
	}
	if (ableToRead == false) {
		t.Fatal("Failed to read GetReviews response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetReviews response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetReviews response: Mismatched hostIdentityHash.")
	}

	areEqual := reflect.DeepEqual(reviewsList, reviewsList_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetReviews response: mismatched reviewsList.")
	}

	// Now we test empty list case

	emptyReviewsList := make([][]byte, 0)

	responseBytes, err = serverResponse.CreateServerResponse_GetReviews(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, emptyReviewsList)
	if (err != nil) {
		t.Fatal("Failed to create GetReviews response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reviewsList_Received, err = serverResponse.ReadServerResponse_GetReviews(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetReviews response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetReviews response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetReviews response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetReviews response: Mismatched hostIdentityHash.")
	}

	if (len(reviewsList_Received) != 0){
		t.Fatal("Failed to read GetReviews response: reviews list not empty.")
	}
}

func TestCreateAndReadResponse_GetIdentityReportsInfo(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	// Map Structure: Report Hash -> Reported hash
	reportsInfoMap := make(map[[30]byte][]byte)

	for i:=0; i<1000; i++{

		// We randomly choose either a profile hash, identity hash or attribute hash
		reportedType, err := helpers.GetRandomItemFromList([]string{"Profile", "Identity", "Attribute"})
		if (err != nil) {
			t.Fatal("Failed to get random reviewedType: " + err.Error())
		}

		reportHash, err := helpers.GetNewRandomReportHash(true, reportedType)
		if (err != nil){
			t.Fatal("Failed to get random report hash: " + err.Error())
		}

		if (reportedType == "Profile"){

			profileHash, err := helpers.GetNewRandomProfileHash(false, "", true, false)
			if (err != nil) {
				t.Fatal("Failed to create random profile hash: " + err.Error())
			}

			reportsInfoMap[reportHash] = profileHash[:]

		} else if (reportedType == "Identity"){
		
			randomIdentityHash, err := identity.GetNewRandomIdentityHash(false, "")
			if (err != nil) {
				t.Fatal("Failed to create random identity hash: " + err.Error())
			}

			reportsInfoMap[reportHash] = randomIdentityHash[:]

		} else {

			// reportedType == "Attribute"

			attributeHash, err := helpers.GetNewRandomAttributeHash(false, "", false, false)
			if (err != nil){
				t.Fatal("Failed to get random attribute hash: " + err.Error())
			}

			reportsInfoMap[reportHash] = attributeHash[:]
		}
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetIdentityReportsInfo(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, reportsInfoMap)
	if (err != nil) {
		t.Fatal("Failed to create GetIdentityReportsInfo response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reportsInfoMap_Received, err := serverResponse.ReadServerResponse_GetIdentityReportsInfo(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetIdentityReportsInfo response: " + err.Error())
	}
	if (ableToRead == false) {
		t.Fatal("Failed to read GetIdentityReportsInfo response")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetIdentityReportsInfo response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetIdentityReportsInfo response: Mismatched hostIdentityHash.")
	}

	areEqual := reflect.DeepEqual(reportsInfoMap, reportsInfoMap_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetIdentityReportsInfo response:  mismatched reportsInfoMap")
	}

	//TODO: Add None case

}


func TestCreateAndReadResponse_GetMessageReportsInfo(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}

	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	// Map Structure: Report Hash -> Reported message hash
	reportsInfoMap := make(map[[30]byte][26]byte)

	for i:=0; i<1000; i++{

		reportHash, err := helpers.GetNewRandomReportHash(true, "Message")
		if (err != nil){
			t.Fatal("GetNewRandomReportHash failed: " + err.Error())
		}

		messageHash, err := helpers.GetNewRandomMessageHash()
		if (err != nil){
			t.Fatal("GetNewRandomMessageHash failed: " + err.Error())
		}

		reportsInfoMap[reportHash] = messageHash
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetMessageReportsInfo(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, reportsInfoMap)
	if (err != nil) {
		t.Fatal("Failed to create GetMessageReportsInfo response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reportsInfoMap_Received, err := serverResponse.ReadServerResponse_GetMessageReportsInfo(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetMessageReportsInfo response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetMessageReportsInfo response")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetMessageReportsInfo response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetMessageReportsInfo response: Mismatched hostIdentityHash.")
	}

	areEqual := maps.Equal(reportsInfoMap, reportsInfoMap_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetMessageReportsInfo response:  mismatched reportsInfoMap")
	}

	//TODO: Add None case

}


func TestCreateAndReadResponse_GetReports(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}
	
	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	networkType, err := helpers.GetRandomByteWithinRange(1, 2)
	if (err != nil){
		t.Fatal("GetRandomByteWithinRange failed: " + err.Error())
	}

	reportsList := make([][]byte, 0, 10)

	for i:=0; i<10; i++{

		reportType, err := helpers.GetRandomItemFromList([]string{"Profile", "Identity", "Attribute", "Message"})
		if (err != nil) {
			t.Fatal("Cannot get random reportType: " + err.Error())
		}

		fakeReportBytes, err := generate.GetFakeReport(reportType, networkType)
		if (err != nil) {
			t.Fatal("Failed to create fake report: " + err.Error())
		}

		reportsList = append(reportsList, fakeReportBytes)
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetReports(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, reportsList)
	if (err != nil) {
		t.Fatal("Failed to create GetReports response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reportsList_Received, err := serverResponse.ReadServerResponse_GetReports(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetReports response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetReports response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetReports response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetReports response: Mismatched hostIdentityHash.")
	}

	areEqual := reflect.DeepEqual(reportsList, reportsList_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetReports response: mismatched reportsList.")
	}

	// Now we test empty list case

	emptyReportsList := make([][]byte, 0)

	responseBytes, err = serverResponse.CreateServerResponse_GetReports(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, emptyReportsList)
	if (err != nil) {
		t.Fatal("Failed to create GetReports response: " + err.Error())
	}
	
	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, reportsList_Received, err = serverResponse.ReadServerResponse_GetReports(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetReports response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetReports response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetReports response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetReports response: Mismatched hostIdentityHash.")
	}

	if (len(reportsList_Received) != 0){
		t.Fatal("Failed to read GetReports response: reports list not empty.")
	}
}


func TestCreateAndReadResponse_GetAddressDeposits(t *testing.T){

	cryptocurrencyNamesList := []string{"Ethereum", "Cardano"}

	for _, cryptocurrencyName := range cryptocurrencyNamesList{

		hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
		if (err != nil) {
			t.Fatal("Failed to create random identity keys: " + err.Error())
		}

		hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
		if (err != nil) {
			t.Fatal("Failed to get host identity hash: " + err.Error())
		}

		connectionKey, err := getNewRandomConnectionKey()
		if (err != nil) {
			t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
		}

		requestIdentifier, err := getNewRandomRequestIdentifier()
		if (err != nil) {
			t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
		}

		addressDepositObjectsList := make([]serverResponse.DepositStruct, 0, 10)

		for i:=0; i<10; i++{

			getNewAddress := func()(string, error){

				if (cryptocurrencyName == "Ethereum"){

					newAddress, err := ethereumAddress.GetNewRandomEthereumAddress()
					if (err != nil) {
						return "", errors.New("Failed to create random ethereum address: " + err.Error())
					}

					return newAddress, nil
				}

				// cryptocurrencyName == "Cardano"

				newAddress, err := cardanoAddress.GetNewRandomCardanoAddress()
				if (err != nil) {
					return "", errors.New("Failed to create random Cardano address: " + err.Error())
				}

				return newAddress, nil
			}

			newAddress, err := getNewAddress()
			if (err != nil){
				t.Fatal(err.Error())
			}

			depositTime := time.Now().Unix()

			depositAmount := helpers.GetRandomIntWithinRange(10, 100000)

			depositObject := serverResponse.DepositStruct{
				Address: newAddress,
				DepositTime: depositTime,
				DepositAmount: int64(depositAmount),
			}

			addressDepositObjectsList = append(addressDepositObjectsList, depositObject)
		}

		responseBytes, err := serverResponse.CreateServerResponse_GetAddressDeposits(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, addressDepositObjectsList)
		if (err != nil) {
			t.Fatal("Failed to create GetAddressDeposits response: " + err.Error())
		}

		ableToRead, requestIdentifier_Received, hostIdentityHash_Received, addressDepositObjectsList_Received, err := serverResponse.ReadServerResponse_GetAddressDeposits(responseBytes, connectionKey)
		if (err != nil) {
			t.Fatal("Failed to read GetAddressDeposits response: " + err.Error())
		}	
		if (ableToRead == false) {
			t.Fatal("Failed to read GetAddressDeposits response.")
		}

		if (requestIdentifier_Received != requestIdentifier){
			t.Fatal("Failed to read GetAddressDeposits response: mismatched requestIdentifier.")
		}
		if (hostIdentityHash_Received != hostIdentityHash){
			t.Fatal("Failed to read GetAddressDeposits response: Mismatched hostIdentityHash.")
		}

		areEqual := slices.Equal(addressDepositObjectsList, addressDepositObjectsList_Received)
		if (areEqual == false){
			t.Fatal("Failed to read GetAddressDeposits response: Received addressDepositsObjectsList does not match original.")
		}
	}

	//TODO: Add None case
}


func TestCreateAndReadResponse_GetViewableStatuses(t *testing.T){

	hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
	if (err != nil) {
		t.Fatal("Failed to create random identity keys: " + err.Error())
	}

	hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
	if (err != nil) {
		t.Fatal("Failed to get host identity hash: " + err.Error())
	}
	
	connectionKey, err := getNewRandomConnectionKey()
	if (err != nil) {
		t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
	}

	requestIdentifier, err := getNewRandomRequestIdentifier()
	if (err != nil) {
		t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
	}

	identityHashStatusesMap := make(map[[16]byte]bool)
	profileHashStatusesMap := make(map[[28]byte]bool)

	for i:=0; i<100; i++{

		contentIsViewableBool := helpers.GetRandomBool()

		randomBool := helpers.GetRandomBool()
		if (randomBool == true){
	
			userIdentityHash, err := identity.GetNewRandomIdentityHash(false, "")
			if (err != nil) {
				t.Fatal("Failed to create random identity hash: " + err.Error())
			}
			
			identityHashStatusesMap[userIdentityHash] = contentIsViewableBool

		} else {
			
			newProfileHash, err := helpers.GetNewRandomProfileHash(false, "", true, false)
			if (err != nil) {
				t.Fatal("Failed to create random profile hash: " + err.Error())
			}

			profileHashStatusesMap[newProfileHash] = contentIsViewableBool
		}
	}

	responseBytes, err := serverResponse.CreateServerResponse_GetViewableStatuses(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, identityHashStatusesMap, profileHashStatusesMap)
	if (err != nil) {
		t.Fatal("Failed to create GetViewableStatuses response: " + err.Error())
	}

	ableToRead, requestIdentifier_Received, hostIdentityHash_Received, identityHashStatusesMap_Received, profileHashStatusesMap_Received, err := serverResponse.ReadServerResponse_GetViewableStatuses(responseBytes, connectionKey)
	if (err != nil) {
		t.Fatal("Failed to read GetViewableStatuses response: " + err.Error())
	}	
	if (ableToRead == false) {
		t.Fatal("Failed to read GetViewableStatuses response.")
	}

	if (requestIdentifier_Received != requestIdentifier){
		t.Fatal("Failed to read GetViewableStatuses response: mismatched requestIdentifier.")
	}
	if (hostIdentityHash_Received != hostIdentityHash){
		t.Fatal("Failed to read GetViewableStatuses response: Mismatched hostIdentityHash.")
	}

	areEqual := maps.Equal(identityHashStatusesMap, identityHashStatusesMap_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetViewableStatuses response: mismatched identityHashStatusesMap")
	}

	areEqual = maps.Equal(profileHashStatusesMap, profileHashStatusesMap_Received)
	if (areEqual == false){
		t.Fatal("Failed to read GetViewableStatuses response: mismatched profileHashStatusesMap")
	}

	//TODO: Add None case

}



func TestCreateAndReadResponse_BroadcastContent(t *testing.T){

	contentTypesList := []string{"Profile", "Message", "Review", "Report", "Parameters"}

	for _, contentType := range contentTypesList{

		hostPublicIdentityKey, hostPrivateIdentityKey, err := identity.GetNewRandomPublicPrivateIdentityKeys()
		if (err != nil) {
			t.Fatal("Failed to create random identity keys: " + err.Error())
		}

		hostIdentityHash, err := identity.ConvertIdentityKeyToIdentityHash(hostPublicIdentityKey, "Host")
		if (err != nil) {
			t.Fatal("Failed to get host identity hash: " + err.Error())
		}

		connectionKey, err := getNewRandomConnectionKey()
		if (err != nil) {
			t.Fatal("getNewRandomConnectionKey failed: " + err.Error())
		}

		requestIdentifier, err := getNewRandomRequestIdentifier()
		if (err != nil) {
			t.Fatal("getNewRandomRequestIdentifier failed: " + err.Error())
		}

		contentAcceptedInfoMap := make(map[string]bool)

		for i:=0; i<100; i++{

			getRandomContentHash := func()([]byte, error){

				if (contentType == "Profile"){
					randomProfileHash, err := helpers.GetNewRandomProfileHash(false, "", false, false)
					if (err != nil) { return nil, err }

					return randomProfileHash[:], nil
				}
				if (contentType == "Message"){

					randomMessageHash, err := helpers.GetNewRandomMessageHash()
					if (err != nil){ return nil, err }

					return randomMessageHash[:], nil
				}
				if (contentType == "Review"){

					randomReviewHash, err := helpers.GetNewRandomReviewHash(false, "")
					if (err != nil) { return nil, err }

					return randomReviewHash[:], nil
				}
				if (contentType == "Report"){

					randomReportHash, err := helpers.GetNewRandomReportHash(false, "")
					if (err != nil) { return nil, err }

					return randomReportHash[:], nil
				}
				// contentType == "Parameters"

				randomParametersHash, err := helpers.GetNewRandomParametersHash()
				if (err != nil) { return nil, err }
			
				return randomParametersHash[:], nil
			}

			randomContentHash, err := getRandomContentHash()
			if (err != nil) {
				t.Fatal("Failed to get random content hash: " + err.Error())
			}

			randomBool := helpers.GetRandomBool()

			contentAcceptedInfoMap[string(randomContentHash)] = randomBool
		}

		responseBytes, err := serverResponse.CreateServerResponse_BroadcastContent(hostPublicIdentityKey, hostPrivateIdentityKey, connectionKey, requestIdentifier, contentAcceptedInfoMap)
		if (err != nil) {
			t.Fatal("Failed to create BroadcastContent response: " + err.Error())
		}

		ableToRead, requestIdentifier_Received, hostIdentityHash_Received, contentAcceptedInfoMap_Received, err := serverResponse.ReadServerResponse_BroadcastContent(responseBytes, connectionKey)
		if (err != nil) {
			t.Fatal("Failed to read BroadcastContent response: " + err.Error())
		}	
		if (ableToRead == false) {
			t.Fatal("Failed to read BroadcastContent response.")
		}

		if (requestIdentifier_Received != requestIdentifier){
			t.Fatal("Failed to read BroadcastContent response: mismatched requestIdentifier.")
		}
		if (hostIdentityHash_Received != hostIdentityHash){
			t.Fatal("Failed to read BroadcastContent response: Mismatched hostIdentityHash.")
		}

		areEqual := maps.Equal(contentAcceptedInfoMap, contentAcceptedInfoMap_Received)
		if (areEqual == false){
			t.Fatal("Failed to read BroadcastContent response: mismatched contentAcceptedInfoMap")
		}

		//TODO: Add None case

	}

}

