(test-assert "luanti server is responding on configured port"
            ;; This is based on the Python script example in doc/protocol.txt.
            (marionette-eval
             '(begin
                (use-modules (gnu services herd)
                             (ice-9 match)
                             (rnrs bytevectors)
                             (rnrs bytevectors gnu))

                (define sock (socket PF_INET SOCK_DGRAM 0))
                (define addr (make-socket-address AF_INET INADDR_LOOPBACK
                                                 30000;; #$(luanti-configuration-port
                                                 ;;    config)
                                                 ))
                (define probe #vu8(#x4f #x45 #x74 #x03 #x00 #x00 #x00 #x01))
                (define buf (make-bytevector 1000))

                (sendto sock probe addr)
                (match (select (list sock) '() '() 2) ;cap wait time to 2s
                  (((sock) _ _)
                   (pk 'ready)
                   (match (recvfrom! sock buf)
                     ((byte-count . _)
                      (and (>= byte-count 15)
                           (pk 'peer-id (bytevector-slice buf 12 2))))))))
             marionette))

Generated by apteryx using scpaste at Mon Dec 29 16:54:10 2025. JST. (original)