package inventory import ( "context" "testing" "github.com/novox/mesh-controller/internal/chain" ) // The first read of a chain that requires the layout lays the builds out itself when it may write, instead of refusing // the controller's own start (issue 1121, 2026-10-18: the controller exited every five seconds). func TestTheFirstReadOfAChainNotLaidOutLaysItOut(t *testing.T) { ctx := context.Background() inv, c := anInventoryOnTheChain(t) inv.RequireLayout() if _, found, _ := c.Builds.GetRaw(ctx, chain.LayoutMarkerKey); found { t.Fatal("a fresh chain holds the marker already; the test proves nothing") } if _, err := inv.theChain(ctx); err != nil { t.Fatalf("the first read was refused: %v", err) } if _, found, err := c.Builds.GetRaw(ctx, chain.LayoutMarkerKey); err != nil || !found { t.Fatalf("the read did not lay the builds out: found %v, %v", found, err) } }