diff --git a/basis/io/sockets/secure/unix/unix-tests.factor b/basis/io/sockets/secure/unix/unix-tests.factor index 6d06db2c4f..07df6bfe61 100644 --- a/basis/io/sockets/secure/unix/unix-tests.factor +++ b/basis/io/sockets/secure/unix/unix-tests.factor @@ -1,15 +1,16 @@ +USING: accessors calendar classes +concurrency.promises destructors io io.backend.unix +io.encodings.ascii io.sockets io.sockets.secure +io.sockets.secure.debug io.streams.duplex io.timeouts kernel +locals namespaces threads tools.test ; IN: io.sockets.secure.tests -USING: accessors kernel namespaces io io.sockets -io.sockets.secure io.encodings.ascii io.streams.duplex -io.backend.unix classes words destructors threads tools.test -concurrency.promises byte-arrays locals calendar io.timeouts -io.sockets.secure.debug ; +QUALIFIED-WITH: concurrency.messaging qm { 1 0 } [ [ ] with-secure-context ] must-infer-as { } [ "port" set ] unit-test -:: server-test ( quot -- ) +:: server-test ( quot -- obj/f ) [ [ "127.0.0.1" 0 f ascii [ @@ -19,13 +20,19 @@ io.sockets.secure.debug ; ] curry with-stream ] with-disposal ] with-test-context - ] "SSL server test" spawn drop ; + ] "SSL server test" qm:spawn-linked drop qm:receive ; + +: ?promise-test ( mailbox -- obj ) + 340 milliseconds ?promise-timeout ; : client-test ( -- string ) [ - "127.0.0.1" "port" get ?promise f ascii drop stream-contents + "127.0.0.1" "port" get ?promise-test f ascii drop + 1 seconds + [ stream-contents ] with-timeout* ] with-secure-context ; +! { } [ [ class-of name>> write "done" my-mailbox mailbox-put ] server-test ] unit-test { } [ [ class-of name>> write ] server-test ] unit-test { "secure" } [ client-test ] unit-test @@ -55,7 +62,7 @@ io.sockets.secure.debug ; [ [ - "localhost" "port" get ?promise f ascii + "localhost" "port" get ?promise-test f ascii drop dispose ] with-secure-context ] [ certificate-verify-error? ] must-fail-with @@ -85,7 +92,7 @@ io.sockets.secure.debug ; { } [ [ [ - "127.0.0.1" "port" get ?promise + "127.0.0.1" "port" get ?promise-test ascii drop &dispose 1 minutes sleep ] with-destructors ] "Silly client" spawn drop @@ -126,7 +133,7 @@ io.sockets.secure.debug ; [ 1 seconds secure-socket-timeout [ [ - "127.0.0.1" "port" get ?promise f + "127.0.0.1" "port" get ?promise-test f ascii drop dispose ] with-secure-context ] with-variable @@ -139,7 +146,7 @@ io.sockets.secure.debug ; [ [ [ - "127.0.0.1" "port" get ?promise + "127.0.0.1" "port" get ?promise-test f ascii drop &dispose 1 minutes sleep ] with-test-context ] with-destructors