Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ dist
resources/production/*.wasm
resources/node-storage/*
resources/local/chainspec.toml
resources/flaky/chainspec.toml

execution_engine_testing/test_support/resources/chainspec.toml

Expand Down
56 changes: 56 additions & 0 deletions generate-flaky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

# This script generates chainspec, config

set -o errexit
set -o nounset
set -o pipefail

generate_timestamp() {
local DELAY=${1}

local SCRIPT=(
"from datetime import datetime, timedelta;"
"print((datetime.utcnow() + timedelta(seconds=${DELAY})).isoformat('T') + 'Z')"
)

python3 -c "${SCRIPT[*]}"
}

generate_chainspec() {
local BASEDIR=${1}
local TIMESTAMP=${2}
local SOURCE="${BASEDIR}/resources/local/chainspec.toml.in"
local TARGET="${BASEDIR}/resources/flaky/chainspec.toml"

export BASEDIR
export TIMESTAMP

touch "${BASEDIR}/resources/flaky/chainspec.toml"

echo "Generating chainspec..."
envsubst < ${SOURCE} > ${TARGET}
}

prepare_config() {
local BASEDIR=${1}
local SOURCE="${BASEDIR}/resources/local/config.toml"
local TARGET="${BASEDIR}/resources/flaky/config.toml"
cp ${SOURCE} ${TARGET}
sed -i 's/# \[network.flakiness\]/[network.flakiness]/g' ${BASEDIR}/resources/flaky/config.toml
sed -i 's/# drop_peer_after_min/drop_peer_after_min/g' ${BASEDIR}/resources/flaky/config.toml
sed -i 's/# drop_peer_after_max/drop_peer_after_max/g' ${BASEDIR}/resources/flaky/config.toml
sed -i 's/# block_peer_after_drop_min/block_peer_after_drop_min/g' ${BASEDIR}/resources/flaky/config.toml
sed -i 's/# block_peer_after_drop_max/block_peer_after_drop_max/g' ${BASEDIR}/resources/flaky/config.toml
}

main() {
local DELAY=${1:-40}
local BASEDIR="$(readlink -f $(dirname ${0}))"
local TIMESTAMP="$(generate_timestamp ${DELAY})"
mkdir -p "${BASEDIR}/resources/flaky"
generate_chainspec ${BASEDIR} ${TIMESTAMP}
prepare_config ${BASEDIR}
}

main $@
2 changes: 1 addition & 1 deletion node/src/components/binary_port/connection_terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ConnectionTerminator {
/// Updates or sets the termination deadline.
/// There will be no update if the termination already happened.
/// Both set and update won't happen if the `in_terminate_at` is in the past.
/// Updating an already running termination countdown happens only if the incomming
/// Updating an already running termination countdown happens only if the incoming
/// `in_terminate_at` is > then the existing one. Returns true if the update was in effect.
/// False otherwise
pub(super) async fn terminate_at(&self, in_terminate_at: Timestamp) -> bool {
Expand Down
Loading