diff --git a/src/p2p/peer_session_handler.cpp b/src/p2p/peer_session_handler.cpp index b57faaa9..f03ff9a2 100644 --- a/src/p2p/peer_session_handler.cpp +++ b/src/p2p/peer_session_handler.cpp @@ -104,7 +104,10 @@ namespace p2p // Check whether contract ids match. if (chall.contract_id != conf::cfg.contract.id) + { + LOG_ERROR << "Contract id mismatch. Dropping connection " << session.display_name(); return -1; + } // Sending the challenge response to the sender. flatbuffers::FlatBufferBuilder fbuf(1024); diff --git a/test/local-cluster/cluster-start.sh b/test/local-cluster/cluster-start.sh index 977f8b63..9879dc0b 100755 --- a/test/local-cluster/cluster-start.sh +++ b/test/local-cluster/cluster-start.sh @@ -1,8 +1,8 @@ #!/bin/bash -# Runs the specified node contract with hpcore docker image. +# Runs the specified node of the local cluster with hpcore docker image. (created via cluster-create.sh) # This script assumes you already have the hpcore docker image and 'hpnet' virtual docker network. -# Usage (to run the node no. 1): ./start.sh 1 +# Usage (to run the node no. 1): ./cluster-start.sh 1 # Validate the node count arg. if [ -n "$1" ] && [ "$1" -eq "$1" ] 2>/dev/null; then diff --git a/test/local-cluster/rundir.sh b/test/local-cluster/rundir.sh new file mode 100755 index 00000000..068404e9 --- /dev/null +++ b/test/local-cluster/rundir.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Runs the specified contract directory with hpcore docker image. +# This script assumes you already have the hpcore docker image and 'hpnet' virtual docker network. +# Usage: ./rundir.sh 1 + +# Validate the node count arg. +if [ -z "$1" ]; then + echo "Error: Please provide contract directory to run." + exit 1 +else + echo "Starting docker container..." +fi + +dir=$(realpath $1) +dirname=$(basename $dir) +n=$1 + +let pubport=8080 + +# Mount the directory $dir into hpcore docker container and run. +# We specify --network=hpnet so all nodes will communicate via 'hpnet' docker virtual network. +# We specify --name for each node so it will be the virtual dns name for each node. +docker run --rm -t -i --network=hpnet --name=hp_$dirname \ + -p ${pubport}:${pubport} \ + --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined \ + --mount type=bind,source=$dir,target=/contract \ + hpcore:latest run /contract \ No newline at end of file