Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

Playground

counter.gno

package counter

import "strconv"

var counter int

func Increment(_ realm) int {
	counter++
	return counter
}

func Render(_ string) string {
	return strconv.Itoa(counter)
}

counter_test.gno

package counter

import "testing"

func TestIncrement(cur realm, t *testing.T) {
	counter = 0
	val := Increment(cross(cur))
	if val != 1 {
		t.Fatalf("result from Increment(): %d != 1", val)
	}
	if counter != val {
		t.Fatalf("counter (%d) != val (%d)", counter, val)
	}
}

func TestRender(t *testing.T) {
	counter = 1337
	res := Render("")
	if res != "1337" {
		t.Fatalf("render result %q != %q", res, "1337")
	}
}

gnomod.toml

module = "gno.land/r/g13v0akxftts4jk0cq55ch4u6yp3hyzn89h4xv7j/counter"
gno = "0.9"

[addpkg]
  creator = "g13v0akxftts4jk0cq55ch4u6yp3hyzn89h4xv7j"
  height = 1342616
  max_deposit = "100000000ugnot"