Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsy committed Oct 27, 2024
1 parent c85b6ae commit ff7e012
Show file tree
Hide file tree
Showing 4 changed files with 346 additions and 10 deletions.
18 changes: 9 additions & 9 deletions gno.land/cmd/gnoland/testdata/ghverify.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ loadpkg gno.land/r/gnoland/ghverify
gnoland start

# make a verification request
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func RequestVerification -args 'deelawn' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func RequestVerification -args 'deelawn' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# request tasks to complete (this is done by the agent)
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GnorkleEntrypoint -args 'request' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GnorkleEntrypoint -args 'request' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout '\("\[\{\\"id\\":\\"g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5\\",\\"type\\":\\"0\\",\\"value_type\\":\\"string\\",\\"tasks\\":\[\{\\"gno_address\\":\\"g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5\\",\\"github_handle\\":\\"deelawn\\"\}\]\}\]" string\)'

# a verification request was made but there should be no verified address
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetHandleByAddress -args 'g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetHandleByAddress -args 'g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout ""

# a verification request was made but there should be no verified handle
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetAddressByHandle -args 'deelawn' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetAddressByHandle -args 'deelawn' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout ""

# fail on ingestion with a bad task ID
! gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GnorkleEntrypoint -args 'ingest,a' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
! gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GnorkleEntrypoint -args 'ingest,a' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stderr 'invalid ingest id: a'

# the agent publishes their response to the task and the verification is complete
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GnorkleEntrypoint -args 'ingest,g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5,OK' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GnorkleEntrypoint -args 'ingest,g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5,OK' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout OK!

# get verified github handle by gno address
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetHandleByAddress -args 'g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetHandleByAddress -args 'g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout "deelawn"

# get verified gno address by github handle
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetAddressByHandle -args 'deelawn' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func GetAddressByHandle -args 'deelawn' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"

gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func Render -args '' -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/gnoland/ghverify -func Render -args '' -gas-fee 1000000ugnot -gas-wanted 4000000 -broadcast -chainid=tendermint_test test1
stdout '\("\{\\"deelawn\\": \\"g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5\\"\}" string\)'
1 change: 0 additions & 1 deletion gnovm/pkg/gnolang/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ func (rlm *Realm) decRefDeletedDescendants(store Store, oo Object) {
rlm.decRefDeletedDescendants(store, child)
} else if rc > 0 {
rlm.MarkDirty(child)

Check warning on line 515 in gnovm/pkg/gnolang/realm.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/realm.go#L515

Added line #L515 was not covered by tests
// do nothing
} else {
panic("deleted descendants should not have a reference count of less than zero")
}
Expand Down
95 changes: 95 additions & 0 deletions gnovm/tests/files/zrealm16.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// PKGPATH: gno.land/r/test
package test

var (
a = &A{A: "here"}
a2 = &A{A: "here"}
b [2]*B
)

type A struct {
A string
}
type B struct {
A *A
B string
}

func init() {
c := B{
A: a,
B: "c",
}
b[0] = &c

d := B{
A: a,
B: "d",
}
b[1] = &d
}

func main() {
b[0].A = a2
}

