#!/usr/bin/env bash

. ./test.common

test_start "PTP port"

# Block communication between 3 and 1
base_delay="(+ 1e-4 (* -1 (equal 0.1 from 3) (equal 0.1 to 1)))"

cat > tmp/peer.keys <<-EOF
1 MD5 1234567890
EOF

clients=2
peers=2
max_sync_time=420

server_conf="
ptpport 319"
client_conf="
ptpport 319
authselectmode ignore
keyfile tmp/peer.keys"
client_server_options="minpoll 6 maxpoll 6 port 319"
client_peer_options="minpoll 6 maxpoll 6 port 319 key 1"

run_test || test_fail
check_chronyd_exit || test_fail
check_source_selection || test_fail
check_sync || test_fail

check_file_messages "	2	1	.*	319	319	1	96	" 150 160 \
	log.packets || test_fail
check_file_messages "	1	2	.*	319	319	1	96	" 150 160 \
	log.packets || test_fail
check_file_messages "	2	3	.*	319	319	1	116	" 150 160 \
	log.packets || test_fail
check_file_messages "	3	2	.*	319	319	1	116	" 150 160 \
	log.packets || test_fail

test_pass
