aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/tests/af-alg/alg-camellia/pretest.dat3
-rw-r--r--testing/tests/af-alg/rw-cert/pretest.dat6
-rw-r--r--testing/tests/gcrypt-ikev1/alg-serpent/pretest.dat2
-rw-r--r--testing/tests/gcrypt-ikev1/alg-twofish/pretest.dat2
-rw-r--r--testing/tests/gcrypt-ikev2/alg-camellia/pretest.dat3
-rw-r--r--testing/tests/gcrypt-ikev2/rw-cert/pretest.dat3
-rw-r--r--testing/tests/ha/active-passive/pretest.dat5
-rw-r--r--testing/tests/ha/both-active/pretest.dat3
-rw-r--r--testing/tests/ike/rw-cert/pretest.dat4
-rw-r--r--testing/tests/ike/rw_v1-net_v2/pretest.dat4
-rw-r--r--testing/tests/ikev1/alg-3des-md5/pretest.dat2
-rw-r--r--testing/tests/ikev1/alg-blowfish/pretest.dat3
-rw-r--r--testing/tests/ikev1/alg-modp-subgroup/pretest.dat3
-rw-r--r--testing/tests/ikev1/alg-sha256/pretest.dat2
-rw-r--r--testing/tests/ikev1/alg-sha384/pretest.dat2
-rw-r--r--testing/tests/ikev1/alg-sha512/pretest.dat2
-rw-r--r--testing/tests/ikev1/compress/pretest.dat2
-rw-r--r--testing/tests/ikev1/config-payload-push/pretest.dat4
-rw-r--r--testing/tests/ikev1/config-payload/pretest.dat4
-rw-r--r--testing/tests/ikev1/double-nat-net/pretest.dat3
-rw-r--r--testing/tests/ikev1/double-nat/pretest.dat3
-rw-r--r--testing/tests/ikev1/dpd-clear/pretest.dat2
-rw-r--r--testing/tests/ikev1/dpd-restart/evaltest.dat2
-rw-r--r--testing/tests/ikev1/dpd-restart/pretest.dat2
-rw-r--r--testing/tests/ikev1/dynamic-initiator/posttest.dat1
-rw-r--r--testing/tests/ikev1/dynamic-initiator/pretest.dat5
-rw-r--r--testing/tests/ikev1/dynamic-responder/posttest.dat1
-rw-r--r--testing/tests/ikev1/dynamic-responder/pretest.dat7
-rw-r--r--testing/tests/ikev1/dynamic-two-peers/posttest.dat1
-rw-r--r--testing/tests/ikev1/dynamic-two-peers/pretest.dat4
-rw-r--r--testing/tests/ikev1/esp-alg-aes-ccm/pretest.dat2
-rw-r--r--testing/tests/ikev1/esp-alg-aes-ctr/pretest.dat2
-rw-r--r--testing/tests/ikev1/esp-alg-aes-gcm/pretest.dat2
-rw-r--r--testing/tests/ikev1/esp-alg-aes-gmac/pretest.dat2
-rw-r--r--testing/tests/ikev1/esp-alg-aes-xcbc/pretest.dat2
-rw-r--r--testing/tests/ikev1/esp-alg-null/pretest.dat3
-rw-r--r--testing/tests/ikev1/host2host-ah/pretest.dat2
-rw-r--r--testing/tests/ikev1/host2host-cert/pretest.dat2
-rw-r--r--testing/tests/ikev1/host2host-transport/pretest.dat2
-rw-r--r--testing/tests/ikev1/ip-pool-db/pretest.dat6
-rw-r--r--testing/tests/ikev1/ip-pool/pretest.dat4
-rw-r--r--testing/tests/ikev1/multi-level-ca-cr-init/pretest.dat3
-rw-r--r--testing/tests/ikev1/multi-level-ca-cr-resp/pretest.dat3
-rw-r--r--testing/tests/ikev1/multi-level-ca/pretest.dat5
-rw-r--r--testing/tests/ikev1/nat-rw/pretest.dat5
-rw-r--r--testing/tests/ikev1/nat-virtual-ip/pretest.dat3
-rw-r--r--testing/tests/ikev1/net2net-ah/pretest.dat2
-rw-r--r--testing/tests/ikev1/net2net-cert/pretest.dat2
-rw-r--r--testing/tests/ikev1/net2net-fragmentation/pretest.dat2
-rw-r--r--testing/tests/ikev1/net2net-ntru-cert/pretest.dat2
-rw-r--r--testing/tests/ikev1/net2net-psk-fail/pretest.dat2
-rw-r--r--testing/tests/ikev1/net2net-psk/pretest.dat2
-rw-r--r--testing/tests/ikev1/protoport-dual/pretest.dat3
-rw-r--r--testing/tests/ikev1/rw-cert-aggressive/pretest.dat3
-rw-r--r--testing/tests/ikev1/rw-cert-unity/pretest.dat2
-rw-r--r--testing/tests/ikev1/rw-cert/pretest.dat3
-rw-r--r--testing/tests/ikev1/rw-initiator-only/pretest.dat3
-rw-r--r--testing/tests/ikev1/rw-ntru-psk/pretest.dat4
-rw-r--r--testing/tests/ikev1/rw-psk-aggressive/pretest.dat3
-rw-r--r--testing/tests/ikev1/rw-psk-fqdn/pretest.dat5
-rw-r--r--testing/tests/ikev1/rw-psk-ipv4/pretest.dat3
-rw-r--r--testing/tests/ikev1/virtual-ip/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-id-psk-config/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-id-rsa-aggressive/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-id-rsa-config/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-id-rsa-hybrid/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-psk/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-rsa-eap-md5-radius/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-rsa-radius/pretest.dat3
-rw-r--r--testing/tests/ikev1/xauth-rsa/pretest.dat3
-rw-r--r--testing/tests/ikev2/acert-cached/pretest.dat3
-rw-r--r--testing/tests/ikev2/acert-fallback/pretest.dat2
-rw-r--r--testing/tests/ikev2/acert-inline/pretest.dat3
-rw-r--r--testing/tests/ikev2/after-2038-certs/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-3des-md5/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-aes-ccm/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-aes-ctr/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-aes-gcm/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-aes-xcbc/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-blowfish/pretest.dat3
-rw-r--r--testing/tests/ikev2/alg-chacha20poly1305/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-modp-subgroup/pretest.dat3
-rw-r--r--testing/tests/ikev2/alg-sha256-96/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-sha256/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-sha384/pretest.dat2
-rw-r--r--testing/tests/ikev2/alg-sha512/pretest.dat2
-rw-r--r--testing/tests/ikev2/any-interface/pretest.dat3
-rw-r--r--testing/tests/ikev2/compress/pretest.dat2
-rw-r--r--testing/tests/ikev2/config-payload-swapped/pretest.dat4
-rw-r--r--testing/tests/ikev2/config-payload/pretest.dat4
-rw-r--r--testing/tests/ikev2/critical-extension/pretest.dat2
-rw-r--r--testing/tests/ikev2/crl-from-cache/pretest.dat2
-rw-r--r--testing/tests/ikev2/crl-ldap/pretest.dat3
-rw-r--r--testing/tests/ikev2/crl-revoked/pretest.dat2
-rw-r--r--testing/tests/ikev2/crl-to-cache/pretest.dat2
-rw-r--r--testing/tests/ikev2/default-keys/pretest.dat4
-rw-r--r--testing/tests/ikev2/dhcp-dynamic/pretest.dat4
-rw-r--r--testing/tests/ikev2/dhcp-static-client-id/pretest.dat4
-rw-r--r--testing/tests/ikev2/dhcp-static-mac/pretest.dat4
-rw-r--r--testing/tests/ikev2/double-nat-net/pretest.dat3
-rw-r--r--testing/tests/ikev2/double-nat/pretest.dat3
-rw-r--r--testing/tests/ikev2/dpd-clear/pretest.dat2
-rw-r--r--testing/tests/ikev2/dpd-hold/pretest.dat2
-rw-r--r--testing/tests/ikev2/dpd-restart/evaltest.dat2
-rw-r--r--testing/tests/ikev2/dpd-restart/pretest.dat2
-rw-r--r--testing/tests/ikev2/dynamic-initiator/posttest.dat1
-rw-r--r--testing/tests/ikev2/dynamic-initiator/pretest.dat5
-rw-r--r--testing/tests/ikev2/dynamic-two-peers/posttest.dat1
-rw-r--r--testing/tests/ikev2/dynamic-two-peers/pretest.dat4
-rw-r--r--testing/tests/ikev2/esp-alg-aes-gmac/pretest.dat2
-rw-r--r--testing/tests/ikev2/esp-alg-md5-128/pretest.dat3
-rw-r--r--testing/tests/ikev2/esp-alg-null/pretest.dat3
-rw-r--r--testing/tests/ikev2/esp-alg-sha1-160/pretest.dat3
-rw-r--r--testing/tests/ikev2/farp/pretest.dat4
-rw-r--r--testing/tests/ikev2/force-udp-encaps/pretest.dat4
-rw-r--r--testing/tests/ikev2/forecast/pretest.dat4
-rw-r--r--testing/tests/ikev2/host2host-ah/pretest.dat2
-rw-r--r--testing/tests/ikev2/host2host-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/host2host-swapped/pretest.dat2
-rw-r--r--testing/tests/ikev2/host2host-transport/pretest.dat2
-rw-r--r--testing/tests/ikev2/inactivity-timeout/pretest.dat3
-rw-r--r--testing/tests/ikev2/ip-pool-db/pretest.dat6
-rw-r--r--testing/tests/ikev2/ip-pool-wish/pretest.dat4
-rw-r--r--testing/tests/ikev2/ip-pool/pretest.dat4
-rw-r--r--testing/tests/ikev2/ip-split-pools-db/pretest.dat4
-rw-r--r--testing/tests/ikev2/ip-two-pools-db/pretest.dat6
-rw-r--r--testing/tests/ikev2/ip-two-pools-mixed/pretest.dat6
-rw-r--r--testing/tests/ikev2/ip-two-pools-v4v6-db/pretest.dat2
-rw-r--r--testing/tests/ikev2/ip-two-pools-v4v6/pretest.dat2
-rw-r--r--testing/tests/ikev2/ip-two-pools/pretest.dat4
-rw-r--r--testing/tests/ikev2/lookip/pretest.dat4
-rw-r--r--testing/tests/ikev2/mobike-nat/pretest.dat3
-rw-r--r--testing/tests/ikev2/mobike-virtual-ip/pretest.dat3
-rw-r--r--testing/tests/ikev2/mobike/pretest.dat3
-rw-r--r--testing/tests/ikev2/mult-auth-rsa-eap-sim-id/pretest.dat4
-rw-r--r--testing/tests/ikev2/multi-level-ca-cr-init/pretest.dat3
-rw-r--r--testing/tests/ikev2/multi-level-ca-cr-resp/pretest.dat3
-rw-r--r--testing/tests/ikev2/multi-level-ca-ldap/pretest.dat5
-rw-r--r--testing/tests/ikev2/multi-level-ca-loop/pretest.dat2
-rw-r--r--testing/tests/ikev2/multi-level-ca-pathlen/pretest.dat4
-rw-r--r--testing/tests/ikev2/multi-level-ca-revoked/pretest.dat2
-rw-r--r--testing/tests/ikev2/multi-level-ca-strict/pretest.dat5
-rw-r--r--testing/tests/ikev2/multi-level-ca/posttest.dat1
-rw-r--r--testing/tests/ikev2/multi-level-ca/pretest.dat5
-rw-r--r--testing/tests/ikev2/nat-rw-mark/pretest.dat5
-rw-r--r--testing/tests/ikev2/nat-rw-psk/pretest.dat5
-rw-r--r--testing/tests/ikev2/nat-rw/pretest.dat5
-rw-r--r--testing/tests/ikev2/nat-virtual-ip/pretest.dat3
-rw-r--r--testing/tests/ikev2/net2net-ah/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-cert-sha2/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-dnscert/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-dnssec/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-esn/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-ntru-bandwidth/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-ntru-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-pgp-v3/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-pgp-v4/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-pkcs12/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-psk-dscp/pretest.dat5
-rw-r--r--testing/tests/ikev2/net2net-psk-fail/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-psk/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-rfc3779/pretest.dat3
-rw-r--r--testing/tests/ikev2/net2net-route/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-rsa/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-same-nets/pretest.dat2
-rw-r--r--testing/tests/ikev2/net2net-start/pretest.dat3
-rw-r--r--testing/tests/ikev2/ocsp-local-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/ocsp-multi-level/pretest.dat3
-rw-r--r--testing/tests/ikev2/ocsp-no-signer-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/ocsp-revoked/pretest.dat2
-rw-r--r--testing/tests/ikev2/ocsp-root-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/ocsp-signer-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/ocsp-strict-ifuri/pretest.dat3
-rw-r--r--testing/tests/ikev2/ocsp-timeouts-good/pretest.dat2
-rw-r--r--testing/tests/ikev2/ocsp-timeouts-unknown/pretest.dat2
-rw-r--r--testing/tests/ikev2/ocsp-untrusted-cert/pretest.dat2
-rw-r--r--testing/tests/ikev2/protoport-dual/pretest.dat3
-rw-r--r--testing/tests/ikev2/protoport-route/pretest.dat4
-rw-r--r--testing/tests/ikev2/reauth-early/pretest.dat2
-rw-r--r--testing/tests/ikev2/reauth-late/pretest.dat2
-rw-r--r--testing/tests/ikev2/reauth-mbb-virtual-ip/pretest.dat2
-rw-r--r--testing/tests/ikev2/reauth-mbb/pretest.dat2
-rw-r--r--testing/tests/ikev2/rw-cert/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-dnssec/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-aka-id-rsa/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-aka-rsa/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-dynamic/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-framed-ip-radius/pretest.dat8
-rw-r--r--testing/tests/ikev2/rw-eap-md5-class-radius/pretest.dat6
-rw-r--r--testing/tests/ikev2/rw-eap-md5-id-prompt/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-md5-id-radius/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-md5-radius/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-md5-rsa/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-mschapv2-id-rsa/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-peap-md5/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-peap-mschapv2/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-peap-radius/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-sim-id-radius/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-sim-only-radius/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-sim-radius/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-sim-rsa/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-tls-fragments/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-tls-only/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-tls-radius/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-eap-ttls-only/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-ttls-phase2-piggyback/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-eap-ttls-radius/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-hash-and-url/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-initiator-only/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-mark-in-out/pretest.dat11
-rw-r--r--testing/tests/ikev2/rw-ntru-bliss/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-ntru-psk/pretest.dat4
-rw-r--r--testing/tests/ikev2/rw-pkcs8/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-psk-fqdn/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-psk-ipv4/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-psk-no-idr/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-psk-rsa-mixed/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-psk-rsa-split/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-radius-accounting/pretest.dat3
-rw-r--r--testing/tests/ikev2/rw-sig-auth/pretest.dat6
-rw-r--r--testing/tests/ikev2/strong-keys-certs/pretest.dat4
-rw-r--r--testing/tests/ikev2/two-certs/pretest.dat4
-rw-r--r--testing/tests/ikev2/virtual-ip-override/pretest.dat3
-rw-r--r--testing/tests/ikev2/virtual-ip/pretest.dat3
-rw-r--r--testing/tests/ikev2/wildcards/pretest.dat5
-rw-r--r--testing/tests/libipsec/host2host-cert/pretest.dat2
-rw-r--r--testing/tests/libipsec/net2net-3des/pretest.dat2
-rw-r--r--testing/tests/libipsec/net2net-cert/pretest.dat2
-rw-r--r--testing/tests/libipsec/rw-suite-b/pretest.dat4
-rw-r--r--testing/tests/openssl-ikev1/alg-camellia/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev1/alg-ecp-high/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev1/alg-ecp-low/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev1/ecdsa-certs/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/alg-aes-gcm/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/alg-blowfish/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/alg-camellia/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/alg-ecp-brainpool-high/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/alg-ecp-brainpool-low/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/alg-ecp-high/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/alg-ecp-low/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/critical-extension/pretest.dat2
-rw-r--r--testing/tests/openssl-ikev2/ecdsa-certs/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/ecdsa-pkcs8/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/net2net-pgp-v3/pretest.dat2
-rw-r--r--testing/tests/openssl-ikev2/net2net-pkcs12/pretest.dat2
-rw-r--r--testing/tests/openssl-ikev2/rw-cert/pretest.dat5
-rw-r--r--testing/tests/openssl-ikev2/rw-eap-tls-only/pretest.dat3
-rw-r--r--testing/tests/openssl-ikev2/rw-suite-b-128/pretest.dat4
-rw-r--r--testing/tests/openssl-ikev2/rw-suite-b-192/pretest.dat4
-rw-r--r--testing/tests/p2pnat/behind-same-nat/pretest.dat4
-rw-r--r--testing/tests/p2pnat/medsrv-psk/pretest.dat4
-rw-r--r--testing/tests/pfkey/alg-aes-xcbc/pretest.dat2
-rw-r--r--testing/tests/pfkey/alg-sha384/pretest.dat2
-rw-r--r--testing/tests/pfkey/alg-sha512/pretest.dat2
-rw-r--r--testing/tests/pfkey/compress/pretest.dat2
-rw-r--r--testing/tests/pfkey/esp-alg-null/pretest.dat2
-rw-r--r--testing/tests/pfkey/host2host-transport/pretest.dat2
-rw-r--r--testing/tests/pfkey/nat-rw/pretest.dat5
-rw-r--r--testing/tests/pfkey/net2net-route/pretest.dat2
-rw-r--r--testing/tests/pfkey/protoport-dual/pretest.dat3
-rw-r--r--testing/tests/pfkey/protoport-route/pretest.dat4
-rw-r--r--testing/tests/pfkey/rw-cert/pretest.dat4
-rw-r--r--testing/tests/sql/ip-pool-db-expired/pretest.dat3
-rw-r--r--testing/tests/sql/ip-pool-db-restart/pretest.dat4
-rw-r--r--testing/tests/sql/ip-pool-db/pretest.dat4
-rw-r--r--testing/tests/sql/ip-split-pools-db-restart/pretest.dat4
-rw-r--r--testing/tests/sql/ip-split-pools-db/pretest.dat4
-rw-r--r--testing/tests/sql/multi-level-ca/pretest.dat3
-rw-r--r--testing/tests/sql/net2net-cert/pretest.dat2
-rw-r--r--testing/tests/sql/net2net-psk/pretest.dat2
-rw-r--r--testing/tests/sql/net2net-route-pem/pretest.dat2
-rw-r--r--testing/tests/sql/net2net-start-pem/pretest.dat2
-rw-r--r--testing/tests/sql/rw-cert/pretest.dat3
-rw-r--r--testing/tests/sql/rw-eap-aka-rsa/pretest.dat2
-rw-r--r--testing/tests/sql/rw-psk-ipv4/pretest.dat3
-rw-r--r--testing/tests/sql/rw-psk-ipv6/pretest.dat3
-rw-r--r--testing/tests/sql/rw-psk-rsa-split/pretest.dat3
-rw-r--r--testing/tests/sql/rw-rsa-keyid/pretest.dat3
-rw-r--r--testing/tests/sql/rw-rsa/pretest.dat3
-rw-r--r--testing/tests/tnc/tnccs-11-fhh/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-11-radius-block/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-11-radius-pts/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-11-radius/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-11-supplicant/pretest.dat2
-rw-r--r--testing/tests/tnc/tnccs-11/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-block/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-client-retry/pretest.dat8
-rw-r--r--testing/tests/tnc/tnccs-20-fail-init/pretest.dat5
-rw-r--r--testing/tests/tnc/tnccs-20-fail-resp/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-fhh/pretest.dat9
-rw-r--r--testing/tests/tnc/tnccs-20-hcd-eap/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-mutual-eap/pretest.dat2
-rw-r--r--testing/tests/tnc/tnccs-20-mutual-pt-tls/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-os-pts/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-pdp-eap/pretest.dat3
-rw-r--r--testing/tests/tnc/tnccs-20-pdp-pt-tls/pretest.dat3
-rw-r--r--testing/tests/tnc/tnccs-20-pts-no-ecc/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-pts/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20-server-retry/pretest.dat8
-rw-r--r--testing/tests/tnc/tnccs-20-tls/pretest.dat4
-rw-r--r--testing/tests/tnc/tnccs-20/pretest.dat8
-rw-r--r--testing/tests/tnc/tnccs-dynamic/pretest.dat4
303 files changed, 500 insertions, 452 deletions
diff --git a/testing/tests/af-alg/alg-camellia/pretest.dat b/testing/tests/af-alg/alg-camellia/pretest.dat
index 886fdf55c..de4acbbf0 100644
--- a/testing/tests/af-alg/alg-camellia/pretest.dat
+++ b/testing/tests/af-alg/alg-camellia/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/af-alg/rw-cert/pretest.dat b/testing/tests/af-alg/rw-cert/pretest.dat
index c582e030d..855c273cc 100644
--- a/testing/tests/af-alg/rw-cert/pretest.dat
+++ b/testing/tests/af-alg/rw-cert/pretest.dat
@@ -4,6 +4,8 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+moon::expect-connection rw
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
-dave::ipsec up home
+dave::ipsec up home \ No newline at end of file
diff --git a/testing/tests/gcrypt-ikev1/alg-serpent/pretest.dat b/testing/tests/gcrypt-ikev1/alg-serpent/pretest.dat
index 1b8fc3b79..8230de058 100644
--- a/testing/tests/gcrypt-ikev1/alg-serpent/pretest.dat
+++ b/testing/tests/gcrypt-ikev1/alg-serpent/pretest.dat
@@ -1,4 +1,4 @@
carol::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/gcrypt-ikev1/alg-twofish/pretest.dat b/testing/tests/gcrypt-ikev1/alg-twofish/pretest.dat
index 1b8fc3b79..8230de058 100644
--- a/testing/tests/gcrypt-ikev1/alg-twofish/pretest.dat
+++ b/testing/tests/gcrypt-ikev1/alg-twofish/pretest.dat
@@ -1,4 +1,4 @@
carol::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/gcrypt-ikev2/alg-camellia/pretest.dat b/testing/tests/gcrypt-ikev2/alg-camellia/pretest.dat
index 886fdf55c..de4acbbf0 100644
--- a/testing/tests/gcrypt-ikev2/alg-camellia/pretest.dat
+++ b/testing/tests/gcrypt-ikev2/alg-camellia/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/gcrypt-ikev2/rw-cert/pretest.dat b/testing/tests/gcrypt-ikev2/rw-cert/pretest.dat
index c582e030d..f1a4b964c 100644
--- a/testing/tests/gcrypt-ikev2/rw-cert/pretest.dat
+++ b/testing/tests/gcrypt-ikev2/rw-cert/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
diff --git a/testing/tests/ha/active-passive/pretest.dat b/testing/tests/ha/active-passive/pretest.dat
index d0efb76f7..2bdab2839 100644
--- a/testing/tests/ha/active-passive/pretest.dat
+++ b/testing/tests/ha/active-passive/pretest.dat
@@ -12,10 +12,11 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
alice::ipsec start
moon::ipsec start
-moon::sleep 2
+moon::sleep 2
alice::echo "+1" > /var/run/charon.ha
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
diff --git a/testing/tests/ha/both-active/pretest.dat b/testing/tests/ha/both-active/pretest.dat
index 5ffc38766..f48873f62 100644
--- a/testing/tests/ha/both-active/pretest.dat
+++ b/testing/tests/ha/both-active/pretest.dat
@@ -14,6 +14,7 @@ alice::ipsec start
alice::sleep 1
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
diff --git a/testing/tests/ike/rw-cert/pretest.dat b/testing/tests/ike/rw-cert/pretest.dat
index e50793830..f1af9ede5 100644
--- a/testing/tests/ike/rw-cert/pretest.dat
+++ b/testing/tests/ike/rw-cert/pretest.dat
@@ -1,7 +1,7 @@
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ike/rw_v1-net_v2/pretest.dat b/testing/tests/ike/rw_v1-net_v2/pretest.dat
index f61a4cb51..072d9ddeb 100644
--- a/testing/tests/ike/rw_v1-net_v2/pretest.dat
+++ b/testing/tests/ike/rw_v1-net_v2/pretest.dat
@@ -1,7 +1,7 @@
moon::ipsec start
sun::ipsec start
carol::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
+carol::expect-connection home
moon::ipsec up net-net
carol::ipsec up home
-moon::sleep 1
diff --git a/testing/tests/ikev1/alg-3des-md5/pretest.dat b/testing/tests/ikev1/alg-3des-md5/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/alg-3des-md5/pretest.dat
+++ b/testing/tests/ikev1/alg-3des-md5/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/alg-blowfish/pretest.dat b/testing/tests/ikev1/alg-blowfish/pretest.dat
index 8bbea1412..f1a4b964c 100644
--- a/testing/tests/ikev1/alg-blowfish/pretest.dat
+++ b/testing/tests/ikev1/alg-blowfish/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
diff --git a/testing/tests/ikev1/alg-modp-subgroup/pretest.dat b/testing/tests/ikev1/alg-modp-subgroup/pretest.dat
index 8bbea1412..f1a4b964c 100644
--- a/testing/tests/ikev1/alg-modp-subgroup/pretest.dat
+++ b/testing/tests/ikev1/alg-modp-subgroup/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
diff --git a/testing/tests/ikev1/alg-sha256/pretest.dat b/testing/tests/ikev1/alg-sha256/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/alg-sha256/pretest.dat
+++ b/testing/tests/ikev1/alg-sha256/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/alg-sha384/pretest.dat b/testing/tests/ikev1/alg-sha384/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/alg-sha384/pretest.dat
+++ b/testing/tests/ikev1/alg-sha384/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/alg-sha512/pretest.dat b/testing/tests/ikev1/alg-sha512/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/alg-sha512/pretest.dat
+++ b/testing/tests/ikev1/alg-sha512/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/compress/pretest.dat b/testing/tests/ikev1/compress/pretest.dat
index f5aa989fe..8230de058 100644
--- a/testing/tests/ikev1/compress/pretest.dat
+++ b/testing/tests/ikev1/compress/pretest.dat
@@ -1,4 +1,4 @@
carol::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/config-payload-push/pretest.dat b/testing/tests/ikev1/config-payload-push/pretest.dat
index 3864bdac3..c0ec6a7a4 100644
--- a/testing/tests/ikev1/config-payload-push/pretest.dat
+++ b/testing/tests/ikev1/config-payload-push/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/config-payload/pretest.dat b/testing/tests/ikev1/config-payload/pretest.dat
index 3864bdac3..c0ec6a7a4 100644
--- a/testing/tests/ikev1/config-payload/pretest.dat
+++ b/testing/tests/ikev1/config-payload/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
+dave::expect-connection home
carol::ipsec up home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/double-nat-net/pretest.dat b/testing/tests/ikev1/double-nat-net/pretest.dat
index 17a4fe5eb..d300a276f 100644
--- a/testing/tests/ikev1/double-nat-net/pretest.dat
+++ b/testing/tests/ikev1/double-nat-net/pretest.dat
@@ -7,6 +7,5 @@ sun::iptables -t nat -A PREROUTING -i eth0 -s PH_IP_MOON -p udp -j DNAT --to-des
sun::ip route add 10.1.0.0/16 via PH_IP_BOB
alice::ipsec start
bob::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-alice::sleep 1
diff --git a/testing/tests/ikev1/double-nat/pretest.dat b/testing/tests/ikev1/double-nat/pretest.dat
index 65f18b756..6a861d29f 100644
--- a/testing/tests/ikev1/double-nat/pretest.dat
+++ b/testing/tests/ikev1/double-nat/pretest.dat
@@ -6,6 +6,5 @@ sun::iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p tcp -j SNAT --to-s
sun::iptables -t nat -A PREROUTING -i eth0 -s PH_IP_MOON -p udp -j DNAT --to-destination PH_IP_BOB
alice::ipsec start
bob::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-alice::sleep 1
diff --git a/testing/tests/ikev1/dpd-clear/pretest.dat b/testing/tests/ikev1/dpd-clear/pretest.dat
index 14ed95322..3a1982f8a 100644
--- a/testing/tests/ikev1/dpd-clear/pretest.dat
+++ b/testing/tests/ikev1/dpd-clear/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/dpd-restart/evaltest.dat b/testing/tests/ikev1/dpd-restart/evaltest.dat
index 91803a3f1..a685ce166 100644
--- a/testing/tests/ikev1/dpd-restart/evaltest.dat
+++ b/testing/tests/ikev1/dpd-restart/evaltest.dat
@@ -8,6 +8,6 @@ carol::cat /var/log/daemon.log::DPD check timed out, enforcing DPD action::YES
carol::cat /var/log/daemon.log::restarting CHILD_SA home::YES
carol::iptables -D INPUT -i eth0 -s PH_IP_MOON -j DROP::no output expected::NO
moon:: iptables -D INPUT -i eth0 -s PH_IP_CAROL -j DROP::no output expected::NO
-carol::sleep 1::no output expected::NO
+carol::sleep 2::no output expected::NO
carol::ipsec status 2> /dev/null::home.*INSTALLED, TUNNEL::YES
moon:: ipsec status 2> /dev/null::rw.*INSTALLED, TUNNEL::YES
diff --git a/testing/tests/ikev1/dpd-restart/pretest.dat b/testing/tests/ikev1/dpd-restart/pretest.dat
index 14ed95322..3a1982f8a 100644
--- a/testing/tests/ikev1/dpd-restart/pretest.dat
+++ b/testing/tests/ikev1/dpd-restart/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/dynamic-initiator/posttest.dat b/testing/tests/ikev1/dynamic-initiator/posttest.dat
index 32ac12ddc..6898bd567 100644
--- a/testing/tests/ikev1/dynamic-initiator/posttest.dat
+++ b/testing/tests/ikev1/dynamic-initiator/posttest.dat
@@ -1,6 +1,5 @@
dave::ipsec stop
carol::ipsec stop
-dave::sleep 1
moon::ipsec stop
carol::iptables-restore < /etc/iptables.flush
dave::rm /etc/ipsec.d/certs/*
diff --git a/testing/tests/ikev1/dynamic-initiator/pretest.dat b/testing/tests/ikev1/dynamic-initiator/pretest.dat
index 9aadb2a4c..7e6ad46df 100644
--- a/testing/tests/ikev1/dynamic-initiator/pretest.dat
+++ b/testing/tests/ikev1/dynamic-initiator/pretest.dat
@@ -2,10 +2,9 @@ carol::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection moon
carol::ipsec up moon
-carol::sleep 1
carol::iptables -D INPUT -i eth0 -p udp --dport 500 --sport 500 -j ACCEPT
carol::iptables -D OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
+dave::expect-connection moon
dave::ipsec up moon
-dave::sleep 2
diff --git a/testing/tests/ikev1/dynamic-responder/posttest.dat b/testing/tests/ikev1/dynamic-responder/posttest.dat
index 32ac12ddc..6898bd567 100644
--- a/testing/tests/ikev1/dynamic-responder/posttest.dat
+++ b/testing/tests/ikev1/dynamic-responder/posttest.dat
@@ -1,6 +1,5 @@
dave::ipsec stop
carol::ipsec stop
-dave::sleep 1
moon::ipsec stop
carol::iptables-restore < /etc/iptables.flush
dave::rm /etc/ipsec.d/certs/*
diff --git a/testing/tests/ikev1/dynamic-responder/pretest.dat b/testing/tests/ikev1/dynamic-responder/pretest.dat
index 8dc744f9a..0c423aeec 100644
--- a/testing/tests/ikev1/dynamic-responder/pretest.dat
+++ b/testing/tests/ikev1/dynamic-responder/pretest.dat
@@ -2,10 +2,11 @@ carol::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-moon::sleep 2
+moon::expect-connection carol
moon::ipsec up carol
-moon::sleep 1
+moon::sleep 0.5
carol::iptables -D INPUT -i eth0 -p udp --dport 500 --sport 500 -j ACCEPT
carol::iptables -D OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
+dave::expect-connection moon
dave::ipsec up moon
-dave::sleep 2
+moon::sleep 0.5
diff --git a/testing/tests/ikev1/dynamic-two-peers/posttest.dat b/testing/tests/ikev1/dynamic-two-peers/posttest.dat
index 7b2609846..119c8e45a 100644
--- a/testing/tests/ikev1/dynamic-two-peers/posttest.dat
+++ b/testing/tests/ikev1/dynamic-two-peers/posttest.dat
@@ -1,6 +1,5 @@
carol::ipsec stop
dave::ipsec stop
-moon::sleep 1
moon::ipsec stop
moon::mv /etc/hosts.ori /etc/hosts
moon::iptables-restore < /etc/iptables.flush
diff --git a/testing/tests/ikev1/dynamic-two-peers/pretest.dat b/testing/tests/ikev1/dynamic-two-peers/pretest.dat
index 4bb2a4686..c19b38fcd 100644
--- a/testing/tests/ikev1/dynamic-two-peers/pretest.dat
+++ b/testing/tests/ikev1/dynamic-two-peers/pretest.dat
@@ -6,7 +6,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection moon
+dave::expect-connection moon
carol::ipsec up moon
dave::ipsec up moon
-carol::sleep 1
diff --git a/testing/tests/ikev1/esp-alg-aes-ccm/pretest.dat b/testing/tests/ikev1/esp-alg-aes-ccm/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/esp-alg-aes-ccm/pretest.dat
+++ b/testing/tests/ikev1/esp-alg-aes-ccm/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/esp-alg-aes-ctr/pretest.dat b/testing/tests/ikev1/esp-alg-aes-ctr/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/esp-alg-aes-ctr/pretest.dat
+++ b/testing/tests/ikev1/esp-alg-aes-ctr/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/esp-alg-aes-gcm/pretest.dat b/testing/tests/ikev1/esp-alg-aes-gcm/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/esp-alg-aes-gcm/pretest.dat
+++ b/testing/tests/ikev1/esp-alg-aes-gcm/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/esp-alg-aes-gmac/pretest.dat b/testing/tests/ikev1/esp-alg-aes-gmac/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev1/esp-alg-aes-gmac/pretest.dat
+++ b/testing/tests/ikev1/esp-alg-aes-gmac/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/esp-alg-aes-xcbc/pretest.dat b/testing/tests/ikev1/esp-alg-aes-xcbc/pretest.dat
index f5aa989fe..8230de058 100644
--- a/testing/tests/ikev1/esp-alg-aes-xcbc/pretest.dat
+++ b/testing/tests/ikev1/esp-alg-aes-xcbc/pretest.dat
@@ -1,4 +1,4 @@
carol::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/esp-alg-null/pretest.dat b/testing/tests/ikev1/esp-alg-null/pretest.dat
index 886fdf55c..de4acbbf0 100644
--- a/testing/tests/ikev1/esp-alg-null/pretest.dat
+++ b/testing/tests/ikev1/esp-alg-null/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/host2host-ah/pretest.dat b/testing/tests/ikev1/host2host-ah/pretest.dat
index 99789b90f..997a48167 100644
--- a/testing/tests/ikev1/host2host-ah/pretest.dat
+++ b/testing/tests/ikev1/host2host-ah/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/ikev1/host2host-cert/pretest.dat b/testing/tests/ikev1/host2host-cert/pretest.dat
index 3bce9f6e5..997a48167 100644
--- a/testing/tests/ikev1/host2host-cert/pretest.dat
+++ b/testing/tests/ikev1/host2host-cert/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/ikev1/host2host-transport/pretest.dat b/testing/tests/ikev1/host2host-transport/pretest.dat
index 99789b90f..997a48167 100644
--- a/testing/tests/ikev1/host2host-transport/pretest.dat
+++ b/testing/tests/ikev1/host2host-transport/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/ikev1/ip-pool-db/pretest.dat b/testing/tests/ikev1/ip-pool-db/pretest.dat
index 2327eb983..0e3175abc 100644
--- a/testing/tests/ikev1/ip-pool-db/pretest.dat
+++ b/testing/tests/ikev1/ip-pool-db/pretest.dat
@@ -7,10 +7,10 @@ moon::ipsec pool --addattr nbns --server PH_IP_VENUS 2> /dev/null
moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
dave::iptables-restore < /etc/iptables.rules
+moon::ipsec start
carol::ipsec start
dave::ipsec start
-moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/ip-pool/pretest.dat b/testing/tests/ikev1/ip-pool/pretest.dat
index 3864bdac3..2d09e88ce 100644
--- a/testing/tests/ikev1/ip-pool/pretest.dat
+++ b/testing/tests/ikev1/ip-pool/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/multi-level-ca-cr-init/pretest.dat b/testing/tests/ikev1/multi-level-ca-cr-init/pretest.dat
index 2eebc0f84..bee9bc792 100644
--- a/testing/tests/ikev1/multi-level-ca-cr-init/pretest.dat
+++ b/testing/tests/ikev1/multi-level-ca-cr-init/pretest.dat
@@ -1,6 +1,7 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-moon::sleep 2
+moon::expect-connection alice
+moon::expect-connection venus
moon::ipsec up alice
moon::ipsec up venus
diff --git a/testing/tests/ikev1/multi-level-ca-cr-resp/pretest.dat b/testing/tests/ikev1/multi-level-ca-cr-resp/pretest.dat
index 86dd31e83..be0051e0b 100644
--- a/testing/tests/ikev1/multi-level-ca-cr-resp/pretest.dat
+++ b/testing/tests/ikev1/multi-level-ca-cr-resp/pretest.dat
@@ -1,6 +1,7 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
carol::ipsec up alice
+dave::expect-connection venus
dave::ipsec up venus
diff --git a/testing/tests/ikev1/multi-level-ca/pretest.dat b/testing/tests/ikev1/multi-level-ca/pretest.dat
index 755564cbc..2134d6bea 100644
--- a/testing/tests/ikev1/multi-level-ca/pretest.dat
+++ b/testing/tests/ikev1/multi-level-ca/pretest.dat
@@ -1,8 +1,11 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
+dave::expect-connection alice
+dave::expect-connection venus
dave::ipsec up venus
dave::ipsec up alice
diff --git a/testing/tests/ikev1/nat-rw/pretest.dat b/testing/tests/ikev1/nat-rw/pretest.dat
index d701a1d61..e3d9fc858 100644
--- a/testing/tests/ikev1/nat-rw/pretest.dat
+++ b/testing/tests/ikev1/nat-rw/pretest.dat
@@ -6,8 +6,7 @@ moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-
alice::ipsec start
venus::ipsec start
sun::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-venus::sleep 2
+venus::expect-connection nat-t
venus::ipsec up nat-t
-venus::sleep 2
diff --git a/testing/tests/ikev1/nat-virtual-ip/pretest.dat b/testing/tests/ikev1/nat-virtual-ip/pretest.dat
index 8945d87b9..1732d6efa 100644
--- a/testing/tests/ikev1/nat-virtual-ip/pretest.dat
+++ b/testing/tests/ikev1/nat-virtual-ip/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
-moon::sleep 1
diff --git a/testing/tests/ikev1/net2net-ah/pretest.dat b/testing/tests/ikev1/net2net-ah/pretest.dat
index 81a98fa41..1732d6efa 100644
--- a/testing/tests/ikev1/net2net-ah/pretest.dat
+++ b/testing/tests/ikev1/net2net-ah/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev1/net2net-cert/pretest.dat b/testing/tests/ikev1/net2net-cert/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev1/net2net-cert/pretest.dat
+++ b/testing/tests/ikev1/net2net-cert/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev1/net2net-fragmentation/pretest.dat b/testing/tests/ikev1/net2net-fragmentation/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev1/net2net-fragmentation/pretest.dat
+++ b/testing/tests/ikev1/net2net-fragmentation/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev1/net2net-ntru-cert/pretest.dat b/testing/tests/ikev1/net2net-ntru-cert/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev1/net2net-ntru-cert/pretest.dat
+++ b/testing/tests/ikev1/net2net-ntru-cert/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev1/net2net-psk-fail/pretest.dat b/testing/tests/ikev1/net2net-psk-fail/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/ikev1/net2net-psk-fail/pretest.dat
+++ b/testing/tests/ikev1/net2net-psk-fail/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev1/net2net-psk/pretest.dat b/testing/tests/ikev1/net2net-psk/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/ikev1/net2net-psk/pretest.dat
+++ b/testing/tests/ikev1/net2net-psk/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev1/protoport-dual/pretest.dat b/testing/tests/ikev1/protoport-dual/pretest.dat
index efb2e5712..4759fdb7b 100644
--- a/testing/tests/ikev1/protoport-dual/pretest.dat
+++ b/testing/tests/ikev1/protoport-dual/pretest.dat
@@ -2,6 +2,7 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home-icmp
+carol::expect-connection home-ssh
carol::ipsec up home-icmp
carol::ipsec up home-ssh
diff --git a/testing/tests/ikev1/rw-cert-aggressive/pretest.dat b/testing/tests/ikev1/rw-cert-aggressive/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev1/rw-cert-aggressive/pretest.dat
+++ b/testing/tests/ikev1/rw-cert-aggressive/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/rw-cert-unity/pretest.dat b/testing/tests/ikev1/rw-cert-unity/pretest.dat
index 4fbe475bf..3a1982f8a 100644
--- a/testing/tests/ikev1/rw-cert-unity/pretest.dat
+++ b/testing/tests/ikev1/rw-cert-unity/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/rw-cert/pretest.dat b/testing/tests/ikev1/rw-cert/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev1/rw-cert/pretest.dat
+++ b/testing/tests/ikev1/rw-cert/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/rw-initiator-only/pretest.dat b/testing/tests/ikev1/rw-initiator-only/pretest.dat
index fc7173430..5a972079b 100644
--- a/testing/tests/ikev1/rw-initiator-only/pretest.dat
+++ b/testing/tests/ikev1/rw-initiator-only/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+dave::expect-connection peer
dave::ipsec up peer
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev1/rw-ntru-psk/pretest.dat b/testing/tests/ikev1/rw-ntru-psk/pretest.dat
index 40eaede87..e827687f8 100644
--- a/testing/tests/ikev1/rw-ntru-psk/pretest.dat
+++ b/testing/tests/ikev1/rw-ntru-psk/pretest.dat
@@ -7,7 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/rw-psk-aggressive/pretest.dat b/testing/tests/ikev1/rw-psk-aggressive/pretest.dat
index 44f41f995..e827687f8 100644
--- a/testing/tests/ikev1/rw-psk-aggressive/pretest.dat
+++ b/testing/tests/ikev1/rw-psk-aggressive/pretest.dat
@@ -7,6 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/rw-psk-fqdn/pretest.dat b/testing/tests/ikev1/rw-psk-fqdn/pretest.dat
index 44f41f995..ab5e18da2 100644
--- a/testing/tests/ikev1/rw-psk-fqdn/pretest.dat
+++ b/testing/tests/ikev1/rw-psk-fqdn/pretest.dat
@@ -4,9 +4,10 @@ dave::iptables-restore < /etc/iptables.rules
moon::rm /etc/ipsec.d/cacerts/*
carol::rm /etc/ipsec.d/cacerts/*
dave::rm /etc/ipsec.d/cacerts/*
+moon::ipsec start
carol::ipsec start
dave::ipsec start
-moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/rw-psk-ipv4/pretest.dat b/testing/tests/ikev1/rw-psk-ipv4/pretest.dat
index 44f41f995..e827687f8 100644
--- a/testing/tests/ikev1/rw-psk-ipv4/pretest.dat
+++ b/testing/tests/ikev1/rw-psk-ipv4/pretest.dat
@@ -7,6 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/virtual-ip/pretest.dat b/testing/tests/ikev1/virtual-ip/pretest.dat
index 1765a83cd..2d09e88ce 100644
--- a/testing/tests/ikev1/virtual-ip/pretest.dat
+++ b/testing/tests/ikev1/virtual-ip/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/xauth-id-psk-config/pretest.dat b/testing/tests/ikev1/xauth-id-psk-config/pretest.dat
index 88a91ae86..ab5e18da2 100644
--- a/testing/tests/ikev1/xauth-id-psk-config/pretest.dat
+++ b/testing/tests/ikev1/xauth-id-psk-config/pretest.dat
@@ -7,6 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/xauth-id-rsa-aggressive/pretest.dat b/testing/tests/ikev1/xauth-id-rsa-aggressive/pretest.dat
index e5a06d44c..a55cf37b2 100644
--- a/testing/tests/ikev1/xauth-id-rsa-aggressive/pretest.dat
+++ b/testing/tests/ikev1/xauth-id-rsa-aggressive/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/xauth-id-rsa-config/pretest.dat b/testing/tests/ikev1/xauth-id-rsa-config/pretest.dat
index e5a06d44c..a55cf37b2 100644
--- a/testing/tests/ikev1/xauth-id-rsa-config/pretest.dat
+++ b/testing/tests/ikev1/xauth-id-rsa-config/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/xauth-id-rsa-hybrid/pretest.dat b/testing/tests/ikev1/xauth-id-rsa-hybrid/pretest.dat
index e5a06d44c..a55cf37b2 100644
--- a/testing/tests/ikev1/xauth-id-rsa-hybrid/pretest.dat
+++ b/testing/tests/ikev1/xauth-id-rsa-hybrid/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/xauth-psk/pretest.dat b/testing/tests/ikev1/xauth-psk/pretest.dat
index 88a91ae86..ab5e18da2 100644
--- a/testing/tests/ikev1/xauth-psk/pretest.dat
+++ b/testing/tests/ikev1/xauth-psk/pretest.dat
@@ -7,6 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev1/xauth-rsa-eap-md5-radius/pretest.dat b/testing/tests/ikev1/xauth-rsa-eap-md5-radius/pretest.dat
index 9adc43d3e..c65fbda83 100644
--- a/testing/tests/ikev1/xauth-rsa-eap-md5-radius/pretest.dat
+++ b/testing/tests/ikev1/xauth-rsa-eap-md5-radius/pretest.dat
@@ -3,6 +3,5 @@ carol::iptables-restore < /etc/iptables.rules
alice::radiusd
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/xauth-rsa-radius/pretest.dat b/testing/tests/ikev1/xauth-rsa-radius/pretest.dat
index 9adc43d3e..c65fbda83 100644
--- a/testing/tests/ikev1/xauth-rsa-radius/pretest.dat
+++ b/testing/tests/ikev1/xauth-rsa-radius/pretest.dat
@@ -3,6 +3,5 @@ carol::iptables-restore < /etc/iptables.rules
alice::radiusd
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev1/xauth-rsa/pretest.dat b/testing/tests/ikev1/xauth-rsa/pretest.dat
index e5a06d44c..a55cf37b2 100644
--- a/testing/tests/ikev1/xauth-rsa/pretest.dat
+++ b/testing/tests/ikev1/xauth-rsa/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/acert-cached/pretest.dat b/testing/tests/ikev2/acert-cached/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev2/acert-cached/pretest.dat
+++ b/testing/tests/ikev2/acert-cached/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/acert-fallback/pretest.dat b/testing/tests/ikev2/acert-fallback/pretest.dat
index baacc1605..de4acbbf0 100644
--- a/testing/tests/ikev2/acert-fallback/pretest.dat
+++ b/testing/tests/ikev2/acert-fallback/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/acert-inline/pretest.dat b/testing/tests/ikev2/acert-inline/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev2/acert-inline/pretest.dat
+++ b/testing/tests/ikev2/acert-inline/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/after-2038-certs/pretest.dat b/testing/tests/ikev2/after-2038-certs/pretest.dat
index baacc1605..de4acbbf0 100644
--- a/testing/tests/ikev2/after-2038-certs/pretest.dat
+++ b/testing/tests/ikev2/after-2038-certs/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-3des-md5/pretest.dat b/testing/tests/ikev2/alg-3des-md5/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-3des-md5/pretest.dat
+++ b/testing/tests/ikev2/alg-3des-md5/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-aes-ccm/pretest.dat b/testing/tests/ikev2/alg-aes-ccm/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-aes-ccm/pretest.dat
+++ b/testing/tests/ikev2/alg-aes-ccm/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-aes-ctr/pretest.dat b/testing/tests/ikev2/alg-aes-ctr/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-aes-ctr/pretest.dat
+++ b/testing/tests/ikev2/alg-aes-ctr/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-aes-gcm/pretest.dat b/testing/tests/ikev2/alg-aes-gcm/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-aes-gcm/pretest.dat
+++ b/testing/tests/ikev2/alg-aes-gcm/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-aes-xcbc/pretest.dat b/testing/tests/ikev2/alg-aes-xcbc/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-aes-xcbc/pretest.dat
+++ b/testing/tests/ikev2/alg-aes-xcbc/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-blowfish/pretest.dat b/testing/tests/ikev2/alg-blowfish/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev2/alg-blowfish/pretest.dat
+++ b/testing/tests/ikev2/alg-blowfish/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/alg-chacha20poly1305/pretest.dat b/testing/tests/ikev2/alg-chacha20poly1305/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-chacha20poly1305/pretest.dat
+++ b/testing/tests/ikev2/alg-chacha20poly1305/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-modp-subgroup/pretest.dat b/testing/tests/ikev2/alg-modp-subgroup/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev2/alg-modp-subgroup/pretest.dat
+++ b/testing/tests/ikev2/alg-modp-subgroup/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/alg-sha256-96/pretest.dat b/testing/tests/ikev2/alg-sha256-96/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-sha256-96/pretest.dat
+++ b/testing/tests/ikev2/alg-sha256-96/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-sha256/pretest.dat b/testing/tests/ikev2/alg-sha256/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-sha256/pretest.dat
+++ b/testing/tests/ikev2/alg-sha256/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-sha384/pretest.dat b/testing/tests/ikev2/alg-sha384/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-sha384/pretest.dat
+++ b/testing/tests/ikev2/alg-sha384/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/alg-sha512/pretest.dat b/testing/tests/ikev2/alg-sha512/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/alg-sha512/pretest.dat
+++ b/testing/tests/ikev2/alg-sha512/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/any-interface/pretest.dat b/testing/tests/ikev2/any-interface/pretest.dat
index 0a6ce8be4..a122073e4 100644
--- a/testing/tests/ikev2/any-interface/pretest.dat
+++ b/testing/tests/ikev2/any-interface/pretest.dat
@@ -4,7 +4,8 @@ alice::ipsec start
moon::ipsec start
sun::ipsec start
bob::ipsec start
-moon::sleep 2
+moon::expect-connection alice
moon::ping -n -c 3 -s 8184 -p deadbeef PH_IP_ALICE
moon::ping -n -c 3 -s 8184 -p deadbeef PH_IP_SUN
+bob::expect-connection sun
bob::ping -n -c 3 -s 8184 -p deadbeef PH_IP_SUN1
diff --git a/testing/tests/ikev2/compress/pretest.dat b/testing/tests/ikev2/compress/pretest.dat
index 29a90355f..1fd37b6a8 100644
--- a/testing/tests/ikev2/compress/pretest.dat
+++ b/testing/tests/ikev2/compress/pretest.dat
@@ -2,5 +2,5 @@ carol::iptables-restore < /etc/iptables.rules
moon::iptables-restore < /etc/iptables.rules
carol::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/config-payload-swapped/pretest.dat b/testing/tests/ikev2/config-payload-swapped/pretest.dat
index 3864bdac3..2d09e88ce 100644
--- a/testing/tests/ikev2/config-payload-swapped/pretest.dat
+++ b/testing/tests/ikev2/config-payload-swapped/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/config-payload/pretest.dat b/testing/tests/ikev2/config-payload/pretest.dat
index 3864bdac3..2d09e88ce 100644
--- a/testing/tests/ikev2/config-payload/pretest.dat
+++ b/testing/tests/ikev2/config-payload/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/critical-extension/pretest.dat b/testing/tests/ikev2/critical-extension/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev2/critical-extension/pretest.dat
+++ b/testing/tests/ikev2/critical-extension/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/crl-from-cache/pretest.dat b/testing/tests/ikev2/crl-from-cache/pretest.dat
index acdb265ed..d4141a30c 100644
--- a/testing/tests/ikev2/crl-from-cache/pretest.dat
+++ b/testing/tests/ikev2/crl-from-cache/pretest.dat
@@ -4,5 +4,5 @@ carol::wget -q http://crl.strongswan.org/strongswan.crl
carol::mv strongswan.crl /etc/ipsec.d/crls/5da7dd700651327ee7b66db3b5e5e060ea2e4def.crl
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/crl-ldap/pretest.dat b/testing/tests/ikev2/crl-ldap/pretest.dat
index 8ffa9d3ed..4eed5e073 100644
--- a/testing/tests/ikev2/crl-ldap/pretest.dat
+++ b/testing/tests/ikev2/crl-ldap/pretest.dat
@@ -3,6 +3,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 3
diff --git a/testing/tests/ikev2/crl-revoked/pretest.dat b/testing/tests/ikev2/crl-revoked/pretest.dat
index 8984dcbcf..3a1982f8a 100644
--- a/testing/tests/ikev2/crl-revoked/pretest.dat
+++ b/testing/tests/ikev2/crl-revoked/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/crl-to-cache/pretest.dat b/testing/tests/ikev2/crl-to-cache/pretest.dat
index d92333d86..3a1982f8a 100644
--- a/testing/tests/ikev2/crl-to-cache/pretest.dat
+++ b/testing/tests/ikev2/crl-to-cache/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/default-keys/pretest.dat b/testing/tests/ikev2/default-keys/pretest.dat
index ef5f67097..9e291d291 100644
--- a/testing/tests/ikev2/default-keys/pretest.dat
+++ b/testing/tests/ikev2/default-keys/pretest.dat
@@ -10,10 +10,10 @@ moon::rm /etc/ipsec.d/private/*
moon::rm /etc/ipsec.d/certs/*
moon::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
-moon::sleep 5
+moon::expect-connection carol
moon::scp /etc/ipsec.d/certs/selfCert.der carol:/etc/ipsec.d/certs/peerCert.der
moon::scp carol:/etc/ipsec.d/certs/selfCert.der /etc/ipsec.d/certs/peerCert.der
moon::ipsec reload
carol::ipsec reload
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/dhcp-dynamic/pretest.dat b/testing/tests/ikev2/dhcp-dynamic/pretest.dat
index 5670a2e89..3b22f29f2 100644
--- a/testing/tests/ikev2/dhcp-dynamic/pretest.dat
+++ b/testing/tests/ikev2/dhcp-dynamic/pretest.dat
@@ -6,7 +6,7 @@ venus::/etc/init.d/isc-dhcp-server start 2> /dev/null
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/dhcp-static-client-id/pretest.dat b/testing/tests/ikev2/dhcp-static-client-id/pretest.dat
index 5670a2e89..8eafe1a9e 100644
--- a/testing/tests/ikev2/dhcp-static-client-id/pretest.dat
+++ b/testing/tests/ikev2/dhcp-static-client-id/pretest.dat
@@ -6,7 +6,7 @@ venus::/etc/init.d/isc-dhcp-server start 2> /dev/null
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+carol::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/dhcp-static-mac/pretest.dat b/testing/tests/ikev2/dhcp-static-mac/pretest.dat
index 5670a2e89..3b22f29f2 100644
--- a/testing/tests/ikev2/dhcp-static-mac/pretest.dat
+++ b/testing/tests/ikev2/dhcp-static-mac/pretest.dat
@@ -6,7 +6,7 @@ venus::/etc/init.d/isc-dhcp-server start 2> /dev/null
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/double-nat-net/pretest.dat b/testing/tests/ikev2/double-nat-net/pretest.dat
index 17a4fe5eb..d300a276f 100644
--- a/testing/tests/ikev2/double-nat-net/pretest.dat
+++ b/testing/tests/ikev2/double-nat-net/pretest.dat
@@ -7,6 +7,5 @@ sun::iptables -t nat -A PREROUTING -i eth0 -s PH_IP_MOON -p udp -j DNAT --to-des
sun::ip route add 10.1.0.0/16 via PH_IP_BOB
alice::ipsec start
bob::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-alice::sleep 1
diff --git a/testing/tests/ikev2/double-nat/pretest.dat b/testing/tests/ikev2/double-nat/pretest.dat
index 65f18b756..6a861d29f 100644
--- a/testing/tests/ikev2/double-nat/pretest.dat
+++ b/testing/tests/ikev2/double-nat/pretest.dat
@@ -6,6 +6,5 @@ sun::iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p tcp -j SNAT --to-s
sun::iptables -t nat -A PREROUTING -i eth0 -s PH_IP_MOON -p udp -j DNAT --to-destination PH_IP_BOB
alice::ipsec start
bob::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-alice::sleep 1
diff --git a/testing/tests/ikev2/dpd-clear/pretest.dat b/testing/tests/ikev2/dpd-clear/pretest.dat
index 14ed95322..3a1982f8a 100644
--- a/testing/tests/ikev2/dpd-clear/pretest.dat
+++ b/testing/tests/ikev2/dpd-clear/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/dpd-hold/pretest.dat b/testing/tests/ikev2/dpd-hold/pretest.dat
index 14ed95322..3a1982f8a 100644
--- a/testing/tests/ikev2/dpd-hold/pretest.dat
+++ b/testing/tests/ikev2/dpd-hold/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/dpd-restart/evaltest.dat b/testing/tests/ikev2/dpd-restart/evaltest.dat
index 744307998..25c54df95 100644
--- a/testing/tests/ikev2/dpd-restart/evaltest.dat
+++ b/testing/tests/ikev2/dpd-restart/evaltest.dat
@@ -8,6 +8,6 @@ carol::cat /var/log/daemon.log::retransmit.*of request::YES
carol::cat /var/log/daemon.log::giving up after.*retransmits::YES
carol::iptables -D INPUT -i eth0 -s PH_IP_MOON -j DROP::no output expected::NO
moon:: iptables -D INPUT -i eth0 -s PH_IP_CAROL -j DROP::no output expected::NO
-carol::sleep 1::no output expected::NO
+carol::sleep 2::no output expected::NO
carol::ipsec status 2> /dev/null::home.*INSTALLED, TUNNEL::YES
moon:: ipsec status 2> /dev/null::rw.*INSTALLED, TUNNEL::YES
diff --git a/testing/tests/ikev2/dpd-restart/pretest.dat b/testing/tests/ikev2/dpd-restart/pretest.dat
index 14ed95322..3a1982f8a 100644
--- a/testing/tests/ikev2/dpd-restart/pretest.dat
+++ b/testing/tests/ikev2/dpd-restart/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/dynamic-initiator/posttest.dat b/testing/tests/ikev2/dynamic-initiator/posttest.dat
index 83063a23f..715bb9482 100644
--- a/testing/tests/ikev2/dynamic-initiator/posttest.dat
+++ b/testing/tests/ikev2/dynamic-initiator/posttest.dat
@@ -1,6 +1,5 @@
dave::ipsec stop
carol::ipsec stop
-dave::sleep 1
moon::ipsec stop
moon::iptables-restore < /etc/iptables.flush
carol::iptables-restore < /etc/iptables.flush
diff --git a/testing/tests/ikev2/dynamic-initiator/pretest.dat b/testing/tests/ikev2/dynamic-initiator/pretest.dat
index 3e1cfce77..f354efe51 100644
--- a/testing/tests/ikev2/dynamic-initiator/pretest.dat
+++ b/testing/tests/ikev2/dynamic-initiator/pretest.dat
@@ -4,10 +4,9 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection moon
carol::ipsec up moon
-carol::sleep 1
carol::iptables -D INPUT -i eth0 -p udp --dport 500 --sport 500 -j ACCEPT
carol::iptables -D OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
+dave::expect-connection moon
dave::ipsec up moon
-dave::sleep 2
diff --git a/testing/tests/ikev2/dynamic-two-peers/posttest.dat b/testing/tests/ikev2/dynamic-two-peers/posttest.dat
index 7b2609846..119c8e45a 100644
--- a/testing/tests/ikev2/dynamic-two-peers/posttest.dat
+++ b/testing/tests/ikev2/dynamic-two-peers/posttest.dat
@@ -1,6 +1,5 @@
carol::ipsec stop
dave::ipsec stop
-moon::sleep 1
moon::ipsec stop
moon::mv /etc/hosts.ori /etc/hosts
moon::iptables-restore < /etc/iptables.flush
diff --git a/testing/tests/ikev2/dynamic-two-peers/pretest.dat b/testing/tests/ikev2/dynamic-two-peers/pretest.dat
index 4bb2a4686..ee0b156dd 100644
--- a/testing/tests/ikev2/dynamic-two-peers/pretest.dat
+++ b/testing/tests/ikev2/dynamic-two-peers/pretest.dat
@@ -6,7 +6,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection moon
carol::ipsec up moon
+dave::expect-connection moon
dave::ipsec up moon
-carol::sleep 1
diff --git a/testing/tests/ikev2/esp-alg-aes-gmac/pretest.dat b/testing/tests/ikev2/esp-alg-aes-gmac/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/ikev2/esp-alg-aes-gmac/pretest.dat
+++ b/testing/tests/ikev2/esp-alg-aes-gmac/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/esp-alg-md5-128/pretest.dat b/testing/tests/ikev2/esp-alg-md5-128/pretest.dat
index 886fdf55c..de4acbbf0 100644
--- a/testing/tests/ikev2/esp-alg-md5-128/pretest.dat
+++ b/testing/tests/ikev2/esp-alg-md5-128/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/esp-alg-null/pretest.dat b/testing/tests/ikev2/esp-alg-null/pretest.dat
index 886fdf55c..de4acbbf0 100644
--- a/testing/tests/ikev2/esp-alg-null/pretest.dat
+++ b/testing/tests/ikev2/esp-alg-null/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/esp-alg-sha1-160/pretest.dat b/testing/tests/ikev2/esp-alg-sha1-160/pretest.dat
index 886fdf55c..de4acbbf0 100644
--- a/testing/tests/ikev2/esp-alg-sha1-160/pretest.dat
+++ b/testing/tests/ikev2/esp-alg-sha1-160/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/farp/pretest.dat b/testing/tests/ikev2/farp/pretest.dat
index f0254da6c..1a982288d 100644
--- a/testing/tests/ikev2/farp/pretest.dat
+++ b/testing/tests/ikev2/farp/pretest.dat
@@ -6,7 +6,7 @@ alice::arp -d 10.1.0.40
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/force-udp-encaps/pretest.dat b/testing/tests/ikev2/force-udp-encaps/pretest.dat
index 7be66867a..87a7764cf 100644
--- a/testing/tests/ikev2/force-udp-encaps/pretest.dat
+++ b/testing/tests/ikev2/force-udp-encaps/pretest.dat
@@ -4,7 +4,5 @@ sun::ip route add 10.1.0.0/16 via PH_IP_MOON
winnetou::ip route add 10.1.0.0/16 via PH_IP_MOON
alice::ipsec start
sun::ipsec start
-alice::sleep 4
+alice::expect-connection nat-t
alice::ipsec up nat-t
-alice::sleep 1
-
diff --git a/testing/tests/ikev2/forecast/pretest.dat b/testing/tests/ikev2/forecast/pretest.dat
index 206bf5b64..68a0c2cda 100644
--- a/testing/tests/ikev2/forecast/pretest.dat
+++ b/testing/tests/ikev2/forecast/pretest.dat
@@ -1,7 +1,7 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/host2host-ah/pretest.dat b/testing/tests/ikev2/host2host-ah/pretest.dat
index 99789b90f..997a48167 100644
--- a/testing/tests/ikev2/host2host-ah/pretest.dat
+++ b/testing/tests/ikev2/host2host-ah/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/ikev2/host2host-cert/pretest.dat b/testing/tests/ikev2/host2host-cert/pretest.dat
index 3bce9f6e5..997a48167 100644
--- a/testing/tests/ikev2/host2host-cert/pretest.dat
+++ b/testing/tests/ikev2/host2host-cert/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/ikev2/host2host-swapped/pretest.dat b/testing/tests/ikev2/host2host-swapped/pretest.dat
index 3bce9f6e5..997a48167 100644
--- a/testing/tests/ikev2/host2host-swapped/pretest.dat
+++ b/testing/tests/ikev2/host2host-swapped/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/ikev2/host2host-transport/pretest.dat b/testing/tests/ikev2/host2host-transport/pretest.dat
index 99789b90f..997a48167 100644
--- a/testing/tests/ikev2/host2host-transport/pretest.dat
+++ b/testing/tests/ikev2/host2host-transport/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/ikev2/inactivity-timeout/pretest.dat b/testing/tests/ikev2/inactivity-timeout/pretest.dat
index b949aaeaf..ac7b8d978 100644
--- a/testing/tests/ikev2/inactivity-timeout/pretest.dat
+++ b/testing/tests/ikev2/inactivity-timeout/pretest.dat
@@ -1,6 +1,5 @@
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/ip-pool-db/pretest.dat b/testing/tests/ikev2/ip-pool-db/pretest.dat
index 2327eb983..0e3175abc 100644
--- a/testing/tests/ikev2/ip-pool-db/pretest.dat
+++ b/testing/tests/ikev2/ip-pool-db/pretest.dat
@@ -7,10 +7,10 @@ moon::ipsec pool --addattr nbns --server PH_IP_VENUS 2> /dev/null
moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
dave::iptables-restore < /etc/iptables.rules
+moon::ipsec start
carol::ipsec start
dave::ipsec start
-moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/ip-pool-wish/pretest.dat b/testing/tests/ikev2/ip-pool-wish/pretest.dat
index 1466fd2f2..2d09e88ce 100644
--- a/testing/tests/ikev2/ip-pool-wish/pretest.dat
+++ b/testing/tests/ikev2/ip-pool-wish/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/ip-pool/pretest.dat b/testing/tests/ikev2/ip-pool/pretest.dat
index 3864bdac3..2d09e88ce 100644
--- a/testing/tests/ikev2/ip-pool/pretest.dat
+++ b/testing/tests/ikev2/ip-pool/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/ip-split-pools-db/pretest.dat b/testing/tests/ikev2/ip-split-pools-db/pretest.dat
index c5af81b38..77a79cf8c 100644
--- a/testing/tests/ikev2/ip-split-pools-db/pretest.dat
+++ b/testing/tests/ikev2/ip-split-pools-db/pretest.dat
@@ -6,7 +6,7 @@ moon::ipsec pool --status 2> /dev/null
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/ip-two-pools-db/pretest.dat b/testing/tests/ikev2/ip-two-pools-db/pretest.dat
index bb36a2630..3dfd974ef 100644
--- a/testing/tests/ikev2/ip-two-pools-db/pretest.dat
+++ b/testing/tests/ikev2/ip-two-pools-db/pretest.dat
@@ -18,9 +18,11 @@ venus::ipsec start
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
+alice::expect-connection home
alice::ipsec up home
+venus::expect-connection home
venus::ipsec up home
-alice::sleep 1
diff --git a/testing/tests/ikev2/ip-two-pools-mixed/pretest.dat b/testing/tests/ikev2/ip-two-pools-mixed/pretest.dat
index 8ebfdc740..c77347632 100644
--- a/testing/tests/ikev2/ip-two-pools-mixed/pretest.dat
+++ b/testing/tests/ikev2/ip-two-pools-mixed/pretest.dat
@@ -4,10 +4,10 @@ moon::ipsec pool --add intpool --start 10.4.0.1 --end 10.4.1.244 --timeout 0 2>
moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
alice::iptables-restore < /etc/iptables.rules
-carol::ipsec start
moon::ipsec start
+carol::ipsec start
alice::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+alice::expect-connection home
alice::ipsec up home
-alice::sleep 1
diff --git a/testing/tests/ikev2/ip-two-pools-v4v6-db/pretest.dat b/testing/tests/ikev2/ip-two-pools-v4v6-db/pretest.dat
index 466a5eaec..2fbf41013 100644
--- a/testing/tests/ikev2/ip-two-pools-v4v6-db/pretest.dat
+++ b/testing/tests/ikev2/ip-two-pools-v4v6-db/pretest.dat
@@ -5,5 +5,5 @@ moon::ipsec pool --add v6_pool --start fec3:\:1 --end fec3:\:fe --timeout 48 2>
alice::ip -6 route add default via fec1:\:1
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ip-two-pools-v4v6/pretest.dat b/testing/tests/ikev2/ip-two-pools-v4v6/pretest.dat
index 04139badf..7eb81b60c 100644
--- a/testing/tests/ikev2/ip-two-pools-v4v6/pretest.dat
+++ b/testing/tests/ikev2/ip-two-pools-v4v6/pretest.dat
@@ -1,5 +1,5 @@
alice::ip -6 route add default via fec1:\:1
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ip-two-pools/pretest.dat b/testing/tests/ikev2/ip-two-pools/pretest.dat
index 4e8b639f4..56c1785cc 100644
--- a/testing/tests/ikev2/ip-two-pools/pretest.dat
+++ b/testing/tests/ikev2/ip-two-pools/pretest.dat
@@ -4,7 +4,7 @@ alice::iptables-restore < /etc/iptables.rules
carol::ipsec start
moon::ipsec start
alice::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+alice::expect-connection home
alice::ipsec up home
-alice::sleep 1
diff --git a/testing/tests/ikev2/lookip/pretest.dat b/testing/tests/ikev2/lookip/pretest.dat
index 3864bdac3..2d09e88ce 100644
--- a/testing/tests/ikev2/lookip/pretest.dat
+++ b/testing/tests/ikev2/lookip/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/mobike-nat/pretest.dat b/testing/tests/ikev2/mobike-nat/pretest.dat
index fde195daa..68df1b533 100644
--- a/testing/tests/ikev2/mobike-nat/pretest.dat
+++ b/testing/tests/ikev2/mobike-nat/pretest.dat
@@ -5,6 +5,5 @@ moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p udp -j SNAT --to-
moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-source PH_IP_MOON:2000-2100
alice::ipsec start
sun::ipsec start
-alice::sleep 2
+alice::expect-connection mobike
alice::ipsec up mobike
-alice::sleep 1
diff --git a/testing/tests/ikev2/mobike-virtual-ip/pretest.dat b/testing/tests/ikev2/mobike-virtual-ip/pretest.dat
index 067c1a1ec..8197296ee 100644
--- a/testing/tests/ikev2/mobike-virtual-ip/pretest.dat
+++ b/testing/tests/ikev2/mobike-virtual-ip/pretest.dat
@@ -4,6 +4,5 @@ sun::iptables-restore < /etc/iptables.rules
sun::ip route add 10.1.0.0/16 via PH_IP_MOON
alice::ipsec start
sun::ipsec start
-alice::sleep 2
+alice::expect-connection mobike
alice::ipsec up mobike
-alice::sleep 1
diff --git a/testing/tests/ikev2/mobike/pretest.dat b/testing/tests/ikev2/mobike/pretest.dat
index 067c1a1ec..8197296ee 100644
--- a/testing/tests/ikev2/mobike/pretest.dat
+++ b/testing/tests/ikev2/mobike/pretest.dat
@@ -4,6 +4,5 @@ sun::iptables-restore < /etc/iptables.rules
sun::ip route add 10.1.0.0/16 via PH_IP_MOON
alice::ipsec start
sun::ipsec start
-alice::sleep 2
+alice::expect-connection mobike
alice::ipsec up mobike
-alice::sleep 1
diff --git a/testing/tests/ikev2/mult-auth-rsa-eap-sim-id/pretest.dat b/testing/tests/ikev2/mult-auth-rsa-eap-sim-id/pretest.dat
index eb69d2e45..07ffe10fa 100644
--- a/testing/tests/ikev2/mult-auth-rsa-eap-sim-id/pretest.dat
+++ b/testing/tests/ikev2/mult-auth-rsa-eap-sim-id/pretest.dat
@@ -8,7 +8,7 @@ alice::radiusd
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/multi-level-ca-cr-init/pretest.dat b/testing/tests/ikev2/multi-level-ca-cr-init/pretest.dat
index 2eebc0f84..bee9bc792 100644
--- a/testing/tests/ikev2/multi-level-ca-cr-init/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca-cr-init/pretest.dat
@@ -1,6 +1,7 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-moon::sleep 2
+moon::expect-connection alice
+moon::expect-connection venus
moon::ipsec up alice
moon::ipsec up venus
diff --git a/testing/tests/ikev2/multi-level-ca-cr-resp/pretest.dat b/testing/tests/ikev2/multi-level-ca-cr-resp/pretest.dat
index 86dd31e83..be0051e0b 100644
--- a/testing/tests/ikev2/multi-level-ca-cr-resp/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca-cr-resp/pretest.dat
@@ -1,6 +1,7 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
carol::ipsec up alice
+dave::expect-connection venus
dave::ipsec up venus
diff --git a/testing/tests/ikev2/multi-level-ca-ldap/pretest.dat b/testing/tests/ikev2/multi-level-ca-ldap/pretest.dat
index 41319ae4d..94de99a97 100644
--- a/testing/tests/ikev2/multi-level-ca-ldap/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca-ldap/pretest.dat
@@ -3,8 +3,11 @@ moon::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
+dave::expect-connection alice
+dave::expect-connection venus
dave::ipsec up venus
dave::ipsec up alice
diff --git a/testing/tests/ikev2/multi-level-ca-loop/pretest.dat b/testing/tests/ikev2/multi-level-ca-loop/pretest.dat
index bb538c160..3407743b3 100644
--- a/testing/tests/ikev2/multi-level-ca-loop/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca-loop/pretest.dat
@@ -1,5 +1,5 @@
moon::rm /etc/ipsec.d/cacerts/strongswanCert.pem
carol::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
carol::ipsec up alice
diff --git a/testing/tests/ikev2/multi-level-ca-pathlen/pretest.dat b/testing/tests/ikev2/multi-level-ca-pathlen/pretest.dat
index e209e60ff..8230de058 100644
--- a/testing/tests/ikev2/multi-level-ca-pathlen/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca-pathlen/pretest.dat
@@ -1,4 +1,4 @@
carol::ipsec start
moon::ipsec start
-carol::sleep 2
-carol::ipsec up home
+carol::expect-connection home
+carol::ipsec up home
diff --git a/testing/tests/ikev2/multi-level-ca-revoked/pretest.dat b/testing/tests/ikev2/multi-level-ca-revoked/pretest.dat
index d92333d86..3a1982f8a 100644
--- a/testing/tests/ikev2/multi-level-ca-revoked/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca-revoked/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/multi-level-ca-strict/pretest.dat b/testing/tests/ikev2/multi-level-ca-strict/pretest.dat
index 755564cbc..2134d6bea 100644
--- a/testing/tests/ikev2/multi-level-ca-strict/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca-strict/pretest.dat
@@ -1,8 +1,11 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
+dave::expect-connection alice
+dave::expect-connection venus
dave::ipsec up venus
dave::ipsec up alice
diff --git a/testing/tests/ikev2/multi-level-ca/posttest.dat b/testing/tests/ikev2/multi-level-ca/posttest.dat
index 1646d5ed2..0f3f1ff89 100644
--- a/testing/tests/ikev2/multi-level-ca/posttest.dat
+++ b/testing/tests/ikev2/multi-level-ca/posttest.dat
@@ -2,4 +2,3 @@ moon::ipsec stop
carol::ipsec stop
dave::ipsec stop
moon::rm /etc/ipsec.d/cacerts/*
-
diff --git a/testing/tests/ikev2/multi-level-ca/pretest.dat b/testing/tests/ikev2/multi-level-ca/pretest.dat
index 755564cbc..2134d6bea 100644
--- a/testing/tests/ikev2/multi-level-ca/pretest.dat
+++ b/testing/tests/ikev2/multi-level-ca/pretest.dat
@@ -1,8 +1,11 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
+dave::expect-connection alice
+dave::expect-connection venus
dave::ipsec up venus
dave::ipsec up alice
diff --git a/testing/tests/ikev2/nat-rw-mark/pretest.dat b/testing/tests/ikev2/nat-rw-mark/pretest.dat
index 6cddfd4fe..9d68e3c6e 100644
--- a/testing/tests/ikev2/nat-rw-mark/pretest.dat
+++ b/testing/tests/ikev2/nat-rw-mark/pretest.dat
@@ -13,8 +13,7 @@ sun::iptables -t mangle -A PREROUTING -d PH_IP_DAVE10 -j MARK --set-mark 20
sun::ipsec start
alice::ipsec start
venus::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-venus::sleep 2
+venus::expect-connection nat-t
venus::ipsec up nat-t
-venus::sleep 2
diff --git a/testing/tests/ikev2/nat-rw-psk/pretest.dat b/testing/tests/ikev2/nat-rw-psk/pretest.dat
index c5d091f32..e52bc9d9c 100644
--- a/testing/tests/ikev2/nat-rw-psk/pretest.dat
+++ b/testing/tests/ikev2/nat-rw-psk/pretest.dat
@@ -9,8 +9,7 @@ sun::rm /etc/ipsec.d/cacerts/*
sun::ipsec start
alice::ipsec start
venus::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-venus::sleep 2
+venus::expect-connection nat-t
venus::ipsec up nat-t
-venus::sleep 2
diff --git a/testing/tests/ikev2/nat-rw/pretest.dat b/testing/tests/ikev2/nat-rw/pretest.dat
index 12676f7ac..e3d9fc858 100644
--- a/testing/tests/ikev2/nat-rw/pretest.dat
+++ b/testing/tests/ikev2/nat-rw/pretest.dat
@@ -6,8 +6,7 @@ moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-
alice::ipsec start
venus::ipsec start
sun::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-venus::sleep 2
+venus::expect-connection nat-t
venus::ipsec up nat-t
-venus::sleep 2
diff --git a/testing/tests/ikev2/nat-virtual-ip/pretest.dat b/testing/tests/ikev2/nat-virtual-ip/pretest.dat
index 8945d87b9..1732d6efa 100644
--- a/testing/tests/ikev2/nat-virtual-ip/pretest.dat
+++ b/testing/tests/ikev2/nat-virtual-ip/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
-moon::sleep 1
diff --git a/testing/tests/ikev2/net2net-ah/pretest.dat b/testing/tests/ikev2/net2net-ah/pretest.dat
index 81a98fa41..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-ah/pretest.dat
+++ b/testing/tests/ikev2/net2net-ah/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-cert-sha2/pretest.dat b/testing/tests/ikev2/net2net-cert-sha2/pretest.dat
index 81a98fa41..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-cert-sha2/pretest.dat
+++ b/testing/tests/ikev2/net2net-cert-sha2/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-cert/pretest.dat b/testing/tests/ikev2/net2net-cert/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-cert/pretest.dat
+++ b/testing/tests/ikev2/net2net-cert/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-dnscert/pretest.dat b/testing/tests/ikev2/net2net-dnscert/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/ikev2/net2net-dnscert/pretest.dat
+++ b/testing/tests/ikev2/net2net-dnscert/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-dnssec/pretest.dat b/testing/tests/ikev2/net2net-dnssec/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/ikev2/net2net-dnssec/pretest.dat
+++ b/testing/tests/ikev2/net2net-dnssec/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-esn/pretest.dat b/testing/tests/ikev2/net2net-esn/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-esn/pretest.dat
+++ b/testing/tests/ikev2/net2net-esn/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-ntru-bandwidth/pretest.dat b/testing/tests/ikev2/net2net-ntru-bandwidth/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-ntru-bandwidth/pretest.dat
+++ b/testing/tests/ikev2/net2net-ntru-bandwidth/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-ntru-cert/pretest.dat b/testing/tests/ikev2/net2net-ntru-cert/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-ntru-cert/pretest.dat
+++ b/testing/tests/ikev2/net2net-ntru-cert/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-pgp-v3/pretest.dat b/testing/tests/ikev2/net2net-pgp-v3/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/ikev2/net2net-pgp-v3/pretest.dat
+++ b/testing/tests/ikev2/net2net-pgp-v3/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-pgp-v4/pretest.dat b/testing/tests/ikev2/net2net-pgp-v4/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/ikev2/net2net-pgp-v4/pretest.dat
+++ b/testing/tests/ikev2/net2net-pgp-v4/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-pkcs12/pretest.dat b/testing/tests/ikev2/net2net-pkcs12/pretest.dat
index 3492238f0..fd1ce379f 100644
--- a/testing/tests/ikev2/net2net-pkcs12/pretest.dat
+++ b/testing/tests/ikev2/net2net-pkcs12/pretest.dat
@@ -6,5 +6,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-psk-dscp/pretest.dat b/testing/tests/ikev2/net2net-psk-dscp/pretest.dat
index 0495890dd..ef3eb9e06 100644
--- a/testing/tests/ikev2/net2net-psk-dscp/pretest.dat
+++ b/testing/tests/ikev2/net2net-psk-dscp/pretest.dat
@@ -9,9 +9,10 @@ moon::iptables -t mangle -A PREROUTING -m dscp --dscp-class EF -j MARK --set-mar
bob::iptables -t mangle -A OUTPUT -d PH_IP_ALICE -p icmp -j DSCP --set-dscp-class BE
bob::iptables -t mangle -A OUTPUT -d PH_IP_VENUS -p icmp -j DSCP --set-dscp-class EF
sun::iptables -t mangle -A PREROUTING -m dscp --dscp-class BE -j MARK --set-mark 10
-sun::iptables -t mangle -A PREROUTING -m dscp --dscp-class EF -j MARK --set-mark 20
+sun::iptables -t mangle -A PREROUTING -m dscp --dscp-class EF -j MARK --set-mark 20
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection dscp-be
+moon::expect-connection dscp-ef
moon::ipsec up dscp-be
moon::ipsec up dscp-ef
diff --git a/testing/tests/ikev2/net2net-psk-fail/pretest.dat b/testing/tests/ikev2/net2net-psk-fail/pretest.dat
index cb9282595..f2cbf6a0c 100644
--- a/testing/tests/ikev2/net2net-psk-fail/pretest.dat
+++ b/testing/tests/ikev2/net2net-psk-fail/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-psk/pretest.dat b/testing/tests/ikev2/net2net-psk/pretest.dat
index cb9282595..f2cbf6a0c 100644
--- a/testing/tests/ikev2/net2net-psk/pretest.dat
+++ b/testing/tests/ikev2/net2net-psk/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-rfc3779/pretest.dat b/testing/tests/ikev2/net2net-rfc3779/pretest.dat
index 9fe2860b9..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-rfc3779/pretest.dat
+++ b/testing/tests/ikev2/net2net-rfc3779/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
-moon::sleep 1
diff --git a/testing/tests/ikev2/net2net-route/pretest.dat b/testing/tests/ikev2/net2net-route/pretest.dat
index e4ee3fac2..fadfeab73 100644
--- a/testing/tests/ikev2/net2net-route/pretest.dat
+++ b/testing/tests/ikev2/net2net-route/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
alice::ping -c 10 PH_IP_BOB
diff --git a/testing/tests/ikev2/net2net-rsa/pretest.dat b/testing/tests/ikev2/net2net-rsa/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/ikev2/net2net-rsa/pretest.dat
+++ b/testing/tests/ikev2/net2net-rsa/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-same-nets/pretest.dat b/testing/tests/ikev2/net2net-same-nets/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/ikev2/net2net-same-nets/pretest.dat
+++ b/testing/tests/ikev2/net2net-same-nets/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/ikev2/net2net-start/pretest.dat b/testing/tests/ikev2/net2net-start/pretest.dat
index 9d23c553e..b3f371041 100644
--- a/testing/tests/ikev2/net2net-start/pretest.dat
+++ b/testing/tests/ikev2/net2net-start/pretest.dat
@@ -1,6 +1,5 @@
moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
sun::ipsec start
-sun::sleep 2
moon::ipsec start
-moon::sleep 3
+moon::sleep 1
diff --git a/testing/tests/ikev2/ocsp-local-cert/pretest.dat b/testing/tests/ikev2/ocsp-local-cert/pretest.dat
index d92333d86..3a1982f8a 100644
--- a/testing/tests/ikev2/ocsp-local-cert/pretest.dat
+++ b/testing/tests/ikev2/ocsp-local-cert/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ocsp-multi-level/pretest.dat b/testing/tests/ikev2/ocsp-multi-level/pretest.dat
index 86dd31e83..be0051e0b 100644
--- a/testing/tests/ikev2/ocsp-multi-level/pretest.dat
+++ b/testing/tests/ikev2/ocsp-multi-level/pretest.dat
@@ -1,6 +1,7 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
carol::ipsec up alice
+dave::expect-connection venus
dave::ipsec up venus
diff --git a/testing/tests/ikev2/ocsp-no-signer-cert/pretest.dat b/testing/tests/ikev2/ocsp-no-signer-cert/pretest.dat
index afb64c3ed..9d3999937 100644
--- a/testing/tests/ikev2/ocsp-no-signer-cert/pretest.dat
+++ b/testing/tests/ikev2/ocsp-no-signer-cert/pretest.dat
@@ -1,5 +1,5 @@
moon::iptables -I OUTPUT -d PH_IP_WINNETOU -p tcp --dport 80 -j DROP
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ocsp-revoked/pretest.dat b/testing/tests/ikev2/ocsp-revoked/pretest.dat
index d92333d86..3a1982f8a 100644
--- a/testing/tests/ikev2/ocsp-revoked/pretest.dat
+++ b/testing/tests/ikev2/ocsp-revoked/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ocsp-root-cert/pretest.dat b/testing/tests/ikev2/ocsp-root-cert/pretest.dat
index d92333d86..3a1982f8a 100644
--- a/testing/tests/ikev2/ocsp-root-cert/pretest.dat
+++ b/testing/tests/ikev2/ocsp-root-cert/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ocsp-signer-cert/pretest.dat b/testing/tests/ikev2/ocsp-signer-cert/pretest.dat
index d92333d86..3a1982f8a 100644
--- a/testing/tests/ikev2/ocsp-signer-cert/pretest.dat
+++ b/testing/tests/ikev2/ocsp-signer-cert/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ocsp-strict-ifuri/pretest.dat b/testing/tests/ikev2/ocsp-strict-ifuri/pretest.dat
index 86dd31e83..be0051e0b 100644
--- a/testing/tests/ikev2/ocsp-strict-ifuri/pretest.dat
+++ b/testing/tests/ikev2/ocsp-strict-ifuri/pretest.dat
@@ -1,6 +1,7 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection alice
carol::ipsec up alice
+dave::expect-connection venus
dave::ipsec up venus
diff --git a/testing/tests/ikev2/ocsp-timeouts-good/pretest.dat b/testing/tests/ikev2/ocsp-timeouts-good/pretest.dat
index d92333d86..3a1982f8a 100644
--- a/testing/tests/ikev2/ocsp-timeouts-good/pretest.dat
+++ b/testing/tests/ikev2/ocsp-timeouts-good/pretest.dat
@@ -1,4 +1,4 @@
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ocsp-timeouts-unknown/pretest.dat b/testing/tests/ikev2/ocsp-timeouts-unknown/pretest.dat
index 7d9d600ff..2006925af 100644
--- a/testing/tests/ikev2/ocsp-timeouts-unknown/pretest.dat
+++ b/testing/tests/ikev2/ocsp-timeouts-unknown/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables -I OUTPUT -d PH_IP_WINNETOU -p tcp --dport 80 -j DROP
carol::iptables -I OUTPUT -d PH_IP_WINNETOU -p tcp --dport 80 -j DROP
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/ocsp-untrusted-cert/pretest.dat b/testing/tests/ikev2/ocsp-untrusted-cert/pretest.dat
index afb64c3ed..9d3999937 100644
--- a/testing/tests/ikev2/ocsp-untrusted-cert/pretest.dat
+++ b/testing/tests/ikev2/ocsp-untrusted-cert/pretest.dat
@@ -1,5 +1,5 @@
moon::iptables -I OUTPUT -d PH_IP_WINNETOU -p tcp --dport 80 -j DROP
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/protoport-dual/pretest.dat b/testing/tests/ikev2/protoport-dual/pretest.dat
index efb2e5712..4759fdb7b 100644
--- a/testing/tests/ikev2/protoport-dual/pretest.dat
+++ b/testing/tests/ikev2/protoport-dual/pretest.dat
@@ -2,6 +2,7 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home-icmp
+carol::expect-connection home-ssh
carol::ipsec up home-icmp
carol::ipsec up home-ssh
diff --git a/testing/tests/ikev2/protoport-route/pretest.dat b/testing/tests/ikev2/protoport-route/pretest.dat
index 5a15574d6..d242f06a8 100644
--- a/testing/tests/ikev2/protoport-route/pretest.dat
+++ b/testing/tests/ikev2/protoport-route/pretest.dat
@@ -2,7 +2,7 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home-icmp
+carol::expect-connection home-ssh
carol::ssh PH_IP_ALICE hostname
carol::ping -c 1 PH_IP_ALICE > /dev/null
-carol::sleep 2
diff --git a/testing/tests/ikev2/reauth-early/pretest.dat b/testing/tests/ikev2/reauth-early/pretest.dat
index 153ea7c43..d3ce70e80 100644
--- a/testing/tests/ikev2/reauth-early/pretest.dat
+++ b/testing/tests/ikev2/reauth-early/pretest.dat
@@ -2,6 +2,6 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
carol::sleep 30
diff --git a/testing/tests/ikev2/reauth-late/pretest.dat b/testing/tests/ikev2/reauth-late/pretest.dat
index 153ea7c43..d3ce70e80 100644
--- a/testing/tests/ikev2/reauth-late/pretest.dat
+++ b/testing/tests/ikev2/reauth-late/pretest.dat
@@ -2,6 +2,6 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
carol::sleep 30
diff --git a/testing/tests/ikev2/reauth-mbb-virtual-ip/pretest.dat b/testing/tests/ikev2/reauth-mbb-virtual-ip/pretest.dat
index baacc1605..de4acbbf0 100644
--- a/testing/tests/ikev2/reauth-mbb-virtual-ip/pretest.dat
+++ b/testing/tests/ikev2/reauth-mbb-virtual-ip/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/reauth-mbb/pretest.dat b/testing/tests/ikev2/reauth-mbb/pretest.dat
index baacc1605..de4acbbf0 100644
--- a/testing/tests/ikev2/reauth-mbb/pretest.dat
+++ b/testing/tests/ikev2/reauth-mbb/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/rw-cert/pretest.dat b/testing/tests/ikev2/rw-cert/pretest.dat
index c582e030d..e87a8ee47 100644
--- a/testing/tests/ikev2/rw-cert/pretest.dat
+++ b/testing/tests/ikev2/rw-cert/pretest.dat
@@ -4,6 +4,8 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+moon::expect-connection rw
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-dnssec/pretest.dat b/testing/tests/ikev2/rw-dnssec/pretest.dat
index 40eaede87..e827687f8 100644
--- a/testing/tests/ikev2/rw-dnssec/pretest.dat
+++ b/testing/tests/ikev2/rw-dnssec/pretest.dat
@@ -7,7 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-aka-id-rsa/pretest.dat b/testing/tests/ikev2/rw-eap-aka-id-rsa/pretest.dat
index 388339fb8..de4acbbf0 100644
--- a/testing/tests/ikev2/rw-eap-aka-id-rsa/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-aka-id-rsa/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-aka-rsa/pretest.dat b/testing/tests/ikev2/rw-eap-aka-rsa/pretest.dat
index 388339fb8..de4acbbf0 100644
--- a/testing/tests/ikev2/rw-eap-aka-rsa/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-aka-rsa/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-dynamic/pretest.dat b/testing/tests/ikev2/rw-eap-dynamic/pretest.dat
index 17f1b5f2b..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-eap-dynamic/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-dynamic/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-framed-ip-radius/pretest.dat b/testing/tests/ikev2/rw-eap-framed-ip-radius/pretest.dat
index 698a719f7..98bf0b15a 100644
--- a/testing/tests/ikev2/rw-eap-framed-ip-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-framed-ip-radius/pretest.dat
@@ -5,7 +5,7 @@ alice::radiusd
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
-carol::ipsec up home
-dave::ipsec up home
-dave::sleep 1
+carol::expect-connection home
+carol::ipsec up home
+dave::expect-connection home
+dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-eap-md5-class-radius/pretest.dat b/testing/tests/ikev2/rw-eap-md5-class-radius/pretest.dat
index a2704e833..8893e0169 100644
--- a/testing/tests/ikev2/rw-eap-md5-class-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-md5-class-radius/pretest.dat
@@ -5,9 +5,11 @@ alice::radiusd
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
+dave::expect-connection alice
+dave::expect-connection venus
dave::ipsec up alice
dave::ipsec up venus
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-md5-id-prompt/pretest.dat b/testing/tests/ikev2/rw-eap-md5-id-prompt/pretest.dat
index 180537f5f..d44910db8 100644
--- a/testing/tests/ikev2/rw-eap-md5-id-prompt/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-md5-id-prompt/pretest.dat
@@ -2,7 +2,6 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec stroke user-creds home carol "Ar3etTnp"
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-md5-id-radius/pretest.dat b/testing/tests/ikev2/rw-eap-md5-id-radius/pretest.dat
index 9adc43d3e..c65fbda83 100644
--- a/testing/tests/ikev2/rw-eap-md5-id-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-md5-id-radius/pretest.dat
@@ -3,6 +3,5 @@ carol::iptables-restore < /etc/iptables.rules
alice::radiusd
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-md5-radius/pretest.dat b/testing/tests/ikev2/rw-eap-md5-radius/pretest.dat
index 9adc43d3e..c65fbda83 100644
--- a/testing/tests/ikev2/rw-eap-md5-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-md5-radius/pretest.dat
@@ -3,6 +3,5 @@ carol::iptables-restore < /etc/iptables.rules
alice::radiusd
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-md5-rsa/pretest.dat b/testing/tests/ikev2/rw-eap-md5-rsa/pretest.dat
index 388339fb8..de4acbbf0 100644
--- a/testing/tests/ikev2/rw-eap-md5-rsa/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-md5-rsa/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-mschapv2-id-rsa/pretest.dat b/testing/tests/ikev2/rw-eap-mschapv2-id-rsa/pretest.dat
index 388339fb8..de4acbbf0 100644
--- a/testing/tests/ikev2/rw-eap-mschapv2-id-rsa/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-mschapv2-id-rsa/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-peap-md5/pretest.dat b/testing/tests/ikev2/rw-eap-peap-md5/pretest.dat
index 17f1b5f2b..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-eap-peap-md5/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-peap-md5/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-peap-mschapv2/pretest.dat b/testing/tests/ikev2/rw-eap-peap-mschapv2/pretest.dat
index 17f1b5f2b..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-eap-peap-mschapv2/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-peap-mschapv2/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-peap-radius/pretest.dat b/testing/tests/ikev2/rw-eap-peap-radius/pretest.dat
index 3e7fc0bb1..98bf0b15a 100644
--- a/testing/tests/ikev2/rw-eap-peap-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-peap-radius/pretest.dat
@@ -5,7 +5,7 @@ alice::radiusd
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-sim-id-radius/pretest.dat b/testing/tests/ikev2/rw-eap-sim-id-radius/pretest.dat
index f8a9cc852..fa1164713 100644
--- a/testing/tests/ikev2/rw-eap-sim-id-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-sim-id-radius/pretest.dat
@@ -5,6 +5,5 @@ carol::cat /etc/ipsec.d/triplets.dat
alice::radiusd
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-sim-only-radius/pretest.dat b/testing/tests/ikev2/rw-eap-sim-only-radius/pretest.dat
index 0e9e46bfd..a204f88a1 100644
--- a/testing/tests/ikev2/rw-eap-sim-only-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-sim-only-radius/pretest.dat
@@ -11,7 +11,7 @@ alice::radiusd
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-sim-radius/pretest.dat b/testing/tests/ikev2/rw-eap-sim-radius/pretest.dat
index 57c9f11a8..fdb50fcfb 100644
--- a/testing/tests/ikev2/rw-eap-sim-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-sim-radius/pretest.dat
@@ -11,7 +11,7 @@ alice::radiusd
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-sim-rsa/pretest.dat b/testing/tests/ikev2/rw-eap-sim-rsa/pretest.dat
index ae464b51c..3e05e4ed7 100644
--- a/testing/tests/ikev2/rw-eap-sim-rsa/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-sim-rsa/pretest.dat
@@ -4,6 +4,5 @@ moon::cat /etc/ipsec.d/triplets.dat
carol::cat /etc/ipsec.d/triplets.dat
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-tls-fragments/pretest.dat b/testing/tests/ikev2/rw-eap-tls-fragments/pretest.dat
index 3d680ab78..7ed202116 100644
--- a/testing/tests/ikev2/rw-eap-tls-fragments/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-tls-fragments/pretest.dat
@@ -4,6 +4,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-tls-only/pretest.dat b/testing/tests/ikev2/rw-eap-tls-only/pretest.dat
index 388339fb8..de4acbbf0 100644
--- a/testing/tests/ikev2/rw-eap-tls-only/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-tls-only/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-tls-radius/pretest.dat b/testing/tests/ikev2/rw-eap-tls-radius/pretest.dat
index 9adc43d3e..c65fbda83 100644
--- a/testing/tests/ikev2/rw-eap-tls-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-tls-radius/pretest.dat
@@ -3,6 +3,5 @@ carol::iptables-restore < /etc/iptables.rules
alice::radiusd
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-ttls-only/pretest.dat b/testing/tests/ikev2/rw-eap-ttls-only/pretest.dat
index 589d478e7..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-eap-ttls-only/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-ttls-only/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 2
diff --git a/testing/tests/ikev2/rw-eap-ttls-phase2-piggyback/pretest.dat b/testing/tests/ikev2/rw-eap-ttls-phase2-piggyback/pretest.dat
index 17f1b5f2b..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-eap-ttls-phase2-piggyback/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-ttls-phase2-piggyback/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-eap-ttls-radius/pretest.dat b/testing/tests/ikev2/rw-eap-ttls-radius/pretest.dat
index 3e7fc0bb1..98bf0b15a 100644
--- a/testing/tests/ikev2/rw-eap-ttls-radius/pretest.dat
+++ b/testing/tests/ikev2/rw-eap-ttls-radius/pretest.dat
@@ -5,7 +5,7 @@ alice::radiusd
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/ikev2/rw-hash-and-url/pretest.dat b/testing/tests/ikev2/rw-hash-and-url/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-hash-and-url/pretest.dat
+++ b/testing/tests/ikev2/rw-hash-and-url/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-initiator-only/pretest.dat b/testing/tests/ikev2/rw-initiator-only/pretest.dat
index fc7173430..4660c29d6 100644
--- a/testing/tests/ikev2/rw-initiator-only/pretest.dat
+++ b/testing/tests/ikev2/rw-initiator-only/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection peer
dave::ipsec up peer
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/ikev2/rw-mark-in-out/pretest.dat b/testing/tests/ikev2/rw-mark-in-out/pretest.dat
index 8e9dd2f51..728831472 100644
--- a/testing/tests/ikev2/rw-mark-in-out/pretest.dat
+++ b/testing/tests/ikev2/rw-mark-in-out/pretest.dat
@@ -1,8 +1,8 @@
alice::iptables-restore < /etc/iptables.rules
venus::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
-moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to PH_IP_MOON
-sun::ip route add 10.1.0.0/16 via PH_IP_MOON
+moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to PH_IP_MOON
+sun::ip route add 10.1.0.0/16 via PH_IP_MOON
sun::iptables -t nat -A POSTROUTING -o eth1 -m mark --mark 10 -j SNAT --to PH_IP_CAROL10
sun::iptables -t nat -A POSTROUTING -o eth1 -m mark --mark 20 -j SNAT --to PH_IP_DAVE10
sun::iptables -t mangle -A PREROUTING -d PH_IP_CAROL10 -j MARK --set-mark 11
@@ -10,8 +10,7 @@ sun::iptables -t mangle -A PREROUTING -d PH_IP_DAVE10 -j MARK --set-mark 21
alice::ipsec start
venus::ipsec start
sun::ipsec start
-alice::sleep 2
-alice::ipsec up home
-venus::sleep 2
+alice::expect-connection home
+alice::ipsec up home
+venus::expect-connection home
venus::ipsec up home
-venus::sleep 2
diff --git a/testing/tests/ikev2/rw-ntru-bliss/pretest.dat b/testing/tests/ikev2/rw-ntru-bliss/pretest.dat
index 24249435e..c0f963d4c 100644
--- a/testing/tests/ikev2/rw-ntru-bliss/pretest.dat
+++ b/testing/tests/ikev2/rw-ntru-bliss/pretest.dat
@@ -7,7 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/strongswanCert.pem
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-ntru-psk/pretest.dat b/testing/tests/ikev2/rw-ntru-psk/pretest.dat
index 40eaede87..e827687f8 100644
--- a/testing/tests/ikev2/rw-ntru-psk/pretest.dat
+++ b/testing/tests/ikev2/rw-ntru-psk/pretest.dat
@@ -7,7 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-pkcs8/pretest.dat b/testing/tests/ikev2/rw-pkcs8/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-pkcs8/pretest.dat
+++ b/testing/tests/ikev2/rw-pkcs8/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-psk-fqdn/pretest.dat b/testing/tests/ikev2/rw-psk-fqdn/pretest.dat
index 64ce593fb..ab5e18da2 100644
--- a/testing/tests/ikev2/rw-psk-fqdn/pretest.dat
+++ b/testing/tests/ikev2/rw-psk-fqdn/pretest.dat
@@ -7,6 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-psk-ipv4/pretest.dat b/testing/tests/ikev2/rw-psk-ipv4/pretest.dat
index 64ce593fb..ab5e18da2 100644
--- a/testing/tests/ikev2/rw-psk-ipv4/pretest.dat
+++ b/testing/tests/ikev2/rw-psk-ipv4/pretest.dat
@@ -7,6 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-psk-no-idr/pretest.dat b/testing/tests/ikev2/rw-psk-no-idr/pretest.dat
index 64ce593fb..ab5e18da2 100644
--- a/testing/tests/ikev2/rw-psk-no-idr/pretest.dat
+++ b/testing/tests/ikev2/rw-psk-no-idr/pretest.dat
@@ -7,6 +7,7 @@ dave::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-psk-rsa-mixed/pretest.dat b/testing/tests/ikev2/rw-psk-rsa-mixed/pretest.dat
index 446f81426..08b891aa5 100644
--- a/testing/tests/ikev2/rw-psk-rsa-mixed/pretest.dat
+++ b/testing/tests/ikev2/rw-psk-rsa-mixed/pretest.dat
@@ -5,6 +5,7 @@ carol::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-psk-rsa-split/pretest.dat b/testing/tests/ikev2/rw-psk-rsa-split/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/ikev2/rw-psk-rsa-split/pretest.dat
+++ b/testing/tests/ikev2/rw-psk-rsa-split/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/rw-radius-accounting/pretest.dat b/testing/tests/ikev2/rw-radius-accounting/pretest.dat
index 9f437fe85..d26229602 100644
--- a/testing/tests/ikev2/rw-radius-accounting/pretest.dat
+++ b/testing/tests/ikev2/rw-radius-accounting/pretest.dat
@@ -4,6 +4,5 @@ alice::rm /var/log/freeradius/radacct/PH_IP_MOON1/*
alice::radiusd
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/rw-sig-auth/pretest.dat b/testing/tests/ikev2/rw-sig-auth/pretest.dat
index bec31cc68..9c26ea122 100644
--- a/testing/tests/ikev2/rw-sig-auth/pretest.dat
+++ b/testing/tests/ikev2/rw-sig-auth/pretest.dat
@@ -4,9 +4,11 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
+dave::expect-connection alice
+dave::expect-connection venus
dave::ipsec up alice
dave::ipsec up venus
-dave::sleep 1
diff --git a/testing/tests/ikev2/strong-keys-certs/pretest.dat b/testing/tests/ikev2/strong-keys-certs/pretest.dat
index dea5fc162..a55cf37b2 100644
--- a/testing/tests/ikev2/strong-keys-certs/pretest.dat
+++ b/testing/tests/ikev2/strong-keys-certs/pretest.dat
@@ -4,7 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/ikev2/two-certs/pretest.dat b/testing/tests/ikev2/two-certs/pretest.dat
index fe2aaec19..5936eda68 100644
--- a/testing/tests/ikev2/two-certs/pretest.dat
+++ b/testing/tests/ikev2/two-certs/pretest.dat
@@ -2,7 +2,7 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
-carol::sleep 1
diff --git a/testing/tests/ikev2/virtual-ip-override/pretest.dat b/testing/tests/ikev2/virtual-ip-override/pretest.dat
index 1765a83cd..2d09e88ce 100644
--- a/testing/tests/ikev2/virtual-ip-override/pretest.dat
+++ b/testing/tests/ikev2/virtual-ip-override/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/virtual-ip/pretest.dat b/testing/tests/ikev2/virtual-ip/pretest.dat
index 1765a83cd..2d09e88ce 100644
--- a/testing/tests/ikev2/virtual-ip/pretest.dat
+++ b/testing/tests/ikev2/virtual-ip/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/ikev2/wildcards/pretest.dat b/testing/tests/ikev2/wildcards/pretest.dat
index 3c4832e5e..2134d6bea 100644
--- a/testing/tests/ikev2/wildcards/pretest.dat
+++ b/testing/tests/ikev2/wildcards/pretest.dat
@@ -1,8 +1,11 @@
carol::ipsec start
dave::ipsec start
moon::ipsec start
-carol::sleep 1
+carol::expect-connection alice
+carol::expect-connection venus
carol::ipsec up alice
carol::ipsec up venus
+dave::expect-connection alice
+dave::expect-connection venus
dave::ipsec up venus
dave::ipsec up alice
diff --git a/testing/tests/libipsec/host2host-cert/pretest.dat b/testing/tests/libipsec/host2host-cert/pretest.dat
index d8d30af02..b095bf5c4 100644
--- a/testing/tests/libipsec/host2host-cert/pretest.dat
+++ b/testing/tests/libipsec/host2host-cert/pretest.dat
@@ -4,5 +4,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/libipsec/net2net-3des/pretest.dat b/testing/tests/libipsec/net2net-3des/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/libipsec/net2net-3des/pretest.dat
+++ b/testing/tests/libipsec/net2net-3des/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/libipsec/net2net-cert/pretest.dat b/testing/tests/libipsec/net2net-cert/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/libipsec/net2net-cert/pretest.dat
+++ b/testing/tests/libipsec/net2net-cert/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/libipsec/rw-suite-b/pretest.dat b/testing/tests/libipsec/rw-suite-b/pretest.dat
index 8bbea1412..e87a8ee47 100644
--- a/testing/tests/libipsec/rw-suite-b/pretest.dat
+++ b/testing/tests/libipsec/rw-suite-b/pretest.dat
@@ -4,6 +4,8 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+moon::expect-connection rw
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev1/alg-camellia/pretest.dat b/testing/tests/openssl-ikev1/alg-camellia/pretest.dat
index 388339fb8..de4acbbf0 100644
--- a/testing/tests/openssl-ikev1/alg-camellia/pretest.dat
+++ b/testing/tests/openssl-ikev1/alg-camellia/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/openssl-ikev1/alg-ecp-high/pretest.dat b/testing/tests/openssl-ikev1/alg-ecp-high/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev1/alg-ecp-high/pretest.dat
+++ b/testing/tests/openssl-ikev1/alg-ecp-high/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev1/alg-ecp-low/pretest.dat b/testing/tests/openssl-ikev1/alg-ecp-low/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev1/alg-ecp-low/pretest.dat
+++ b/testing/tests/openssl-ikev1/alg-ecp-low/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev1/ecdsa-certs/pretest.dat b/testing/tests/openssl-ikev1/ecdsa-certs/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev1/ecdsa-certs/pretest.dat
+++ b/testing/tests/openssl-ikev1/ecdsa-certs/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/alg-aes-gcm/pretest.dat b/testing/tests/openssl-ikev2/alg-aes-gcm/pretest.dat
index 972d93053..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/alg-aes-gcm/pretest.dat
+++ b/testing/tests/openssl-ikev2/alg-aes-gcm/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/alg-blowfish/pretest.dat b/testing/tests/openssl-ikev2/alg-blowfish/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/alg-blowfish/pretest.dat
+++ b/testing/tests/openssl-ikev2/alg-blowfish/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/alg-camellia/pretest.dat b/testing/tests/openssl-ikev2/alg-camellia/pretest.dat
index 886fdf55c..de4acbbf0 100644
--- a/testing/tests/openssl-ikev2/alg-camellia/pretest.dat
+++ b/testing/tests/openssl-ikev2/alg-camellia/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/openssl-ikev2/alg-ecp-brainpool-high/pretest.dat b/testing/tests/openssl-ikev2/alg-ecp-brainpool-high/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/alg-ecp-brainpool-high/pretest.dat
+++ b/testing/tests/openssl-ikev2/alg-ecp-brainpool-high/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/alg-ecp-brainpool-low/pretest.dat b/testing/tests/openssl-ikev2/alg-ecp-brainpool-low/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/alg-ecp-brainpool-low/pretest.dat
+++ b/testing/tests/openssl-ikev2/alg-ecp-brainpool-low/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/alg-ecp-high/pretest.dat b/testing/tests/openssl-ikev2/alg-ecp-high/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/alg-ecp-high/pretest.dat
+++ b/testing/tests/openssl-ikev2/alg-ecp-high/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/alg-ecp-low/pretest.dat b/testing/tests/openssl-ikev2/alg-ecp-low/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/alg-ecp-low/pretest.dat
+++ b/testing/tests/openssl-ikev2/alg-ecp-low/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/critical-extension/pretest.dat b/testing/tests/openssl-ikev2/critical-extension/pretest.dat
index c724e5df8..1732d6efa 100644
--- a/testing/tests/openssl-ikev2/critical-extension/pretest.dat
+++ b/testing/tests/openssl-ikev2/critical-extension/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/openssl-ikev2/ecdsa-certs/pretest.dat b/testing/tests/openssl-ikev2/ecdsa-certs/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/ecdsa-certs/pretest.dat
+++ b/testing/tests/openssl-ikev2/ecdsa-certs/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/ecdsa-pkcs8/pretest.dat b/testing/tests/openssl-ikev2/ecdsa-pkcs8/pretest.dat
index 8bbea1412..a55cf37b2 100644
--- a/testing/tests/openssl-ikev2/ecdsa-pkcs8/pretest.dat
+++ b/testing/tests/openssl-ikev2/ecdsa-pkcs8/pretest.dat
@@ -4,6 +4,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/net2net-pgp-v3/pretest.dat b/testing/tests/openssl-ikev2/net2net-pgp-v3/pretest.dat
index 0f4ae0f4f..f2cbf6a0c 100644
--- a/testing/tests/openssl-ikev2/net2net-pgp-v3/pretest.dat
+++ b/testing/tests/openssl-ikev2/net2net-pgp-v3/pretest.dat
@@ -4,5 +4,5 @@ moon::rm /etc/ipsec.d/cacerts/*
sun::rm /etc/ipsec.d/cacerts/*
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/openssl-ikev2/net2net-pkcs12/pretest.dat b/testing/tests/openssl-ikev2/net2net-pkcs12/pretest.dat
index 3492238f0..fd1ce379f 100644
--- a/testing/tests/openssl-ikev2/net2net-pkcs12/pretest.dat
+++ b/testing/tests/openssl-ikev2/net2net-pkcs12/pretest.dat
@@ -6,5 +6,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/openssl-ikev2/rw-cert/pretest.dat b/testing/tests/openssl-ikev2/rw-cert/pretest.dat
index c582e030d..974c22530 100644
--- a/testing/tests/openssl-ikev2/rw-cert/pretest.dat
+++ b/testing/tests/openssl-ikev2/rw-cert/pretest.dat
@@ -4,6 +4,9 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+# moon runs crypto tests, so make sure it is ready
+moon::expect-connection rw
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/openssl-ikev2/rw-eap-tls-only/pretest.dat b/testing/tests/openssl-ikev2/rw-eap-tls-only/pretest.dat
index 388339fb8..de4acbbf0 100644
--- a/testing/tests/openssl-ikev2/rw-eap-tls-only/pretest.dat
+++ b/testing/tests/openssl-ikev2/rw-eap-tls-only/pretest.dat
@@ -2,6 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/openssl-ikev2/rw-suite-b-128/pretest.dat b/testing/tests/openssl-ikev2/rw-suite-b-128/pretest.dat
index b9393944a..290f57e69 100644
--- a/testing/tests/openssl-ikev2/rw-suite-b-128/pretest.dat
+++ b/testing/tests/openssl-ikev2/rw-suite-b-128/pretest.dat
@@ -4,6 +4,8 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+moon::expect-connection rw
+dave::expect-connection peer
dave::ipsec up peer
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/openssl-ikev2/rw-suite-b-192/pretest.dat b/testing/tests/openssl-ikev2/rw-suite-b-192/pretest.dat
index b9393944a..290f57e69 100644
--- a/testing/tests/openssl-ikev2/rw-suite-b-192/pretest.dat
+++ b/testing/tests/openssl-ikev2/rw-suite-b-192/pretest.dat
@@ -4,6 +4,8 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+moon::expect-connection rw
+dave::expect-connection peer
dave::ipsec up peer
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/p2pnat/behind-same-nat/pretest.dat b/testing/tests/p2pnat/behind-same-nat/pretest.dat
index eb1d67fa2..6d9217066 100644
--- a/testing/tests/p2pnat/behind-same-nat/pretest.dat
+++ b/testing/tests/p2pnat/behind-same-nat/pretest.dat
@@ -7,8 +7,8 @@ moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-
moon::iptables -A FORWARD -i eth1 -o eth0 -s 10.1.0.0/16 -j ACCEPT
moon::iptables -A FORWARD -i eth0 -o eth1 -d 10.1.0.0/16 -j ACCEPT
carol::ipsec start
-carol::sleep 1
+carol::expect-connection medsrv
alice::ipsec start
alice::sleep 1
venus::ipsec start
-venus::sleep 4
+venus::sleep 2
diff --git a/testing/tests/p2pnat/medsrv-psk/pretest.dat b/testing/tests/p2pnat/medsrv-psk/pretest.dat
index 09b658318..950520006 100644
--- a/testing/tests/p2pnat/medsrv-psk/pretest.dat
+++ b/testing/tests/p2pnat/medsrv-psk/pretest.dat
@@ -12,8 +12,8 @@ sun::iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p tcp -j SNAT --to-s
sun::iptables -A FORWARD -i eth1 -o eth0 -s 10.2.0.0/16 -j ACCEPT
sun::iptables -A FORWARD -i eth0 -o eth1 -d 10.2.0.0/16 -j ACCEPT
carol::ipsec start
-carol::sleep 1
+carol::expect-connection medsrv
bob::ipsec start
bob::sleep 1
alice::ipsec start
-alice::sleep 4
+alice::sleep 2
diff --git a/testing/tests/pfkey/alg-aes-xcbc/pretest.dat b/testing/tests/pfkey/alg-aes-xcbc/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/pfkey/alg-aes-xcbc/pretest.dat
+++ b/testing/tests/pfkey/alg-aes-xcbc/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/pfkey/alg-sha384/pretest.dat b/testing/tests/pfkey/alg-sha384/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/pfkey/alg-sha384/pretest.dat
+++ b/testing/tests/pfkey/alg-sha384/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/pfkey/alg-sha512/pretest.dat b/testing/tests/pfkey/alg-sha512/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/pfkey/alg-sha512/pretest.dat
+++ b/testing/tests/pfkey/alg-sha512/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/pfkey/compress/pretest.dat b/testing/tests/pfkey/compress/pretest.dat
index 29a90355f..1fd37b6a8 100644
--- a/testing/tests/pfkey/compress/pretest.dat
+++ b/testing/tests/pfkey/compress/pretest.dat
@@ -2,5 +2,5 @@ carol::iptables-restore < /etc/iptables.rules
moon::iptables-restore < /etc/iptables.rules
carol::ipsec start
moon::ipsec start
-carol::sleep 2
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/pfkey/esp-alg-null/pretest.dat b/testing/tests/pfkey/esp-alg-null/pretest.dat
index 4fc25772b..de4acbbf0 100644
--- a/testing/tests/pfkey/esp-alg-null/pretest.dat
+++ b/testing/tests/pfkey/esp-alg-null/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/pfkey/host2host-transport/pretest.dat b/testing/tests/pfkey/host2host-transport/pretest.dat
index 99789b90f..997a48167 100644
--- a/testing/tests/pfkey/host2host-transport/pretest.dat
+++ b/testing/tests/pfkey/host2host-transport/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/pfkey/nat-rw/pretest.dat b/testing/tests/pfkey/nat-rw/pretest.dat
index d701a1d61..e3d9fc858 100644
--- a/testing/tests/pfkey/nat-rw/pretest.dat
+++ b/testing/tests/pfkey/nat-rw/pretest.dat
@@ -6,8 +6,7 @@ moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-
alice::ipsec start
venus::ipsec start
sun::ipsec start
-alice::sleep 2
+alice::expect-connection nat-t
alice::ipsec up nat-t
-venus::sleep 2
+venus::expect-connection nat-t
venus::ipsec up nat-t
-venus::sleep 2
diff --git a/testing/tests/pfkey/net2net-route/pretest.dat b/testing/tests/pfkey/net2net-route/pretest.dat
index e4ee3fac2..fadfeab73 100644
--- a/testing/tests/pfkey/net2net-route/pretest.dat
+++ b/testing/tests/pfkey/net2net-route/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 2
+moon::expect-connection net-net
alice::ping -c 10 PH_IP_BOB
diff --git a/testing/tests/pfkey/protoport-dual/pretest.dat b/testing/tests/pfkey/protoport-dual/pretest.dat
index efb2e5712..12112b194 100644
--- a/testing/tests/pfkey/protoport-dual/pretest.dat
+++ b/testing/tests/pfkey/protoport-dual/pretest.dat
@@ -2,6 +2,7 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 2
+carol::expect-connection home-icmp
carol::ipsec up home-icmp
+carol::expect-connection home-ssh
carol::ipsec up home-ssh
diff --git a/testing/tests/pfkey/protoport-route/pretest.dat b/testing/tests/pfkey/protoport-route/pretest.dat
index 5a15574d6..d242f06a8 100644
--- a/testing/tests/pfkey/protoport-route/pretest.dat
+++ b/testing/tests/pfkey/protoport-route/pretest.dat
@@ -2,7 +2,7 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home-icmp
+carol::expect-connection home-ssh
carol::ssh PH_IP_ALICE hostname
carol::ping -c 1 PH_IP_ALICE > /dev/null
-carol::sleep 2
diff --git a/testing/tests/pfkey/rw-cert/pretest.dat b/testing/tests/pfkey/rw-cert/pretest.dat
index c582e030d..e87a8ee47 100644
--- a/testing/tests/pfkey/rw-cert/pretest.dat
+++ b/testing/tests/pfkey/rw-cert/pretest.dat
@@ -4,6 +4,8 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+moon::expect-connection rw
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/ip-pool-db-expired/pretest.dat b/testing/tests/sql/ip-pool-db-expired/pretest.dat
index 10a51bc37..b0776d4a4 100644
--- a/testing/tests/sql/ip-pool-db-expired/pretest.dat
+++ b/testing/tests/sql/ip-pool-db-expired/pretest.dat
@@ -14,6 +14,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/ip-pool-db-restart/pretest.dat b/testing/tests/sql/ip-pool-db-restart/pretest.dat
index 639cfd99f..7c8898613 100644
--- a/testing/tests/sql/ip-pool-db-restart/pretest.dat
+++ b/testing/tests/sql/ip-pool-db-restart/pretest.dat
@@ -14,7 +14,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+dave::expect-connection home
dave::ipsec up home
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/sql/ip-pool-db/pretest.dat b/testing/tests/sql/ip-pool-db/pretest.dat
index 46f33324c..f0d045cb8 100644
--- a/testing/tests/sql/ip-pool-db/pretest.dat
+++ b/testing/tests/sql/ip-pool-db/pretest.dat
@@ -13,7 +13,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/sql/ip-split-pools-db-restart/pretest.dat b/testing/tests/sql/ip-split-pools-db-restart/pretest.dat
index ba3f4d1cb..0805232ac 100644
--- a/testing/tests/sql/ip-split-pools-db-restart/pretest.dat
+++ b/testing/tests/sql/ip-split-pools-db-restart/pretest.dat
@@ -12,7 +12,7 @@ moon::ipsec pool --leases 2> /dev/null
moon::ipsec start
dave::ipsec start
carol::ipsec start
-dave::sleep 1
+dave::expect-connection home
dave::ipsec up home
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
diff --git a/testing/tests/sql/ip-split-pools-db/pretest.dat b/testing/tests/sql/ip-split-pools-db/pretest.dat
index 6c7633811..5a4a13522 100644
--- a/testing/tests/sql/ip-split-pools-db/pretest.dat
+++ b/testing/tests/sql/ip-split-pools-db/pretest.dat
@@ -11,7 +11,7 @@ moon::ipsec pool --status 2> /dev/null
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/sql/multi-level-ca/pretest.dat b/testing/tests/sql/multi-level-ca/pretest.dat
index 6d56ede09..f0d045cb8 100644
--- a/testing/tests/sql/multi-level-ca/pretest.dat
+++ b/testing/tests/sql/multi-level-ca/pretest.dat
@@ -13,6 +13,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/net2net-cert/pretest.dat b/testing/tests/sql/net2net-cert/pretest.dat
index b62da613c..95d4c7b20 100644
--- a/testing/tests/sql/net2net-cert/pretest.dat
+++ b/testing/tests/sql/net2net-cert/pretest.dat
@@ -8,5 +8,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/sql/net2net-psk/pretest.dat b/testing/tests/sql/net2net-psk/pretest.dat
index b62da613c..95d4c7b20 100644
--- a/testing/tests/sql/net2net-psk/pretest.dat
+++ b/testing/tests/sql/net2net-psk/pretest.dat
@@ -8,5 +8,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
moon::ipsec up net-net
diff --git a/testing/tests/sql/net2net-route-pem/pretest.dat b/testing/tests/sql/net2net-route-pem/pretest.dat
index 537aa630b..ee09d2f2f 100644
--- a/testing/tests/sql/net2net-route-pem/pretest.dat
+++ b/testing/tests/sql/net2net-route-pem/pretest.dat
@@ -8,6 +8,6 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
sun::ipsec start
moon::ipsec start
-moon::sleep 1
+moon::expect-connection net-net
alice::ping -c 1 PH_IP_BOB
bob::ping -c 1 PH_IP_VENUS
diff --git a/testing/tests/sql/net2net-start-pem/pretest.dat b/testing/tests/sql/net2net-start-pem/pretest.dat
index 7307aca81..c2bbf858b 100644
--- a/testing/tests/sql/net2net-start-pem/pretest.dat
+++ b/testing/tests/sql/net2net-start-pem/pretest.dat
@@ -8,4 +8,4 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
sun::ipsec start
moon::ipsec start
-moon::sleep 3
+moon::sleep 1
diff --git a/testing/tests/sql/rw-cert/pretest.dat b/testing/tests/sql/rw-cert/pretest.dat
index 7958f0928..f0d045cb8 100644
--- a/testing/tests/sql/rw-cert/pretest.dat
+++ b/testing/tests/sql/rw-cert/pretest.dat
@@ -13,6 +13,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 3
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/rw-eap-aka-rsa/pretest.dat b/testing/tests/sql/rw-eap-aka-rsa/pretest.dat
index 2a8e460e7..28d86d441 100644
--- a/testing/tests/sql/rw-eap-aka-rsa/pretest.dat
+++ b/testing/tests/sql/rw-eap-aka-rsa/pretest.dat
@@ -8,5 +8,5 @@ moon::iptables-restore < /etc/iptables.rules
carol::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/sql/rw-psk-ipv4/pretest.dat b/testing/tests/sql/rw-psk-ipv4/pretest.dat
index 6d56ede09..f0d045cb8 100644
--- a/testing/tests/sql/rw-psk-ipv4/pretest.dat
+++ b/testing/tests/sql/rw-psk-ipv4/pretest.dat
@@ -13,6 +13,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/rw-psk-ipv6/pretest.dat b/testing/tests/sql/rw-psk-ipv6/pretest.dat
index fdb5f1970..f0455fc9f 100644
--- a/testing/tests/sql/rw-psk-ipv6/pretest.dat
+++ b/testing/tests/sql/rw-psk-ipv6/pretest.dat
@@ -19,6 +19,7 @@ dave::"ip route add fec1:\:/16 via fec0:\:1"
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/rw-psk-rsa-split/pretest.dat b/testing/tests/sql/rw-psk-rsa-split/pretest.dat
index 6d56ede09..f0d045cb8 100644
--- a/testing/tests/sql/rw-psk-rsa-split/pretest.dat
+++ b/testing/tests/sql/rw-psk-rsa-split/pretest.dat
@@ -13,6 +13,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/rw-rsa-keyid/pretest.dat b/testing/tests/sql/rw-rsa-keyid/pretest.dat
index 6d56ede09..f0d045cb8 100644
--- a/testing/tests/sql/rw-rsa-keyid/pretest.dat
+++ b/testing/tests/sql/rw-rsa-keyid/pretest.dat
@@ -13,6 +13,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/sql/rw-rsa/pretest.dat b/testing/tests/sql/rw-rsa/pretest.dat
index 6d56ede09..f0d045cb8 100644
--- a/testing/tests/sql/rw-rsa/pretest.dat
+++ b/testing/tests/sql/rw-rsa/pretest.dat
@@ -13,6 +13,7 @@ dave::iptables-restore < /etc/iptables.rules
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/tnc/tnccs-11-fhh/pretest.dat b/testing/tests/tnc/tnccs-11-fhh/pretest.dat
index 8fab1fb6c..7825f1fc9 100644
--- a/testing/tests/tnc/tnccs-11-fhh/pretest.dat
+++ b/testing/tests/tnc/tnccs-11-fhh/pretest.dat
@@ -9,7 +9,7 @@ dave::cat /etc/tnc/dummyimc.file
moon::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
carol::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
dave::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-11-radius-block/pretest.dat b/testing/tests/tnc/tnccs-11-radius-block/pretest.dat
index 96163aa36..d2bb94583 100644
--- a/testing/tests/tnc/tnccs-11-radius-block/pretest.dat
+++ b/testing/tests/tnc/tnccs-11-radius-block/pretest.dat
@@ -8,7 +8,7 @@ alice::LEAK_DETECTIVE_DISABLE=1 LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.propertie
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-11-radius-pts/pretest.dat b/testing/tests/tnc/tnccs-11-radius-pts/pretest.dat
index 03b24747e..b745ed4b3 100644
--- a/testing/tests/tnc/tnccs-11-radius-pts/pretest.dat
+++ b/testing/tests/tnc/tnccs-11-radius-pts/pretest.dat
@@ -14,9 +14,9 @@ dave::cat /etc/tnc_config
moon::ipsec start
dave::ipsec start
carol::ipsec start
-dave::sleep 1
+dave::expect-connection home
dave::ipsec up home
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
alice::ipsec attest --sessions
alice::ipsec attest --devices
diff --git a/testing/tests/tnc/tnccs-11-radius/pretest.dat b/testing/tests/tnc/tnccs-11-radius/pretest.dat
index 71dff71b7..fcfb1451c 100644
--- a/testing/tests/tnc/tnccs-11-radius/pretest.dat
+++ b/testing/tests/tnc/tnccs-11-radius/pretest.dat
@@ -10,7 +10,7 @@ dave::cat /etc/tnc_config
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-11-supplicant/pretest.dat b/testing/tests/tnc/tnccs-11-supplicant/pretest.dat
index ac03fedbb..4dbff64a3 100644
--- a/testing/tests/tnc/tnccs-11-supplicant/pretest.dat
+++ b/testing/tests/tnc/tnccs-11-supplicant/pretest.dat
@@ -6,6 +6,6 @@ carol::cat /etc/tnc_config
dave::cat /etc/tnc_config
moon::hostapd -B /etc/hostapd/hostapd.conf
carol::LEAK_DETECTIVE_DISABLE=1 LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties wpa_supplicant -B -c /etc/wpa_supplicant.conf -D wired -i eth0
-carol::sleep 4
+carol::sleep 4
dave::LEAK_DETECTIVE_DISABLE=1 LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties wpa_supplicant -B -c /etc/wpa_supplicant.conf -D wired -i eth0
dave::sleep 4
diff --git a/testing/tests/tnc/tnccs-11/pretest.dat b/testing/tests/tnc/tnccs-11/pretest.dat
index cac1cfafc..85622034d 100644
--- a/testing/tests/tnc/tnccs-11/pretest.dat
+++ b/testing/tests/tnc/tnccs-11/pretest.dat
@@ -7,7 +7,7 @@ dave::cat /etc/tnc_config
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-block/pretest.dat b/testing/tests/tnc/tnccs-20-block/pretest.dat
index f5b3b2e8c..c66a2e1ec 100644
--- a/testing/tests/tnc/tnccs-20-block/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-block/pretest.dat
@@ -8,7 +8,7 @@ dave::cat /etc/tnc_config
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-client-retry/pretest.dat b/testing/tests/tnc/tnccs-20-client-retry/pretest.dat
index b2b243ba3..85622034d 100644
--- a/testing/tests/tnc/tnccs-20-client-retry/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-client-retry/pretest.dat
@@ -5,9 +5,9 @@ moon::cat /etc/tnc_config
carol::cat /etc/tnc_config
dave::cat /etc/tnc_config
moon::ipsec start
-carol::ipsec start
-dave::ipsec start
-carol::sleep 1
+carol::ipsec start
+dave::ipsec start
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-fail-init/pretest.dat b/testing/tests/tnc/tnccs-20-fail-init/pretest.dat
index 38c651328..85622034d 100644
--- a/testing/tests/tnc/tnccs-20-fail-init/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-fail-init/pretest.dat
@@ -5,8 +5,9 @@ moon::cat /etc/tnc_config
carol::cat /etc/tnc_config
dave::cat /etc/tnc_config
moon::ipsec start
-carol::ipsec start
+carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
diff --git a/testing/tests/tnc/tnccs-20-fail-resp/pretest.dat b/testing/tests/tnc/tnccs-20-fail-resp/pretest.dat
index 6947c4bdf..e5c202947 100644
--- a/testing/tests/tnc/tnccs-20-fail-resp/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-fail-resp/pretest.dat
@@ -3,6 +3,6 @@ carol::iptables-restore < /etc/iptables.rules
moon::cat /etc/tnc_config
carol::cat /etc/tnc_config
moon::ipsec start
-carol::ipsec start
-carol::sleep 1
+carol::ipsec start
+carol::expect-connection home
carol::ipsec up home
diff --git a/testing/tests/tnc/tnccs-20-fhh/pretest.dat b/testing/tests/tnc/tnccs-20-fhh/pretest.dat
index 72c9b1665..39b0e03eb 100644
--- a/testing/tests/tnc/tnccs-20-fhh/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-fhh/pretest.dat
@@ -8,9 +8,10 @@ carol::cat /etc/tnc/dummyimc.file
dave::cat /etc/tnc/dummyimc.file
moon::cat /etc/tnc/dummyimv.policy
moon::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
-carol::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
-dave::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
-carol::sleep 1
+carol::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
+dave::LOG4CXX_CONFIGURATION=/etc/tnc/log4cxx.properties ipsec start
+moon::expect-connection rw-allow
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-hcd-eap/pretest.dat b/testing/tests/tnc/tnccs-20-hcd-eap/pretest.dat
index 913dd2190..0978d1252 100644
--- a/testing/tests/tnc/tnccs-20-hcd-eap/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-hcd-eap/pretest.dat
@@ -11,7 +11,7 @@ alice::ipsec start
moon::ipsec start
carol::ipsec start
dave::ipsec start
-dave::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-mutual-eap/pretest.dat b/testing/tests/tnc/tnccs-20-mutual-eap/pretest.dat
index 3bce9f6e5..997a48167 100644
--- a/testing/tests/tnc/tnccs-20-mutual-eap/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-mutual-eap/pretest.dat
@@ -2,5 +2,5 @@ moon::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::ipsec start
sun::ipsec start
-moon::sleep 1
+moon::expect-connection host-host
moon::ipsec up host-host
diff --git a/testing/tests/tnc/tnccs-20-mutual-pt-tls/pretest.dat b/testing/tests/tnc/tnccs-20-mutual-pt-tls/pretest.dat
index fab55d11a..07b17600d 100644
--- a/testing/tests/tnc/tnccs-20-mutual-pt-tls/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-mutual-pt-tls/pretest.dat
@@ -1,4 +1,4 @@
sun::ipsec start
moon::cat /etc/pts/options
-moon::sleep 1
-moon::ipsec pt-tls-client --optionsfrom /etc/pts/options
+sun::expect-connection pdp
+moon::ipsec pt-tls-client --optionsfrom /etc/pts/options
diff --git a/testing/tests/tnc/tnccs-20-os-pts/pretest.dat b/testing/tests/tnc/tnccs-20-os-pts/pretest.dat
index 7a562eec5..0fedb2608 100644
--- a/testing/tests/tnc/tnccs-20-os-pts/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-os-pts/pretest.dat
@@ -11,9 +11,9 @@ dave::cat /etc/tnc_config
moon::ipsec start
dave::ipsec start
carol::ipsec start
-dave::sleep 1
+dave::expect-connection home
dave::ipsec up home
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
moon::ipsec attest --sessions
moon::ipsec attest --devices
diff --git a/testing/tests/tnc/tnccs-20-pdp-eap/pretest.dat b/testing/tests/tnc/tnccs-20-pdp-eap/pretest.dat
index ca3c559d1..bc191651c 100644
--- a/testing/tests/tnc/tnccs-20-pdp-eap/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-pdp-eap/pretest.dat
@@ -16,7 +16,8 @@ alice::ipsec start
moon::ipsec start
dave::ipsec start
carol::ipsec start
-carol::sleep 1
+dave::expect-connection home
dave::ipsec up home
+carol::expect-connection home
carol::ipsec up home
carol::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-pdp-pt-tls/pretest.dat b/testing/tests/tnc/tnccs-20-pdp-pt-tls/pretest.dat
index eed7967ee..9427a5c47 100644
--- a/testing/tests/tnc/tnccs-20-pdp-pt-tls/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-pdp-pt-tls/pretest.dat
@@ -13,7 +13,7 @@ alice::chgrp www-data /etc/pts/config.db; chmod g+w /etc/pts/config.db
alice::/var/www/tnc/manage.py setpassword strongSwan strongSwan
alice::service apache2 start
alice::ipsec start
-alice::sleep 1
+alice::expect-connection aaa
winnetou::ip route add 10.1.0.0/16 via 192.168.0.1
dave::ip route add 10.1.0.0/16 via 192.168.0.1
dave::cat /etc/pts/options
@@ -21,4 +21,3 @@ dave::ipsec pt-tls-client --optionsfrom /etc/pts/options
carol::ip route add 10.1.0.0/16 via 192.168.0.1
carol::cat /etc/pts/options
carol::ipsec pt-tls-client --optionsfrom /etc/pts/options
-carol::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-pts-no-ecc/pretest.dat b/testing/tests/tnc/tnccs-20-pts-no-ecc/pretest.dat
index 7a562eec5..0fedb2608 100644
--- a/testing/tests/tnc/tnccs-20-pts-no-ecc/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-pts-no-ecc/pretest.dat
@@ -11,9 +11,9 @@ dave::cat /etc/tnc_config
moon::ipsec start
dave::ipsec start
carol::ipsec start
-dave::sleep 1
+dave::expect-connection home
dave::ipsec up home
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
moon::ipsec attest --sessions
moon::ipsec attest --devices
diff --git a/testing/tests/tnc/tnccs-20-pts/pretest.dat b/testing/tests/tnc/tnccs-20-pts/pretest.dat
index 7a562eec5..0fedb2608 100644
--- a/testing/tests/tnc/tnccs-20-pts/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-pts/pretest.dat
@@ -11,9 +11,9 @@ dave::cat /etc/tnc_config
moon::ipsec start
dave::ipsec start
carol::ipsec start
-dave::sleep 1
+dave::expect-connection home
dave::ipsec up home
+carol::expect-connection home
carol::ipsec up home
-carol::sleep 1
moon::ipsec attest --sessions
moon::ipsec attest --devices
diff --git a/testing/tests/tnc/tnccs-20-server-retry/pretest.dat b/testing/tests/tnc/tnccs-20-server-retry/pretest.dat
index b2b243ba3..85622034d 100644
--- a/testing/tests/tnc/tnccs-20-server-retry/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-server-retry/pretest.dat
@@ -5,9 +5,9 @@ moon::cat /etc/tnc_config
carol::cat /etc/tnc_config
dave::cat /etc/tnc_config
moon::ipsec start
-carol::ipsec start
-dave::ipsec start
-carol::sleep 1
+carol::ipsec start
+dave::ipsec start
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-20-tls/pretest.dat b/testing/tests/tnc/tnccs-20-tls/pretest.dat
index cac1cfafc..85622034d 100644
--- a/testing/tests/tnc/tnccs-20-tls/pretest.dat
+++ b/testing/tests/tnc/tnccs-20-tls/pretest.dat
@@ -7,7 +7,7 @@ dave::cat /etc/tnc_config
moon::ipsec start
carol::ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-20/pretest.dat b/testing/tests/tnc/tnccs-20/pretest.dat
index b2b243ba3..85622034d 100644
--- a/testing/tests/tnc/tnccs-20/pretest.dat
+++ b/testing/tests/tnc/tnccs-20/pretest.dat
@@ -5,9 +5,9 @@ moon::cat /etc/tnc_config
carol::cat /etc/tnc_config
dave::cat /etc/tnc_config
moon::ipsec start
-carol::ipsec start
-dave::ipsec start
-carol::sleep 1
+carol::ipsec start
+dave::ipsec start
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1
diff --git a/testing/tests/tnc/tnccs-dynamic/pretest.dat b/testing/tests/tnc/tnccs-dynamic/pretest.dat
index 60775a11e..927b89d06 100644
--- a/testing/tests/tnc/tnccs-dynamic/pretest.dat
+++ b/testing/tests/tnc/tnccs-dynamic/pretest.dat
@@ -7,7 +7,7 @@ dave::cat /etc/tnc_config
moon::LEAK_DETECTIVE_DISABLE=1 ipsec start
carol::LEAK_DETECTIVE_DISABLE=1 ipsec start
dave::ipsec start
-carol::sleep 1
+carol::expect-connection home
carol::ipsec up home
+dave::expect-connection home
dave::ipsec up home
-dave::sleep 1