From 336edabe3d724a9d3c09f050e969e0c0b2f15e7c Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 22 Jun 2023 14:17:08 +0200 Subject: [PATCH] do not assign id to testmain if it's not a realm --- gnovm/cmd/gno/test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index e6c77817f6a..f2292f80747 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -381,10 +381,13 @@ func runTestFiles( m.RunFiles(files.Files...) n := gno.MustParseFile("testmain.gno", testmain) m.RunFiles(n) - // XXX Affect an ID to testmain so it doesn't trigger a panic when - // realm.FinalizeRealmTransaction() is invoked - oo := m.Package.GetFileBlock(m.Store, n.Name) - m.Realm.AssignNewObjectID(oo) + + if m.Realm != nil { + // XXX Affect an ID to testmain if it's under a realm, so it doesn't + // trigger a panic when realm.FinalizeRealmTransaction() is invoked. + b := m.Package.GetFileBlock(m.Store, n.Name) + m.Realm.AssignNewObjectID(b) + } for _, test := range testFuncs.Tests { if verbose {