package miner

import (
	"testing"
)

func TestHashMeetsTargetEqual(t *testing.T) {
	target := "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
	hash := "0000000000000000000000000000000000000000000000000000000000000001"
	if !hashMeetsTarget(hash, target) {
		t.Fatal("lower hash should meet high target")
	}
}

func TestHashMeetsTargetReject(t *testing.T) {
	target := "0000000000000000000000000000000000000000000000000000000000000001"
	hash := "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
	if hashMeetsTarget(hash, target) {
		t.Fatal("high hash should not meet low target")
	}
}

func TestDifficultyToTargetHex(t *testing.T) {
	out := difficultyToTargetHex(1000)
	if len(out) != 64 {
		t.Fatalf("expected 64 hex chars, got %d", len(out))
	}
}
