-
Notifications
You must be signed in to change notification settings - Fork 429
Open
Description
Description
There is an issue where realm packages cannot be deployed when the "testing" package is imported in regular source code (not test files).
For example, assume we created a test helper package as follows:
// PATH: r/testutils/logger.gno
package testutils
import "testing"
func PrintLog(t *testing.T, msg string) {
t.Helper()
println(msg)
}
When deploying this package, the following error occurs:
# Run chain
cd gno.land
make fclean && make start.gnoland
# Deploy package
gnokey maketx addpkg -pkgdir path/to/root/r/testutils -pkgpath gno.land/r/testuils -insecure-password-stdin=true -remote localhost:26657 -broadcast=true -chainid dev -gas-fee 100000000ugnot -gas-wanted 100000000
Output:
Enter password.
TX HASH:
INFO: vm.version=develop
--= Error =--
Data: invalid gno package; type check errors:
gno.land/r/testutils.gno:5:2: could not import testing (unknown import path "testing")
Msg Traces:
0 /Users/notJoon/gno-core/tm2/pkg/errors/errors.go:28 - deliver transaction failed: log:msg:0,success:false,log:--= Error =--
Data: vm.TypeCheckError{abciError:vm.abciError{}, Errors:[]string{"gno.land/r/testutils.gno:5:2: could not import testing (unknown import path \"testing\")"}}
Msg Traces:
...
I believe this issue occurs because after the MemPackageType
type was added, test files and regular source code are now clearly separated, and during the deployment process, there's a type mismatch with the expected type.
gno/gnovm/pkg/gnolang/mempackage.go
Lines 409 to 425 in 5e6bf29
type MemPackageType string | |
const ( | |
MPAnyAll MemPackageType = "MPAnyAll" // MPUserAll or MPStdlibAll. | |
MPAnyProd MemPackageType = "MPAnyProd" // MPUserProd or MPStdlibProd. | |
MPAnyTest MemPackageType = "MPAnyTest" // MPUserTest or MPStdlibTest. | |
MPAnyIntegration MemPackageType = "MPAnyIntegration" // MPUserIntegration or MPStdlibIntegration. | |
MPStdlibAll MemPackageType = "MPStdlibAll" // stdlibs only, all files. | |
MPStdlibProd MemPackageType = "MPStdlibProd" // stdlibs only, no tests/filetests | |
MPStdlibTest MemPackageType = "MPStdlibTest" // stdlibs only, w/ tests, w/o integration/filetests | |
MPStdlibIntegration MemPackageType = "MPStdlibIntegration" // stdlibs only, only integration tests. | |
MPUserAll MemPackageType = "MPUserAll" // no stdlibs, gno pkg path, w/ tests/filetests. | |
MPUserProd MemPackageType = "MPUserProd" // no stdlibs, gno pkg path, no tests/filetests. | |
MPUserTest MemPackageType = "MPUserTest" // no stdlibs, gno pkg path, w/ tests, w/o integration/filetests. | |
MPUserIntegration MemPackageType = "MPUserIntegration" // no stdlibs, only integration tests. | |
MPFiletests MemPackageType = "MPFiletests" // filetests only, regardless of file name (tests/files). | |
) |
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Triage