1# Check DFS, calling other contracts - Example for illustrative purposes only.
2
3import smartpy as sp
4
5
6@sp.module
7def main():
8 class Check_dfs(sp.Contract):
9 def __init__(self):
10 self.data.steps = ""
11 self.data.conclusion = ""
12
13 @sp.entrypoint
14 def a(self):
15 self.data.steps += ".a"
16 sp.transfer((), sp.mutez(0), sp.self_entrypoint("aa"))
17
18 @sp.entrypoint
19 def aa(self):
20 self.data.steps += ".aa"
21
22 @sp.entrypoint
23 def b(self):
24 self.data.steps += ".b"
25 if self.data.steps == "check.a.b":
26 self.data.conclusion = "BFS"
27 else:
28 self.data.conclusion = "DFS"
29
30 @sp.entrypoint
31 def check(self):
32 self.data.steps = "check"
33 self.data.conclusion = ""
34 sp.transfer((), sp.mutez(0), sp.self_entrypoint("a"))
35 sp.transfer((), sp.mutez(0), sp.self_entrypoint("b"))
36
37
38@sp.add_test()
39def test():
40 scenario = sp.test_scenario("dfs", main)
41 scenario.h2("Depth first")
42 check_dfs = main.Check_dfs()
43 scenario += check_dfs
44 check_dfs.check()
45 scenario.verify(check_dfs.data.conclusion == "DFS")