Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: e2e checking for multiples certificates submitted #225

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ jobs:
KURTOSIS_FOLDER: ${{ github.workspace }}/kurtosis-cdk
BATS_LIB_PATH: /usr/lib/
agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }}
TARGET_CERTIFICATE: 2
DEPOSIT_COUNT: 2

- name: Dump enclave logs
if: failure()
Expand Down
43 changes: 29 additions & 14 deletions test/bats/pp/bridge-e2e.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ setup() {
fi
echo "Bridge address=$BRIDGE_ADDRESS" >&3

readonly deposit_count=${DEPOSIT_COUNT:-1}
readonly sender_private_key=${SENDER_PRIVATE_KEY:-"12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"}
readonly sender_addr="$(cast wallet address --private-key $sender_private_key)"
destination_net=${DESTINATION_NET:-"1"}
Expand Down Expand Up @@ -48,26 +49,40 @@ setup() {
readonly weth_token_addr=$(cast call --rpc-url $l2_rpc_url $bridge_addr 'WETHToken()' | cast parse-bytes32-address)
}

# This test is intended for local debugging, generating only a single certificate
@test "Native gas token deposit to WETH" {
destination_addr=$sender_addr
local initial_receiver_balance=$(cast call --rpc-url "$l2_rpc_url" "$weth_token_addr" "$balance_of_fn_sig" "$destination_addr" | awk '{print $1}')
echo "Initial receiver balance of native token on L2 $initial_receiver_balance" >&3

echo "=== Running LxLy deposit on L1 to network: $l2_rpc_network_id native_token: $native_token_addr" >&3
for i in $(seq 1 $deposit_count); do
echo "=== Running #$i LxLy deposit on L1 to network: $l2_rpc_network_id native_token: $native_token_addr" >&3

destination_net=$l2_rpc_network_id
run bridge_asset "$native_token_addr" "$l1_rpc_url"
assert_success
destination_net=$l2_rpc_network_id
destination_net=1
run bridge_asset "$native_token_addr" "$l1_rpc_url"
assert_success

echo "=== Running LxLy claim on L2" >&3
timeout="120"
claim_frequency="10"
run wait_for_claim "$timeout" "$claim_frequency" "$l2_rpc_url"
assert_success
echo "=== Running #$i LxLy claim on L2" >&3
timeout="120"
claim_frequency="10"
run wait_for_claim "$timeout" "$claim_frequency" "$l2_rpc_url"
assert_success

echo "=== bridgeAsset L2 WETH: $weth_token_addr to L1 ETH" >&3
destination_addr=$sender_addr
destination_net=0
run bridge_asset "$weth_token_addr" "$l2_rpc_url"
assert_success
run verify_balance "$l2_rpc_url" "$weth_token_addr" "$destination_addr" \
"$initial_receiver_balance" "$ether_value"
assert_success

echo "=== bridgeAsset L2 WETH: $weth_token_addr to L1 ETH" >&3
destination_addr=$sender_addr
destination_net=0
run bridge_asset "$weth_token_addr" "$l2_rpc_url"
assert_success

echo "Waiting for agglayer certificate to settle before sending another transaction..." >&3
settle_certificates_target=$i
agglayer_timeout=600
run $PROJECT_ROOT/../scripts/agglayer_certificates_monitor.sh "$settle_certificates_target" "$agglayer_timeout" "$l2_rpc_network_id"
assert_success
done
}
6 changes: 4 additions & 2 deletions test/bats/pp/e2e-pp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ setup() {

_common_setup

local target_certificate=${TARGET_CERTIFICATE:-1}
if [ -z "$BRIDGE_ADDRESS" ]; then
local combined_json_file="/opt/zkevm/combined.json"
echo "BRIDGE_ADDRESS env variable is not provided, resolving the bridge address from the Kurtosis CDK '$combined_json_file'" >&3
Expand All @@ -21,6 +22,7 @@ setup() {
readonly bridge_addr=$BRIDGE_ADDRESS
readonly l2_rpc_network_id=$(cast call --rpc-url $l2_rpc_url $bridge_addr 'networkID() (uint32)')

run $PROJECT_ROOT/../scripts/agglayer_certificates_monitor.sh 1 600 $l2_rpc_network_id
run $PROJECT_ROOT/../scripts/agglayer_certificates_monitor.sh \
$target_certificate 600 $l2_rpc_network_id
assert_success
}
}
Loading