Skip to content

Commit

Permalink
expect two error calls
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy committed Dec 2, 2024
1 parent 5fd231b commit 1226186
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 77 deletions.
9 changes: 6 additions & 3 deletions yarn-project/end-to-end/scripts/native-network/validators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ if [ "$NUM_VALIDATORS" -eq 1 ]; then
echo "Running single validator directly"
eval "${CMD[0]}"
else
echo "Running $NUM_VALIDATORS validators interleaved"
# Execute the run_interleaved.sh script with the commands
"$(git rev-parse --show-toplevel)/scripts/run_interleaved.sh" "${CMD[@]}"
echo "Running $NUM_VALIDATORS validators sequentially, interleaved"
FIRST_PORT=8081

# Use run_interleaved with a wait condition
WAIT_CONDITION="curl -s http://127.0.0.1:$FIRST_PORT/status >/dev/null"
"$(git rev-parse --show-toplevel)/scripts/run_interleaved.sh" -w "$WAIT_CONDITION" "${CMD[@]}"
fi
139 changes: 78 additions & 61 deletions yarn-project/end-to-end/scripts/network_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set -eux
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Main positional parameter
TEST="$1"
TEST=${1:-}

REPO=$(git rev-parse --show-toplevel)
if [ "$(uname)" = "Linux" ] && [ "$(uname -m)" = "x86_64" ]; then
Expand All @@ -39,8 +39,8 @@ if [ -z "${NAMESPACE:-}" ]; then
exit 1
fi

if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/aztec:$AZTEC_DOCKER_TAG" || \
! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG"; then
if ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/aztec:$AZTEC_DOCKER_TAG" ||
! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -q "aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG"; then
echo "Docker images not found. They need to be built with 'earthly ./yarn-project/+export-e2e-test-images' or otherwise tagged with aztecprotocol/aztec:$AZTEC_DOCKER_TAG and aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG."
exit 1
fi
Expand All @@ -56,15 +56,15 @@ fi
STERN_PID=""
function copy_stern_to_log() {
ulimit -n 4096
stern spartan -n $NAMESPACE > $SCRIPT_DIR/network-test.log &
stern spartan -n $NAMESPACE >$SCRIPT_DIR/network-test.log &
STERN_PID=$!
}

