From 17d72f02a126b21ebaa87f9aef6808e4fec56bb9 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 4 Apr 2022 20:11:19 +0300 Subject: [PATCH] use a sync.Once for manifest loading to avoid interference from parallel test runs --- chain/actors/manifest.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chain/actors/manifest.go b/chain/actors/manifest.go index 3c600ecf2..4eecab352 100644 --- a/chain/actors/manifest.go +++ b/chain/actors/manifest.go @@ -2,6 +2,7 @@ package actors import ( "context" + "sync" "golang.org/x/xerrors" @@ -19,12 +20,23 @@ var ManifestCids map[Version]cid.Cid = map[Version]cid.Cid{ var manifests map[Version]*manifest.Manifest var actorMeta map[cid.Cid]actorEntry +var ( + loadOnce sync.Once + loadError error +) + type actorEntry struct { name string version Version } func LoadManifests(ctx context.Context, store cbor.IpldStore) error { + // tests may invoke this concurrently, so we wrap it in a sync.Once + loadOnce.Do(func() { loadError = loadManifests(ctx, store) }) + return loadError +} + +func loadManifests(ctx context.Context, store cbor.IpldStore) error { adtStore := adt.WrapStore(ctx, store) manifests = make(map[Version]*manifest.Manifest)