// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJNStableStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJN.StableStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJNStableStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationStableStateLedgerContract Contract;
	TestTrue(
		TEXT("The validation stable-state ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationStableStateLedgerContract(
			TEXT("validation-stable-state-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation stable-state ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-stable-state-ledger-contract")
	);
	TestTrue(
		TEXT("The validation stable-state ledger contract must preserve benchmark-drift stable ledger entries."),
		Contract.LedgerEntryIds.Contains(TEXT("stable-ledger/benchmark-drift-stable"))
	);
	TestTrue(
		TEXT("The validation stable-state ledger contract must preserve the bounded stable-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded stable-state ledger"))
	);
	TestTrue(
		TEXT("The validation stable-state ledger contract must preserve the no-generic-state-ledger-platform guard."),
		Contract.StabilityGuardTags.Contains(TEXT("no-generic-state-ledger-platform guard"))
	);
	TestTrue(
		TEXT("The validation stable-state ledger contract must keep generic state-ledger platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic state-ledger platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJNContinuationStateDigestBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJN.ContinuationStateDigests",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJNContinuationStateDigestBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationContinuationStateDigestBoundary Boundary;
	TestTrue(
		TEXT("The validation continuation-state digest boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationContinuationStateDigestBoundary(
			TEXT("validation-continuation-state-digest-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation continuation-state digest boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-continuation-state-digest-boundary")
	);
	TestTrue(
		TEXT("The validation continuation-state digest boundary must preserve manual-waiver stable digests."),
		Boundary.DigestIds.Contains(TEXT("continuation-state-digest/manual-waiver-stable"))
	);
	TestTrue(
		TEXT("The validation continuation-state digest boundary must preserve the bounded continuation-state digest surface."),
		Boundary.DigestSurfaceTags.Contains(TEXT("bounded continuation-state digest"))
	);
	TestTrue(
		TEXT("The validation continuation-state digest boundary must preserve the no-generic-continuation-digest-platform guard."),
		Boundary.ContinuationDigestGuardTags.Contains(TEXT("no-generic-continuation-digest-platform guard"))
	);
	TestTrue(
		TEXT("The validation continuation-state digest boundary must keep generic continuation digest platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic continuation digest platform ownership"))
	);
	return true;
}

#endif
