#!/bin/sh
# With no core running, ed2k queues a link in ~/.aMule/ED2KLinks, where amule
# picks it up at start, and rejects a malformed link.
set -eu

export HOME="${AUTOPKGTEST_TMP:-$(mktemp -d)}"
mkdir -p "$HOME/.aMule"

link='ed2k://|file|abc.txt|3|A448017AAF21D8525FC10AE87AA6729D|/'
ed2k "$link" 2>&1
if ! grep -qxF "$link" "$HOME/.aMule/ED2KLinks"; then
	echo "FAIL: the link was not queued"
	exit 1
fi

if ed2k 'ed2k://|file|broken|/' 2>&1; then
	echo "FAIL: the malformed link was accepted"
	exit 1
fi
