-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into grc721Royalty
- Loading branch information
Showing
12 changed files
with
277 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package mapdelete | ||
|
||
var mapus map[uint64]string = make(map[uint64]string) | ||
|
||
func init() { | ||
mapus[3] = "three" | ||
mapus[5] = "five" | ||
mapus[9] = "nine" | ||
} | ||
|
||
func DeleteMap(k uint64) { | ||
delete(mapus, k) | ||
} | ||
|
||
func GetMap(k uint64) bool { | ||
_, exist := mapus[k] | ||
return exist | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package mapdelete | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGetMap(t *testing.T) { | ||
if !(GetMap(3)) { | ||
t.Error("Expected true, got ", GetMap(3)) | ||
} | ||
} | ||
|
||
func TestDeleteMap(t *testing.T) { | ||
DeleteMap(3) | ||
} | ||
|
||
func TestGetMapAfterDelete(t *testing.T) { | ||
if GetMap(3) { | ||
t.Error("Expected false, got ", GetMap(3)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
loadpkg gno.land/r/foobar/bar $WORK/bar | ||
|
||
## start a new node | ||
gnoland start | ||
|
||
# execute Render | ||
gnokey maketx call -pkgpath gno.land/r/foobar/bar -func Render -args X -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
stdout '(" orig=g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 prev=g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5" string)' | ||
stdout 'OK!' | ||
|
||
-- bar/bar.gno -- | ||
package bar | ||
|
||
import "std" | ||
|
||
var orig = std.Address("orig") | ||
var prev = std.Address("prev") | ||
|
||
func init() { | ||
orig = std.GetOrigCaller() | ||
prev = std.PrevRealm().Addr() | ||
} | ||
|
||
func Render(addr string) string { | ||
return " orig="+orig.String()+" prev="+prev.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
gnoland start | ||
|
||
# add contract | ||
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/mapdelete -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
|
||
# delete map | ||
gnokey maketx call -pkgpath gno.land/r/demo/mapdelete -func DeleteMap -args 3 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
|
||
# check deletion | ||
gnokey maketx call -pkgpath gno.land/r/demo/mapdelete -func GetMap -args 3 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
stdout OK! | ||
stdout 'false bool' | ||
# XXX without patching uverse.go, expected stdout is | ||
# stdout 'true bool' | ||
|
||
|
||
|
||
-- gno.mod -- | ||
module gno.land/r/demo/mapdelete | ||
|
||
-- realm.gno -- | ||
package mapdelete | ||
|
||
var mapus map[uint64]string = make(map[uint64]string) | ||
|
||
func init() { | ||
mapus[3] = "three" | ||
mapus[5] = "five" | ||
mapus[9] = "nine" | ||
} | ||
|
||
func DeleteMap(k uint64) { | ||
delete(mapus, k) | ||
} | ||
|
||
func GetMap(k uint64) bool { | ||
_, exist := mapus[k] | ||
return exist | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
type I interface { | ||
dummy() | ||
} | ||
type IS struct{} | ||
|
||
func (iss IS) dummy() { | ||
} | ||
|
||
type S struct { | ||
x int | ||
I | ||
} | ||
|
||
func main() { | ||
m := make(map[S]string) | ||
m[S{0, IS{}}] = "test" | ||
println(m) | ||
} | ||
|
||
// Output: | ||
// map{(struct{(0 int),(struct{} main.IS)} main.S):("test" string)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// PKGPATH: gno.land/r/demo/tests_test | ||
package tests_test | ||
|
||
import ( | ||
"gno.land/r/demo/tests" | ||
"std" | ||
) | ||
|
||
var addr = std.Address("test") | ||
var addrInit = std.Address("addrInit") | ||
|
||
func init() { | ||
addr = std.GetOrigCaller() | ||
addrInit = tests.InitOrigCaller() | ||
} | ||
|
||
func main() { | ||
println(addr) | ||
println(addrInit) | ||
} | ||
|
||
// Output: | ||
// g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm | ||
// g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm | ||
|
||
// Realm: | ||
// switchrealm["gno.land/r/demo/tests_test"] |
Oops, something went wrong.