package blake3_test

import "seekia/internal/cryptography/blake3"

import "testing"

func TestHashes(t *testing.T) {

	testData := []byte("Seekia:AGeneticsAwareMateDiscoveryNetwork.")

	expectedHashResult := "839d854bcab7e3f2b0d89736542a64bffd9c7b88365e7b53830a6311aba1386b2aa1c3e4a5bb95c3fbf26dde6cb99f375705841072d8cecbbd62ecf179c02564"
	
	hashResult, err := blake3.GetBlake3HashAsHexString(64, testData)
	if (err != nil) {
		t.Fatal("Failed to get 64 byte blake3 hash: " + err.Error())
	}

	if (hashResult != expectedHashResult){
		t.Fatal("Blake3 512 bits hash result is not expected: " + hashResult)
	}


	_, err = blake3.GetBlake3HashAsBase32String(32, testData)
	if (err == nil) {
		t.Fatal("Failed to get correct length error on base32 hash.")
	}

	outputHex, err := blake3.GetBlake3HashAsHexString(16, testData)
	if (err != nil) {
		t.Fatal("Failed to get 16 byte blake3 hash: " + err.Error())
	}
	if (outputHex != "839d854bcab7e3f2b0d89736542a64bf"){
		t.Fatal("16 byte blake3 hash provides invalid output: " + outputHex)
	}
}

