Skip to content

Commit

Permalink
Fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Nov 6, 2023
1 parent 1d4554b commit b60607c
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1


FROM golang:1.20-alpine AS is-builder
FROM golang:1.21.3-alpine AS is-builder

ENV PACKAGES curl make git libc-dev bash gcc linux-headers
RUN apk add --no-cache $PACKAGES
Expand All @@ -21,7 +21,7 @@ ADD . /interchain-security

WORKDIR /interchain-security

# Do not specify version here. It leads to odd replacement behavior
# Do not specify version here. It leads to odd replacement behavior
RUN if [ -d "./cosmos-sdk" ]; then go mod edit -replace github.com/cosmos/cosmos-sdk=./cosmos-sdk; fi
RUN go mod tidy

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/cosmos/interchain-security/v3

go 1.21

toolchain go1.21.1
toolchain go1.21.3

require (
cosmossdk.io/errors v1.0.0
Expand Down
11 changes: 11 additions & 0 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func SlashThrottleTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand All @@ -183,6 +184,7 @@ func SlashThrottleTestRun() TestRun {
ipPrefix: "7.7.8",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"15\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
Expand Down Expand Up @@ -213,6 +215,7 @@ func DefaultTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand All @@ -228,6 +231,7 @@ func DefaultTestRun() TestRun {
ipPrefix: "7.7.8",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"15\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
Expand All @@ -244,6 +248,7 @@ func DefaultTestRun() TestRun {
func DemocracyTestRun(allowReward bool) TestRun {
consumerGenChanges := ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"20\" | " +
".app_state.gov.voting_params.voting_period = \"10s\" | " +
".app_state.gov.params.expedited_voting_period = \"5s\" | " +
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
Expand All @@ -270,6 +275,7 @@ func DemocracyTestRun(allowReward bool) TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand Down Expand Up @@ -310,6 +316,7 @@ func MultiConsumerTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"30s\" | " +
".app_state.gov.params.expedited_voting_period = \"15s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand All @@ -324,6 +331,7 @@ func MultiConsumerTestRun() TestRun {
ipPrefix: "7.7.8",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
Expand All @@ -335,6 +343,7 @@ func MultiConsumerTestRun() TestRun {
ipPrefix: "7.7.9",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
Expand Down Expand Up @@ -365,6 +374,7 @@ func ChangeoverTestRun() TestRun {
ipPrefix: "7.7.7",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
// Custom slashing parameters for testing validator downtime functionality
// See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking
".app_state.slashing.params.signed_blocks_window = \"10\" | " +
Expand All @@ -381,6 +391,7 @@ func ChangeoverTestRun() TestRun {
ipPrefix: "7.7.8",
votingWaitTime: 20,
genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " +
".app_state.gov.params.expedited_voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"15\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
Expand Down
31 changes: 15 additions & 16 deletions tests/e2e/testnet-scripts/start-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ NODES=$(echo "$VALIDATORS" | jq '. | length')
# SETUP NETWORK NAMESPACES, see: https://adil.medium.com/container-networking-under-the-hood-network-namespaces-6b2b8fe8dc2a

# Create virtual bridge device (acts like a switch)
ip link add name virtual-bridge type bridge || true
ip link add name virtual-bridge type bridge || true

for i in $(seq 0 $(($NODES - 1)));
do
VAL_ID=$(echo "$VALIDATORS" | jq -r ".[$i].val_id")
VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[$i].ip_suffix")
NET_NAMESPACE_NAME="$CHAIN_ID-$VAL_ID"
IP_ADDR="$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX/24"
IP_ADDR="$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX/24"

# Create network namespace
# Create network namespace
ip netns add $NET_NAMESPACE_NAME
# Create virtual ethernet device to connect with bridge
# Create virtual ethernet device to connect with bridge
ip link add $NET_NAMESPACE_NAME-in type veth peer name $NET_NAMESPACE_NAME-out
# Connect input end of virtual ethernet device to namespace
ip link set $NET_NAMESPACE_NAME-in netns $NET_NAMESPACE_NAME
Expand All @@ -84,14 +84,14 @@ do
VAL_ID=$(echo "$VALIDATORS" | jq -r ".[$i].val_id")
NET_NAMESPACE_NAME="$CHAIN_ID-$VAL_ID"

# Enable in/out interfaces for the namespace
# Enable in/out interfaces for the namespace
ip link set $NET_NAMESPACE_NAME-out up
ip netns exec $NET_NAMESPACE_NAME ip link set dev $NET_NAMESPACE_NAME-in up
# Enable loopback device
ip netns exec $NET_NAMESPACE_NAME ip link set dev lo up
done

# Assign IP for bridge, to route between default network namespace and bridge
# Assign IP for bridge, to route between default network namespace and bridge
BRIDGE_IP="$CHAIN_IP_PREFIX.254/24"
ip addr add $BRIDGE_IP dev virtual-bridge

Expand Down Expand Up @@ -129,11 +129,11 @@ do
--keyring-backend test \
--recover > /dev/null
fi

# Give validators their initial token allocations
# move the genesis in
mv /$CHAIN_ID/genesis.json /$CHAIN_ID/validator$VAL_ID/config/genesis.json

# give this validator some money
ALLOCATION=$(echo "$VALIDATORS" | jq -r ".[$i].allocation")
$BIN genesis add-genesis-account validator$VAL_ID $ALLOCATION \
Expand Down Expand Up @@ -178,23 +178,23 @@ do
fi

# Make a gentx (this command also sets up validator state on disk even if we are not going to use the gentx for anything)
if [ "$SKIP_GENTX" = "false" ] ; then
if [ "$SKIP_GENTX" = "false" ] ; then
STAKE_AMOUNT=$(echo "$VALIDATORS" | jq -r ".[$i].stake")
$BIN genesis gentx validator$VAL_ID "$STAKE_AMOUNT" \
--home /$CHAIN_ID/validator$VAL_ID \
--keyring-backend test \
--moniker validator$VAL_ID \
--chain-id=$CHAIN_ID

# Copy gentxs to the first validator for possible future collection.
# Copy gentxs to the first validator for possible future collection.
# Obviously we don't need to copy the first validator's gentx to itself
if [ $VAL_ID != $FIRST_VAL_ID ]; then
cp /$CHAIN_ID/validator$VAL_ID/config/gentx/* /$CHAIN_ID/validator$FIRST_VAL_ID/config/gentx/
fi
fi

# Modify tendermint configs of validator
if [ "$TENDERMINT_CONFIG_TRANSFORM" != "" ] ; then
if [ "$TENDERMINT_CONFIG_TRANSFORM" != "" ] ; then
#'s/foo/bar/;s/abc/def/'
sed -i "$TENDERMINT_CONFIG_TRANSFORM" $CHAIN_ID/validator$VAL_ID/config/config.toml
fi
Expand All @@ -209,7 +209,7 @@ if [ "$SKIP_GENTX" = "false" ] ; then
# make the final genesis.json
$BIN genesis collect-gentxs --home /$CHAIN_ID/validator$FIRST_VAL_ID

# and copy it to the root
# and copy it to the root
cp /$CHAIN_ID/validator$FIRST_VAL_ID/config/genesis.json /$CHAIN_ID/genesis.json

# put the now final genesis.json into the correct folders
Expand Down Expand Up @@ -249,7 +249,7 @@ do
do
if [ $i -ne $j ]; then
PEER_VAL_ID=$(echo "$VALIDATORS" | jq -r ".[$j].val_id")
PEER_VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[$j].ip_suffix")
PEER_VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[$j].ip_suffix")
NODE_ID=$($BIN tendermint show-node-id --home /$CHAIN_ID/validator$PEER_VAL_ID)
ADDRESS="$NODE_ID@$CHAIN_IP_PREFIX.$PEER_VAL_IP_SUFFIX:26656"
# (jq -r '.body.memo' /$CHAIN_ID/validator$j/config/gentx/*) # Getting the address from the gentx should also work
Expand Down Expand Up @@ -373,12 +373,11 @@ fi
# poll for chain start
if [[ "$USE_COMETMOCK" == "true" ]]; then
set +e
until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658"; do sleep 0.3 ; done
until $BIN query block --type height 1 --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658"; do sleep 0.3 ; done
set -e
else
set +e
until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":
""}},"block":null}'; do sleep 0.3 ; done
until $BIN query block --type height 1 --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658"; do sleep 0.3 ; done
set -e
fi

Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/testnet-scripts/start-changeover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ NODES=$(echo "$VALIDATORS" | jq '. | length')
# SETUP NETWORK NAMESPACES, see: https://adil.medium.com/container-networking-under-the-hood-network-namespaces-6b2b8fe8dc2a

# Create virtual bridge device (acts like a switch)
ip link add name virtual-bridge type bridge || true
ip link add name virtual-bridge type bridge || true

for i in $(seq 0 $(($NODES - 1)));
do
Expand All @@ -59,11 +59,11 @@ do
VAL_ID=$(echo "$VALIDATORS" | jq -r ".[$i].val_id")
VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[$i].ip_suffix")
NET_NAMESPACE_NAME="$CHAIN_ID-$VAL_ID"
IP_ADDR="$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX/24"
IP_ADDR="$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX/24"

# Create network namespace
# Create network namespace
ip netns add $NET_NAMESPACE_NAME
# Create virtual ethernet device to connect with bridge
# Create virtual ethernet device to connect with bridge
ip link add $NET_NAMESPACE_NAME-in type veth peer name $NET_NAMESPACE_NAME-out
# Connect input end of virtual ethernet device to namespace
ip link set $NET_NAMESPACE_NAME-in netns $NET_NAMESPACE_NAME
Expand All @@ -84,15 +84,15 @@ do
VAL_ID=$(echo "$VALIDATORS" | jq -r ".[$i].val_id")
NET_NAMESPACE_NAME="$CHAIN_ID-$VAL_ID"

# Enable in/out interfaces for the namespace
# Enable in/out interfaces for the namespace
ip link set $NET_NAMESPACE_NAME-out up
ip netns exec $NET_NAMESPACE_NAME ip link set dev $NET_NAMESPACE_NAME-in up
# Enable loopback device
ip netns exec $NET_NAMESPACE_NAME ip link set dev lo up
fi
done

# Assign IP for bridge, to route between default network namespace and bridge
# Assign IP for bridge, to route between default network namespace and bridge
# BRIDGE_IP="$CHAIN_IP_PREFIX.254/24"
# ip addr add $BRIDGE_IP dev virtual-bridge

Expand Down Expand Up @@ -127,7 +127,7 @@ do
fi

# Modify tendermint configs of validator
if [ "$TENDERMINT_CONFIG_TRANSFORM" != "" ] ; then
if [ "$TENDERMINT_CONFIG_TRANSFORM" != "" ] ; then
#'s/foo/bar/;s/abc/def/'
sed -i "$TENDERMINT_CONFIG_TRANSFORM" $CHAIN_ID/validator$VAL_ID/config/config.toml
fi
Expand Down Expand Up @@ -160,7 +160,7 @@ do
do
if [ $i -ne $j ]; then
PEER_VAL_ID=$(echo "$VALIDATORS" | jq -r ".[$j].val_id")
PEER_VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[$j].ip_suffix")
PEER_VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[$j].ip_suffix")
NODE_ID=$($BIN tendermint show-node-id --home /$CHAIN_ID/validator$PEER_VAL_ID)
ADDRESS="$NODE_ID@$CHAIN_IP_PREFIX.$PEER_VAL_IP_SUFFIX:26656"
# (jq -r '.body.memo' /$CHAIN_ID/validator$j/config/gentx/*) # Getting the address from the gentx should also work
Expand All @@ -179,7 +179,7 @@ QUERY_NODE_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[0].ip_suffix")
echo "NODE SUFFIX: $QUERY_NODE_SUFFIX"
# poll for chain start
set +e
until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_NODE_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":""}},"block":null}'; do sleep 0.3 ; done
until $BIN query block --type height 1 --node "tcp://$CHAIN_IP_PREFIX.$QUERY_NODE_SUFFIX:26658"; do sleep 0.3 ; done
set -e

echo "done!!!!!!!!"
Expand Down
16 changes: 8 additions & 8 deletions tests/e2e/testnet-scripts/start-sovereign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ TENDERMINT_CONFIG_TRANSFORM=$6
# SETUP NETWORK NAMESPACES, see: https://adil.medium.com/container-networking-under-the-hood-network-namespaces-6b2b8fe8dc2a

# Create virtual bridge device (acts like a switch)
ip link add name virtual-bridge type bridge || true
ip link add name virtual-bridge type bridge || true

# used globally in the whole script
VAL_ID=$(echo "$VALIDATORS" | jq -r ".[0].val_id")
VAL_IP_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[0].ip_suffix")
NET_NAMESPACE_NAME="$CHAIN_ID-$VAL_ID"
IP_ADDR="$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX/24"
IP_ADDR="$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX/24"

# Create network namespace
# Create network namespace
ip netns add $NET_NAMESPACE_NAME
# Create virtual ethernet device to connect with bridge
# Create virtual ethernet device to connect with bridge
ip link add $NET_NAMESPACE_NAME-in type veth peer name $NET_NAMESPACE_NAME-out
# Connect input end of virtual ethernet device to namespace
ip link set $NET_NAMESPACE_NAME-in netns $NET_NAMESPACE_NAME
Expand All @@ -56,13 +56,13 @@ ip link set $NET_NAMESPACE_NAME-out master virtual-bridge
ip link set virtual-bridge up

NET_NAMESPACE_NAME="$CHAIN_ID-$VAL_ID"
# Enable in/out interfaces for the namespace
# Enable in/out interfaces for the namespace
ip link set $NET_NAMESPACE_NAME-out up
ip netns exec $NET_NAMESPACE_NAME ip link set dev $NET_NAMESPACE_NAME-in up
# Enable loopback device
ip netns exec $NET_NAMESPACE_NAME ip link set dev lo up

# Assign IP for bridge, to route between default network namespace and bridge
# Assign IP for bridge, to route between default network namespace and bridge
BRIDGE_IP="$CHAIN_IP_PREFIX.254/24"
ip addr add $BRIDGE_IP dev virtual-bridge

Expand Down Expand Up @@ -100,7 +100,7 @@ echo "$VALIDATORS" | jq -r ".[0].mnemonic" | $BIN keys add validator$VAL_ID \
--recover > /dev/null

# Modify tendermint configs of validator
if [ "$TENDERMINT_CONFIG_TRANSFORM" != "" ] ; then
if [ "$TENDERMINT_CONFIG_TRANSFORM" != "" ] ; then
#'s/foo/bar/;s/abc/def/'
sed -i "$TENDERMINT_CONFIG_TRANSFORM" $CHAIN_ID/validator$VAL_ID/config/config.toml
fi
Expand All @@ -125,7 +125,7 @@ ip netns exec $NET_NAMESPACE_NAME $BIN $ARGS start &> /$CHAIN_ID/validator$VAL_I

# poll for chain start
set +e
until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":""}},"block":null}'; do sleep 0.3 ; done
until $BIN query block --type height 1 --node "tcp://$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26658"; do sleep 0.3 ; done
set -e

echo "done!!!!!!!!"
Expand Down

0 comments on commit b60607c

Please sign in to comment.