test.lisp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. (defvar *alice* (create-schema))
  2. (defvar *bob* (create-schema))
  3. (add-contact *alice* "bob" (getf *bob* :id))
  4. (add-contact *bob* "alice" (getf *alice* :id))
  5. (put-msg *alice* (list 0 (getf *alice* :id)) "food" "pizza")
  6. (put-msg *alice* (list 0 (getf *alice* :id)) "food" "tofu")
  7. ;;;; ONE WAY SYNC
  8. (process-eager-update *bob* (getf *alice* :id)
  9. (send-eager-update *alice* (getf *bob* :id)))
  10. *alice*
  11. *bob*
  12. ;;;; Create a merge conflict
  13. (put-msg *bob* (list 0 (getf *alice* :id)) "food" "salad")
  14. (put-msg *alice* (list 0 (getf *alice* :id)) "food" "pasta")
  15. ;;;; TWO WAY SYNC
  16. ;;;; note that order does not matter
  17. (process-eager-update *alice*
  18. (getf *bob* :id)
  19. (send-eager-update *bob* (getf *alice* :id)))
  20. (process-eager-update *bob*
  21. (getf *alice* :id)
  22. (send-eager-update *alice* (getf *bob* :id)))
  23. *alice*
  24. *bob*
  25. ;;;; Should be in sync now
  26. (get-msg *alice* (list 0 (getf *alice* :id)) "food")
  27. (get-msg *bob* (list 0 (getf *alice* :id)) "food")
  28. ;;;; Put objects into slots
  29. (let ((table (put-obj *bob* (list 0 (getf *alice* :id)) "contact")))
  30. (put-msg *bob* table "email" "someemail@email.com"))
  31. (let ((table (get-msg *bob* (list 0 (getf *alice* :id)) "contact")))
  32. (get-msg *bob* table "email")) ; "someemail@email.com
  33. *alice*
  34. *bob*
  35. (process-eager-update *alice*
  36. (getf *bob* :id)
  37. (send-eager-update *bob* (getf *alice* :id)))
  38. *alice*
  39. *bob*
  40. (let ((table (get-msg *alice* (list 0 (getf *alice* :id)) "contact")))
  41. (get-msg *alice* table "email")) ; "someemail@email.com
  42. (let ((table (get-msg *alice* (list 0 (getf *alice* :id)) "contact")))
  43. (put-msg *alice* table "email" "alice@email.com"))
  44. (process-eager-update *bob*
  45. (getf *alice* :id)
  46. (send-eager-update *alice* (getf *bob* :id)))
  47. (let ((table (get-msg *bob* (list 0 (getf *alice* :id)) "contact")))
  48. (get-msg *alice* table "email")) ; "alice@email.com