package main

import (
	"testing"
	"testing/synctest"
	"time"
)

func TestRejectColdboot(t *testing.T) {
	t.Parallel()

	synctest.Test(t, func(t *testing.T) {
		nextColdboot := newRejectColdboot()
		want := func(want bool) {
			if got := nextColdboot(); got != want {
				t.Fatalf("nextColdboot: %v, want %v", got, want)
			}
		}

		synctest.Wait()
		want(true)
		time.Sleep(time.Hour)
		synctest.Wait()
		want(true)
		want(true)
		time.Sleep(5 * time.Minute)
		synctest.Wait()
		want(true)
		want(false)
		time.Sleep(time.Hour)
		synctest.Wait()
		want(false)
		want(false)
	})
}
