sherlock_regress_test.gno
2.03 Kb · 54 lines
1package game31
2
3import (
4 "strings"
5 "testing"
6 "time"
7)
8
9// Sherlock's 4 main-tree exploit probes (SHERLOCK_REPORT §4), inverted:
10// each must now be refused by the single game29 realm.
11
12func TestSherlockH1aBankAndFreePass_Closed(cur realm, t *testing.T) {
13 setup()
14 bot := ta("sherlock-bot")
15 testing.SetRealm(testing.NewUserRealm(bot))
16 exp := time.Now().Unix() + 300
17 mustAbort(t, "unsigned bank claim", revive(func() { ClaimAndMint(cross(cur), `[["grin","1000"]]`, 1, exp, "") }), "")
18 mustAbort(t, "forged bank claim", revive(func() { ClaimAndMint(cross(cur), `[["grin","1000"]]`, 1, exp, strings.Repeat("ab", 64)) }), "")
19 mustAbort(t, "free pass", revive(func() { ActivateGnomePass(cross(cur), 3650) }), "")
20 if strings.Contains(AllBalances(bot.String()), "grin") || HasActivePass(bot.String()) {
21 t.Errorf("H1a open: %s", AllBalances(bot.String()))
22 }
23}
24
25func TestSherlockN1ForgedMedal_Closed(cur realm, t *testing.T) {
26 setup()
27 bot := ta("sherlock-n1")
28 testing.SetRealm(testing.NewUserRealm(bot))
29 mustAbort(t, "forged medal", revive(func() { ClaimAchievement(cross(cur), "made-up-medal", 1, time.Now().Unix()+300, "") }), "")
30 if strings.Contains(GetMedals(bot.String()), "made-up-medal") {
31 t.Errorf("N1 open")
32 }
33}
34
35func TestSherlockH2bCommitOverwrite_Closed(cur realm, t *testing.T) {
36 setup()
37 bot := ta("sherlock-h2b")
38 testing.SetRealm(testing.NewUserRealm(bot))
39 mustAbort(t, "commit on missing lobby", revive(func() { CommitPvpMove(cross(cur), "no-such-lobby", "aaaa") }), "")
40}
41
42func TestSherlockH1fSybil_Closed(cur realm, t *testing.T) {
43 setup()
44 main := ta("sherlock-main")
45 for _, n := range []string{"s1", "s2", "s3"} {
46 a := ta("sherlock-" + n)
47 testing.SetRealm(testing.NewUserRealm(a))
48 mustAbort(t, "sybil claim", revive(func() { ClaimAndMint(cross(cur), `[["grin","1000"]]`, 1, time.Now().Unix()+300, "") }), "")
49 mustAbort(t, "sybil transfer", revive(func() { Transfer(cross(cur), "grin", main.String(), "1000") }), "")
50 }
51 if strings.Contains(AllBalances(main.String()), "grin") {
52 t.Errorf("H1f open: %s", AllBalances(main.String()))
53 }
54}