forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(r/faucet): Render call panic (gnolang#628)
Co-authored-by: Morgan <git@howl.moe> Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
- Loading branch information
1 parent
aa730e3
commit f8231e0
Showing
7 changed files
with
180 additions
and
10 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
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 @@ | ||
package main | ||
|
||
import ( | ||
"gno.land/r/gnoland/faucet" | ||
) | ||
|
||
// assert render with empty path and no controllers | ||
func main() { | ||
println(faucet.Render("")) | ||
} | ||
|
||
// Output: | ||
// # Community Faucet. | ||
// | ||
// Status: active. | ||
// Balance: 200000000ugnot. | ||
// Total transfers: (in 0 times). | ||
// | ||
// Package address: g17rgsdnfxzza0sdfsdma37sdwxagsz378833ca4 | ||
// | ||
// Admin: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 | ||
// | ||
// Controllers: | ||
// | ||
// | ||
// | ||
// Per request limit: 350000000ugnot |
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 @@ | ||
package main | ||
|
||
import ( | ||
"gno.land/r/gnoland/faucet" | ||
) | ||
|
||
// assert render with a path and no controllers | ||
func main() { | ||
println(faucet.Render("path")) | ||
} | ||
|
||
// Output: | ||
// # Community Faucet. | ||
// | ||
// Status: active. | ||
// Balance: 200000000ugnot. | ||
// Total transfers: (in 0 times). | ||
// | ||
// Package address: g17rgsdnfxzza0sdfsdma37sdwxagsz378833ca4 | ||
// | ||
// Admin: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 | ||
// | ||
// Controllers: | ||
// | ||
// | ||
// | ||
// Per request limit: 350000000ugnot |
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,44 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/p/demo/testutils" | ||
"gno.land/r/gnoland/faucet" | ||
) | ||
|
||
// assert render with empty path and 2 controllers | ||
func main() { | ||
var ( | ||
adminaddr = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") | ||
controlleraddr1 = testutils.TestAddress("controller1") | ||
controlleraddr2 = testutils.TestAddress("controller2") | ||
) | ||
std.TestSetOrigCaller(adminaddr) | ||
err := faucet.AdminAddController(controlleraddr1) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = faucet.AdminAddController(controlleraddr2) | ||
if err != nil { | ||
panic(err) | ||
} | ||
println(faucet.Render("")) | ||
} | ||
|
||
// Output: | ||
// # Community Faucet. | ||
// | ||
// Status: active. | ||
// Balance: 200000000ugnot. | ||
// Total transfers: (in 0 times). | ||
// | ||
// Package address: g17rgsdnfxzza0sdfsdma37sdwxagsz378833ca4 | ||
// | ||
// Admin: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 | ||
// | ||
// Controllers: | ||
// | ||
// g1vdhkuarjdakxcetjx9047h6lta047h6lsdacav g1vdhkuarjdakxcetjxf047h6lta047h6lnrev3v | ||
// | ||
// Per request limit: 350000000ugnot |
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,56 @@ | ||
package main | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/p/demo/testutils" | ||
"gno.land/r/gnoland/faucet" | ||
) | ||
|
||
// assert render with 2 controllers and 2 transfers | ||
func main() { | ||
var ( | ||
adminaddr = std.Address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") | ||
controlleraddr1 = testutils.TestAddress("controller1") | ||
controlleraddr2 = testutils.TestAddress("controller2") | ||
testaddr1 = testutils.TestAddress("test1") | ||
testaddr2 = testutils.TestAddress("test2") | ||
) | ||
std.TestSetOrigCaller(adminaddr) | ||
err := faucet.AdminAddController(controlleraddr1) | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = faucet.AdminAddController(controlleraddr2) | ||
if err != nil { | ||
panic(err) | ||
} | ||
std.TestSetOrigCaller(controlleraddr1) | ||
err = faucet.Transfer(testaddr1, 1000000) | ||
if err != nil { | ||
panic(err) | ||
} | ||
std.TestSetOrigCaller(controlleraddr2) | ||
err = faucet.Transfer(testaddr1, 2000000) | ||
if err != nil { | ||
panic(err) | ||
} | ||
println(faucet.Render("")) | ||
} | ||
|
||
// Output: | ||
// # Community Faucet. | ||
// | ||
// Status: active. | ||
// Balance: 197000000ugnot. | ||
// Total transfers: 3000000ugnot (in 2 times). | ||
// | ||
// Package address: g17rgsdnfxzza0sdfsdma37sdwxagsz378833ca4 | ||
// | ||
// Admin: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 | ||
// | ||
// Controllers: | ||
// | ||
// g1vdhkuarjdakxcetjx9047h6lta047h6lsdacav g1vdhkuarjdakxcetjxf047h6lta047h6lnrev3v | ||
// | ||
// Per request limit: 350000000ugnot |
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