/ test / contracts / sophia_2 / simple_auth_fail.aes
simple_auth_fail.aes
 1  contract Remote =
 2    function main_ : (int) => int
 3  
 4  contract Auth1 =
 5    record state = { secret : int }
 6  
 7    datatype auth_test = Spend(address, int)
 8                       | OracleReg
 9                       | RemoteCall(Remote)
10  
11    function init(s : int) = { secret = s }
12  
13    function authorize(s : int, x : int) : bool =
14      state.secret == s
15  
16    stateful function do_auth_test(at : auth_test) : bool =
17      switch(at)
18        Spend(to, tokens) =>
19          Chain.spend(to, tokens)
20        OracleReg         =>
21          Oracle.register(Contract.address, 12345, RelativeTTL(1000)) : oracle(int, int)
22          ()
23        RemoteCall(r)     =>
24          r.main_(42)
25          ()
26      true
27