@@ -36,30 +36,45 @@ test: install
36
36
| grep 'print via non-replicated query' && echo 'PASS'
37
37
38
38
# Test trapped call is recorded in logs.
39
- # Ignore failed call output (so the test continues) and check the logs to contain the message.
40
- -dfx canister call canister_logs trap 'trap via update'
39
+ # Ignore failed dfx command output (so the test continues) and check the logs to contain the message.
40
+ - dfx canister call canister_logs trap 'trap via update'
41
41
dfx canister logs canister_logs \
42
42
| grep 'trap via update' && echo 'PASS'
43
43
44
+ # Test trap via replicated query call.
45
+ # Ignore failed dfx command output (so the test continues) and check the logs to contain the message.
46
+ - dfx canister call --update canister_logs trap_query 'trap via replicated query'
47
+ dfx canister logs canister_logs \
48
+ | grep 'trap via replicated query' && echo 'PASS'
49
+
50
+ # Test trap via non-replicated query call should NOT record the message.
51
+ # Ignore failed dfx command output (so the test continues) and check the logs to contain the message.
52
+ - dfx canister call --query canister_logs trap_query 'trap via non-replicated query'
53
+ ! dfx canister logs canister_logs \
54
+ | grep 'trap via non-replicated query' && echo 'PASS'
55
+
44
56
# Test the call with panic is recorded in logs.
45
- # Ignore failed call output (so the test continues) and check the logs to contain the message.
46
- -dfx canister call canister_logs panic 'panic via update'
57
+ # Ignore failed dfx command output (so the test continues) and check the logs to contain the message.
58
+ - dfx canister call canister_logs panic 'panic via update'
47
59
dfx canister logs canister_logs \
48
60
| grep 'panic via update' && echo 'PASS'
49
61
50
62
# Test call to fail with memory out of bounds.
51
- # Ignore failed call output (so the test continues) and check the logs to contain the message.
52
- -dfx canister call canister_logs memory_oob
63
+ # Ignore failed dfx command output (so the test continues) and check the logs to contain the message.
64
+ - dfx canister call canister_logs memory_oob
53
65
dfx canister logs canister_logs \
54
66
| grep 'stable memory out of bounds' && echo 'PASS'
55
67
56
68
# Test call to fail with failed unwrap.
57
- # Ignore failed call output (so the test continues) and check the logs to contain the message.
58
- -dfx canister call canister_logs failed_unwrap
69
+ # Ignore failed dfx command output (so the test continues) and check the logs to contain the message.
70
+ - dfx canister call canister_logs failed_unwrap
59
71
dfx canister logs canister_logs \
60
72
| grep 'Result::unwrap()' && echo 'PASS'
61
73
62
- # Test timer trap, assume it's been 5 seconds since the start.
74
+ # Test timer trap.
75
+ # The timer is setup to trap every 5 seconds, so this test has to be called
76
+ # at least 5 seconds after the start to record the trap log message.
77
+ sleep 5
63
78
dfx canister logs canister_logs \
64
79
| grep 'timer trap' && echo 'PASS'
65
80
0 commit comments