package seedPhrase_test

import "seekia/internal/seedPhrase"

import "testing"


func TestSeedPhraseFunctions(t *testing.T){

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

		randomSeedPhrase, _, err := seedPhrase.GetNewRandomSeedPhrase("English")
		if (err != nil){
			t.Fatal("GetNewRandomSeedPhrase failed: " + err.Error())
		}

		isValid := seedPhrase.VerifySeedPhrase(randomSeedPhrase)
		if (isValid == false){
			t.Fatal("GetNewRandomSeedPhrase returning invalid seed phrase: " + randomSeedPhrase)
		}
	}

	testPhrase := "mention kitten rival rice minute follow problem sense december vicious unit silk limit odor quarter"

	seedPhraseHash, err := seedPhrase.ConvertSeedPhraseToSeedPhraseHash(testPhrase)
	if (err != nil){
		t.Fatal("ConvertSeedPhraseToSeedPhraseHash failed: " + err.Error())
	}

	expectedSeedPhraseHash := [32]byte{71, 29, 32, 59, 153, 84, 251, 93, 180, 116, 220, 228, 127, 229, 228, 132, 158, 62, 177, 9, 117, 139, 119, 216, 221, 204, 26, 233, 113, 71, 151, 134}

	if (seedPhraseHash != expectedSeedPhraseHash){
		t.Fatal("ConvertSeedPhraseToSeedPhraseHash returning unexpected seed phrase hash.")
	}
}
