Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Villaquiranm committed Jul 1, 2024
1 parent 3c140af commit fb3e1f8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions gnovm/pkg/gnolang/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,14 @@ func isUnsaved(oo Object) bool {
return oo.GetIsNewReal() || oo.GetIsDirty()
}

// pkgPathPrefix is the prefix used to identify pkgpaths which are meant to
// be pure packages. This is used by [IsPkgPath].
const pkgPathPrefix = "gno.land/p/"

func IsPkgPath(pkgPath string) bool {
return strings.HasPrefix(pkgPath, pkgPathPrefix)
}

func prettyJSON(jstr []byte) []byte {
var c interface{}
err := json.Unmarshal(jstr, &c)
Expand Down
5 changes: 5 additions & 0 deletions gnovm/pkg/gnolang/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,11 @@ func (pv *PackageValue) IsRealm() bool {
return IsRealmPath(pv.PkgPath)
}

// IsPkgPath returns true if pv represents a package path.
func (pv *PackageValue) IsPkgPath() bool {
return IsPkgPath(pv.PkgPath)
}

func (pv *PackageValue) getFBlocksMap() map[Name]*Block {
if pv.fBlocksMap == nil {
pv.fBlocksMap = make(map[Name]*Block, len(pv.FNames))
Expand Down
1 change: 1 addition & 0 deletions gnovm/stdlibs/native.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gnovm/stdlibs/std/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func X_decodeBech32(addr string) (prefix string, bytes [20]byte, ok bool) {

func X_assertCallerIsRealm(m *gno.Machine) {
frame := m.Frames[m.NumFrames()-2]
if !frame.LastPackage.IsRealm() {
if frame.LastPackage.IsPkgPath() {
m.Panic(typedString("caller is not a realm"))
}
}
Expand Down
1 change: 1 addition & 0 deletions gnovm/tests/stdlibs/native.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb3e1f8

Please sign in to comment.