templates.test_onchain_views_not_found

 1import smartpy as sp
 2
 3
 4@sp.module
 5def main():
 6    class Test(sp.Contract):
 7        def __init__(self):
 8            self.data.value = 0
 9
10        @sp.offchain_view()
11        def other(self, x):
12            return 1 + x
13
14
15if "main" in __name__:
16
17    @sp.add_test()
18    def test2():
19        scenario = sp.test_scenario("Test")
20        scenario.add_module(main)
21        provider = sp.address("KT1")
22        scenario.verify(sp.view("a_view", provider, 0, t=sp.nat) == None)
23        c1 = main.Test()
24        scenario += c1
25        scenario.verify(c1.other(42) == 43)
26        scenario.verify(sp.view("other", c1.address, 1, t=sp.int_or_nat) == sp.Some(2))
27        scenario.verify(sp.view("other", c1.address, 1) == sp.Some(2))
28        scenario.verify(sp.view("missing_view", c1.address, 1) == None)
29        scenario.verify(sp.view("other", c1.address, 1, t=sp.int) == sp.Some(2))
30        scenario.verify(sp.view("other", c1.address, 1, t=sp.nat) == None)