function show_status_until_pxe_ready() {
set +x # don't spam with our commands
set +x # don't spam with our commands
sleep 15 # let helm upgrade start
for i in {1..100} ; do
if kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=20s >/dev/null 2>/dev/null ; then
for i in {1..100}; do
if kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=20s >/dev/null 2>/dev/null; then
break # we are up, stop showing status
fi
# show startup status
Expand All @@ -74,38 +74,51 @@ function show_status_until_pxe_ready() {

# Handle and check chaos mesh setup
handle_network_shaping() {
if [ -n "${CHAOS_VALUES:-}" ]; then
echo "Checking chaos-mesh setup..."

if ! kubectl get service chaos-daemon -n chaos-mesh &>/dev/null; then
# If chaos mesh is not installed, we check the INSTALL_CHAOS_MESH flag
# to determine if we should install it.
if [ "$INSTALL_CHAOS_MESH" ]; then
echo "Installing chaos-mesh..."
cd "$REPO/spartan/chaos-mesh" && ./install.sh
else
echo "Error: chaos-mesh namespace not found!"
echo "Please set up chaos-mesh first. You can do this by running:"
echo "cd $REPO/spartan/chaos-mesh && ./install.sh"
exit 1
fi
fi

echo "Deploying Aztec Chaos Scenarios..."
if ! helm upgrade --install aztec-chaos-scenarios "$REPO/spartan/aztec-chaos-scenarios/" \
--namespace chaos-mesh \
--values "$REPO/spartan/aztec-chaos-scenarios/values/$CHAOS_VALUES" \
--set global.targetNamespace="$NAMESPACE" \
--wait \
--timeout=5m; then
echo "Error: failed to deploy Aztec Chaos Scenarios!"
return 1
fi

echo "Aztec Chaos Scenarios applied successfully"
return 0
if [ -n "${CHAOS_VALUES:-}" ]; then
echo "Checking chaos-mesh setup..."

if ! kubectl get service chaos-daemon -n chaos-mesh &>/dev/null; then
# If chaos mesh is not installed, we check the INSTALL_CHAOS_MESH flag
# to determine if we should install it.
if [ "$INSTALL_CHAOS_MESH" ]; then
echo "Installing chaos-mesh..."
cd "$REPO/spartan/chaos-mesh" && ./install.sh
else
echo "Error: chaos-mesh namespace not found!"
echo "Please set up chaos-mesh first. You can do this by running:"
echo "cd $REPO/spartan/chaos-mesh && ./install.sh"
exit 1
fi
fi

echo "Deploying Aztec Chaos Scenarios..."
if ! helm upgrade --install aztec-chaos-scenarios "$REPO/spartan/aztec-chaos-scenarios/" \
--namespace chaos-mesh \
--values "$REPO/spartan/aztec-chaos-scenarios/values/$CHAOS_VALUES" \
--set global.targetNamespace="$NAMESPACE" \
--wait \
--timeout=5m; then
echo "Error: failed to deploy Aztec Chaos Scenarios!"
return 1
fi

echo "Aztec Chaos Scenarios applied successfully"
return 0
fi

echo "Deploying network shaping configuration..."
if ! helm upgrade --install network-shaping "$REPO/spartan/network-shaping/" \
--namespace chaos-mesh \
--values "$REPO/spartan/network-shaping/values/$CHAOS_VALUES" \
--set global.targetNamespace="$NAMESPACE" \
--wait \
--timeout=5m; then
echo "Error: failed to deploy network shaping configuration!"
return 1
fi

echo "Network shaping configuration applied successfully"
return 0
}

copy_stern_to_log
Expand All @@ -129,13 +142,13 @@ fi

# Install the Helm chart
helm upgrade --install spartan "$REPO/spartan/aztec-network/" \
--namespace "$NAMESPACE" \
--create-namespace \
--values "$REPO/spartan/aztec-network/values/$VALUES_FILE" \
--set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \
--wait \
--wait-for-jobs=true \
--timeout="$INSTALL_TIMEOUT"
--namespace "$NAMESPACE" \
--create-namespace \
--values "$REPO/spartan/aztec-network/values/$VALUES_FILE" \
--set images.aztec.image="aztecprotocol/aztec:$AZTEC_DOCKER_TAG" \
--wait \
--wait-for-jobs=true \
--timeout="$INSTALL_TIMEOUT"

kubectl wait pod -l app==pxe --for=condition=Ready -n "$NAMESPACE" --timeout=10m

Expand Down Expand Up @@ -163,20 +176,24 @@ if ! handle_network_shaping; then
fi
fi

docker run --rm --network=host \
-v ~/.kube:/root/.kube \
-e K8S=true \
-e INSTANCE_NAME="spartan" \
-e SPARTAN_DIR="/usr/src/spartan" \
-e NAMESPACE="$NAMESPACE" \
-e HOST_PXE_PORT=$PXE_PORT \
-e CONTAINER_PXE_PORT=8081 \
-e HOST_ETHEREUM_PORT=$ANVIL_PORT \
-e CONTAINER_ETHEREUM_PORT=8545 \
-e HOST_METRICS_PORT=$METRICS_PORT \
-e CONTAINER_METRICS_PORT=80 \
-e GRAFANA_PASSWORD=$GRAFANA_PASSWORD \
-e DEBUG="aztec:*" \
-e LOG_JSON=1 \
-e LOG_LEVEL=debug \
aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG $TEST
# Run the test if $TEST is not empty
if [ -n "$TEST" ]; then
echo "RUNNING TEST: $TEST"
docker run --rm --network=host \
-v ~/.kube:/root/.kube \
-e K8S=true \
-e INSTANCE_NAME="spartan" \
-e SPARTAN_DIR="/usr/src/spartan" \
-e NAMESPACE="$NAMESPACE" \
-e HOST_PXE_PORT=$PXE_PORT \
-e CONTAINER_PXE_PORT=8081 \
-e HOST_ETHEREUM_PORT=$ANVIL_PORT \
-e CONTAINER_ETHEREUM_PORT=8545 \
-e HOST_METRICS_PORT=$METRICS_PORT \
-e CONTAINER_METRICS_PORT=80 \
-e GRAFANA_PASSWORD=$GRAFANA_PASSWORD \
-e DEBUG="aztec:*" \
-e LOG_JSON=1 \
-e LOG_LEVEL=debug \
aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG $TEST
fi
Original file line number Diff line number Diff line change
Expand Up @@ -584,19 +584,29 @@ describe('L1Publisher integration', () => {
// Expect the tx to revert
await expect(publisher.proposeL2Block(block)).resolves.toEqual(false);

// Expect a proper error to be logged. Full message looks like:
// aztec:sequencer:publisher [ERROR] Rollup process tx reverted. The contract function "propose" reverted. Error: Rollup__InvalidInHash(bytes32 expected, bytes32 actual) (0x00089a9d421a82c4a25f7acbebe69e638d5b064fa8a60e018793dcb0be53752c, 0x00a5a12af159e0608de45d825718827a36d8a7cdfa9ecc7955bc62180ae78e51) blockNumber=1 slotNumber=49 blockHash=0x131c59ebc2ce21224de6473fe954b0d4eb918043432a3a95406bb7e7a4297fbd txHash=0xc01c3c26b6b67003a8cce352afe475faf7e0196a5a3bba963cfda3792750ed28
expect(loggerErrorSpy).toHaveBeenCalledWith('Rollup publish failed', expect.stringContaining('0xcd6f4233'));
// NOTE: Reinstate check below with #10066
// expect(loggerErrorSpy).toHaveBeenCalledWith(
// expect.stringMatching(/Rollup__InvalidInHash/),
// undefined,
// expect.objectContaining({
// blockHash: expect.any(String),
// blockNumber: expect.any(Number),
// slotNumber: expect.any(BigInt),
// }),
// );
// Test for both calls
expect(loggerErrorSpy).toHaveBeenCalledTimes(2);

// Test first call
expect(loggerErrorSpy).toHaveBeenNthCalledWith(
1,
expect.stringMatching(/^L1 Transaction 0x[a-f0-9]{64} reverted$/),
);

// Test second call
expect(loggerErrorSpy).toHaveBeenNthCalledWith(
2,
expect.stringMatching(
/^Rollup process tx reverted\. The contract function "propose" reverted\. Error: Rollup__InvalidInHash/,
),
undefined,
expect.objectContaining({
blockHash: expect.any(String),
blockNumber: expect.any(Number),
slotNumber: expect.any(BigInt),
txHash: expect.any(String),
}),
);
});
});
});
Expand Down

0 comments on commit 1226186

Please sign in to comment.