1 (define-module (tests test-actors)
2 #:use-module (srfi srfi-64)
3 #:use-module (8sync systems actors)
4 #:use-module (tests utils))
6 (test-begin "test-actors")
9 ;;; Some test dummy values
10 ;;; ======================
12 (define %fake-hive-id "the-main-hive")
13 ;; Some fake ids for actors
14 (define %fake-emo-id (make-address "emo" %fake-hive-id))
15 (define %fake-proog-id (make-address "proog" %fake-hive-id))
16 (define %fake-hive-actor-id (make-address "hive" %fake-hive-id))
19 (make-message ((simple-message-id-generator))
21 %fake-hive-actor-id ; Bootstrap messages come from the hive
22 'greet-proog `((target . ,%fake-proog-id))))
31 (make-message 'id 'to 'from 'action
32 '((monkey . banana)))))
34 (test-equal (message-ref monkey-message 'monkey)
37 ;; A key we don't have
38 (let ((caught-error #f))
39 (catch 'message-missing-key
41 (message-ref monkey-message 'coo-coo))
43 (set! caught-error #t)))
44 (test-assert caught-error))
46 ;; A key we don't have, with a default set
47 (test-equal (message-ref monkey-message 'coo-coo 'danger-danger)
51 ;; Make sure our test message serializes and deserializes okay
54 (read-message-from-string
55 (with-output-to-string
56 (lambda () (write-message test-message))))))
57 (test-assert (message? reread-message))
58 ;; Make sure that all the properties are the same from
59 ;; the original message to the re-read message
62 (test-equal (getter test-message) (getter reread-message)))
63 (list message-id message-to message-from message-action message-body
64 message-in-reply-to message-wants-reply
65 (@@ (8sync systems actors) message-replied)
66 (@@ (8sync systems actors) message-deferred-reply))))
68 (test-end "test-agenda")