<commit_before>#!/bin/bash
set +e
CUR_PATH=$(cd `dirname $0`; pwd)
cd ${CUR_PATH}/../../admintool/
./admintool.sh

setup_node() {
    id=$1
    cd ${CUR_PATH}/../../admintool/release/node${id}
    ./cita setup ${id}
}

start_node() {
    id=$1
    cd ${CUR_PATH}/../../admintool/release/node${id}
    ./cita start ${id} debug
}

stop_node() {
    id=$1
    cd ${CUR_PATH}/../../admintool/release/node${id}
    ./cita stop ${id}
}

stop_all () {
    stop_node 0
    stop_node 1
    stop_node 2
    stop_node 3
    kill -9 $pid
}

start_all () {
    start_node 0
    start_node 1
    start_node 2
    start_node 3
}

get_height(){
    nodeid=$1
    if [ ! -n "$nodeid" ]; then
        nodeid=0
    fi
    h=`${CUR_PATH}/cita_blockNumber.sh 127.0.0.1 $((1337+${nodeid}))`
    h=$(echo $h | sed 's/\"//g')
    echo $((h))    
}

check_height_change () {
    echo "check block height"
    old_height=$(get_height)
    echo "block height $old_height"
    sleep 30
    new_height=$(get_height)
    echo "block height $new_height"
    if [ $new_height -eq $old_height ]; then
        stop_all
        exit 1
    fi
}

check_height_stop () {
    echo "check block height"
    old_height=$(get_height)
    echo "block height $old_height"
    sleep 30
    new_height=$(get_height)
    echo "block height $new_height"
    if [ $new_height -ne $old_height ]; then
        stop_all
        exit 1
    fi
}

create_contract() {
    cd ${CUR_PATH}/../wrk_benchmark_test/
    echo "create contract"
    ./benchmark.sh
    if [ $? -ne 0 ]
    then  
        exit
    fi
}

send_tx() {
    cd ${CUR_PATH}/../wrk_benchmark_test/
    while [ 0 -le 1 ]
    do
        echo "call contract"
        ./benchmark.sh config_call.json >/dev/null
        if [ $? -ne 0 ]
        then  
            echo "call contract error"
        fi
        sleep 5
    done
}

echo "###start nodes..."
(setup_node 0;start_node 0) &
(setup_node 1;start_node 1) &
(setup_node 2;start_node 2) &
(setup_node 3;start_node 3) &
echo `date`
echo "###wait for start..."
sleep 120
echo `date`
check_height_change
create_contract
(send_tx)&
pid=$!

echo "###stop node3..."
stop_node 3
check_height_change

echo "###stop node2..."
stop_node 2
check_height_stop

echo "###start node2..."
start_node 2
before_height=$(get_height)
#recover too slow
sleep 420
after_height=$(get_height)
echo "node2 recover block height $after_height"<commit_msg>fix cita basic<commit_after>#!/bin/bash
set +e
CUR_PATH=$(cd `dirname $0`; pwd)
cd ${CUR_PATH}/../../admintool/
./admintool.sh

setup_node() {
    id=$1
    cd ${CUR_PATH}/../../admintool/release/node${id}
    ./cita setup ${id}
}

start_node() {
    id=$1
    cd ${CUR_PATH}/../../admintool/release/node${id}
    ./cita start ${id} debug
}

stop_node() {
    id=$1
    cd ${CUR_PATH}/../../admintool/release/node${id}
    ./cita stop ${id}
}

stop_all () {
    stop_node 0
    stop_node 1
    stop_node 2
    stop_node 3
    killall trans_evm
    killall cita_basic.sh
}

start_all () {
    start_node 0
    start_node 1
    start_node 2
    start_node 3
}

get_height(){
    nodeid=$1
    if [ ! -n "$nodeid" ]; then
        nodeid=0
    fi
    h=`${CUR_PATH}/cita_blockNumber.sh 127.0.0.1 $((1337+${nodeid}))`
    h=$(echo $h | sed 's/\"//g')
    echo $((h))    
}

check_height_change () {
    echo "check block height"
    old_height=$(get_height)
    echo "block height $old_height"
    sleep 30
    new_height=$(get_height)
    echo "block height $new_height"
    if [ $new_height -eq $old_height ]; then
        stop_all
        exit 1
    fi
}

check_height_stop () {
    echo "check block height"
    old_height=$(get_height)
    echo "block height $old_height"
    sleep 30
    new_height=$(get_height)
    echo "block height $new_height"
    if [ $new_height -ne $old_height ]; then
        stop_all
        exit 1
    fi
}

create_contract() {
    cd ${CUR_PATH}/../wrk_benchmark_test/
    echo "create contract"
    ./benchmark.sh
    if [ $? -ne 0 ]
    then  
        exit
    fi
}

send_tx() {
    cd ${CUR_PATH}/../wrk_benchmark_test/
    while [ 0 -le 1 ]
    do
        echo "call contract"
        ./benchmark.sh config_call.json >/dev/null
        if [ $? -ne 0 ]
        then  
            echo "call contract error"
        fi
        sleep 5
    done
}

echo "###start nodes..."
(setup_node 0;start_node 0) &
(setup_node 1;start_node 1) &
(setup_node 2;start_node 2) &
(setup_node 3;start_node 3) &
echo `date`
echo "###wait for start..."
sleep 120
echo `date`
check_height_change
create_contract
(send_tx)&

echo "###stop node3..."
stop_node 3
check_height_change

echo "###stop node2..."
stop_node 2
check_height_stop

echo "###start node2..."
start_node 2
before_height=$(get_height)
#recover too slow
sleep 420
after_height=$(get_height)
echo "node2 recover block height $after_height"
{'fraction_non_alphanumeric': 0.14657505725588174, 'fraction_numerical': 0.023526962315219654, 'mean_word_length': 2.473608098336949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '229016', 'n_tokens_mistral': 1867, 'n_tokens_neox': 1768, 'n_words': 441}