Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below:

ssh user@hostname 'bash -s'< ./test.sh file.txt

But i got the error file.txt doesn't exist .
Can anyone help me on this.

Content of test.sh :

#!/bin/bash
file="$1"
while read line
do
col=`cut -d"|" -f1 <<<$line`
echo $col;
done<$file

Content of file.txt :

XXX|yyyyy
xxxx|12333

It's looking for the file in the remote machine ,never gonna work.

No, it passes ./test.sh to bash on the remote machine.
But argument file.txt is put on the ssh command; put it on the script instead:

ssh user@hostname 'bash -s file.txt'< ./test.sh

Here you definitely need the -s option, otherwise bash would read its commands from file.txt
NB: file.txt must be present on the remote machine. A simple ssh command can only pass one stream that is ./test.sh