Download this file
| 1 | package host |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "github.com/carlosframework/platform/internal/release" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestPlan14RootHistoryMintUsesRootInventory(t *testing.T) { |
| 10 | if !plan14RootFixture(t) { |
| 11 | return |
| 12 | } |
| 13 | if legacy, err := legacyRootRestart(); err != nil || !legacy { |
| 14 | t.Fatalf("expected a box without a census: legacy=%v error=%v", legacy, err) |
| 15 | } |
| 16 | e, _, _, _ := plan14ProofFixture(t) |
| 17 | h := &release.RootHistory{Store: &rollbackMemory{files: map[string][]byte{}}} |
| 18 | e.root.refusals = h.MintRefusals |
| 19 | e.root.mintCensus = func() (bool, error) { |
| 20 | legacy, err := legacyRootRestart() |
| 21 | return !legacy && err == nil, err |
| 22 | } |
| 23 | for pass := 1; pass <= 2; pass++ { |
| 24 | e.root.run(context.Background()) |
| 25 | if e.proof(t) != nil { |
| 26 | t.Fatal("minted without a census") |
| 27 | } |
| 28 | pauses := 0 |
| 29 | for _, line := range e.logs { |
| 30 | if line == "proof: minting paused until this box has a root census" { |
| 31 | pauses++ |
| 32 | } |
| 33 | } |
| 34 | if pauses != pass { |
| 35 | t.Fatalf("pause logged %d times after %d passes: %v", pauses, pass, e.logs) |
| 36 | } |
| 37 | } |
| 38 | if len(release.ReadHealthy(e.root.historyDir(), "bab", "console")) != 1 { |
| 39 | t.Fatal("mint pause suppressed health") |
| 40 | } |
| 41 | } |
| 42 | |