// Realm:
// switchrealm["gno.land/r/test"]
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:10]={
// "Fields": [
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.A"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Escaped": true,
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5"
// },
// "Index": "0",
// "TV": null
// }
// },
// {
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "16"
// },
// "V": {
// "@type": "/gno.StringValue",
// "value": "c"
// }
// }
// ],
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10",
// "ModTime": "11",
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9",
// "RefCount": "1"
// }
// }
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:3]={
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3",
// "IsEscaped": true,
// "ModTime": "11",
// "RefCount": "2"
// },
// "Value": {
// "T": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.A"
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "95dca2f5b12899b6367402ecdac04c7ca59a03d9",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4"
// }
// }
// }
242 changes: 242 additions & 0 deletions gnovm/tests/files/zrealm17.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
// PKGPATH: gno.land/r/test
package test

var (
a = &A{A: "here"}
a2 = &A{A: "here"}
b [2]*B
)

type A struct {
A string
}
type B struct {
A *A
B string
}

func init() {
c := B{
A: a,
B: "c",
}
b[0] = &c

d := B{
A: a,
B: "d",
}
b[1] = &d
}

func main() {
b[0] = nil
b[1] = nil
}

// Realm:
// switchrealm["gno.land/r/test"]
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:7]={
// "Data": null,
// "List": [
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.B"
// }
// }
// },
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.B"
// }
// }
// }
// ],
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7",
// "ModTime": "11",
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2",
// "RefCount": "1"
// }
// }
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:10]={
// "Fields": [
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.A"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Escaped": true,
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3"
// },
// "Index": "0",
// "TV": null
// }
// },
// {
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "16"
// },
// "V": {
// "@type": "/gno.StringValue",
// "value": "c"
// }
// }
// ],
// "ObjectInfo": {
// "Hash": "eb2a077c834c2611affad67bdeddfb4d481d0947",
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10",
// "ModTime": "0",
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9",
// "RefCount": "0"
// }
// }
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:11]={
// "Fields": [
// {
// "T": {
// "@type": "/gno.PointerType",
// "Elt": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.A"
// }
// },
// "V": {
// "@type": "/gno.PointerValue",
// "Base": {
// "@type": "/gno.RefValue",
// "Escaped": true,
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3"
// },
// "Index": "0",
// "TV": null
// }
// },
// {
// "T": {
// "@type": "/gno.PrimitiveType",
// "value": "16"
// },
// "V": {
// "@type": "/gno.StringValue",
// "value": "d"
// }
// }
// ],
// "ObjectInfo": {
// "Hash": "3e711a4eade7634fe616a9b66646034f1d28dafc",
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:11",
// "ModTime": "0",
// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9",
// "RefCount": "0"
// }
// }
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:9]={
// "Blank": {},
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9",
// "IsEscaped": true,
// "ModTime": "11",
// "RefCount": "0"
// },
// "Parent": {
// "@type": "/gno.RefValue",
// "Escaped": true,
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8"
// },
// "Source": {
// "@type": "/gno.RefNode",
// "BlockNode": null,
// "Location": {
// "Column": "1",
// "File": "main.gno",
// "Line": "18",
// "PkgPath": "gno.land/r/test"
// }
// },
// "Values": [
// {
// "T": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.B"
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "3316460f1bfec49fce2aaf28a28277b12b1f5f15",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:10"
// }
// },
// {
// "T": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.B"
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "8cc8f6bfb70f530e2024a48391f7a1a697d1e65f",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:11"
// }
// }
// ]
// }
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:3]={
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3",
// "IsEscaped": true,
// "ModTime": "11",
// "RefCount": "1"
// },
// "Value": {
// "T": {
// "@type": "/gno.RefType",
// "ID": "gno.land/r/test.A"
// },
// "V": {
// "@type": "/gno.RefValue",
// "Hash": "95dca2f5b12899b6367402ecdac04c7ca59a03d9",
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4"
// }
// }
// }
// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:8]={
// "Blank": {},
// "ObjectInfo": {
// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8",
// "IsEscaped": true,
// "ModTime": "11",
// "RefCount": "3"
// },
// "Parent": {
// "@type": "/gno.RefValue",
// "Escaped": true,
// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2"
// },
// "Source": {
// "@type": "/gno.RefNode",
// "BlockNode": null,
// "Location": {
// "Column": "1",
// "File": "main.gno",
// "Line": "2",
// "PkgPath": "gno.land/r/test"
// }
// },
// "Values": []
// }
// d[a8ada09dee16d791fd406d629fe29bb0ed084a30:9]
// d[a8ada09dee16d791fd406d629fe29bb0ed084a30:10]
// d[a8ada09dee16d791fd406d629fe29bb0ed084a30:11]

0 comments on commit ff7e012

Please sign in to comment.