-
Notifications
You must be signed in to change notification settings - Fork 9
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
rachit77
wants to merge
4
commits into
develop
Choose a base branch
from
rachit77/CDK-598
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
setup() { | ||
load '../helpers/common-setup' | ||
load '../helpers/common' | ||
load '../helpers/lxly-bridge' | ||
|
||
_common_setup | ||
|
||
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 | ||
|
||
# Fetching the combined JSON output and filtering to get polygonZkEVMBridgeAddress | ||
combined_json_output=$($contracts_service_wrapper "cat $combined_json_file" | tail -n +2) | ||
bridge_default_address=$(echo "$combined_json_output" | jq -r .polygonZkEVMBridgeAddress) | ||
BRIDGE_ADDRESS=$bridge_default_address | ||
fi | ||
echo "Bridge address=$BRIDGE_ADDRESS" >&3 | ||
|
||
readonly sender_private_key=${SENDER_PRIVATE_KEY:-"12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"} | ||
readonly sender_addr="$(cast wallet address --private-key $sender_private_key)" | ||
destination_net=${DESTINATION_NET:-"1"} | ||
destination_addr=${DESTINATION_ADDRESS:-"0x0bb7AA0b4FdC2D2862c088424260e99ed6299148"} | ||
ether_value=${ETHER_VALUE:-"0.0200000054"} | ||
amount=$(cast to-wei $ether_value ether) | ||
readonly native_token_addr=${NATIVE_TOKEN_ADDRESS:-"0x0000000000000000000000000000000000000000"} | ||
if [[ -n "$GAS_TOKEN_ADDR" ]]; then | ||
echo "Using provided GAS_TOKEN_ADDR: $GAS_TOKEN_ADDR" >&3 | ||
gas_token_addr="$GAS_TOKEN_ADDR" | ||
else | ||
echo "GAS_TOKEN_ADDR not provided, retrieving from rollup parameters file." >&3 | ||
readonly rollup_params_file=/opt/zkevm/create_rollup_parameters.json | ||
run bash -c "$contracts_service_wrapper 'cat $rollup_params_file' | tail -n +2 | jq -r '.gasTokenAddress'" | ||
assert_success | ||
assert_output --regexp "0x[a-fA-F0-9]{40}" | ||
gas_token_addr=$output | ||
fi | ||
readonly is_forced=${IS_FORCED:-"true"} | ||
readonly bridge_addr=$BRIDGE_ADDRESS | ||
readonly meta_bytes=${META_BYTES:-"0x"} | ||
|
||
readonly l1_rpc_url=${L1_ETH_RPC_URL:-"$(kurtosis port print $enclave el-1-geth-lighthouse rpc)"} | ||
readonly bridge_api_url=${BRIDGE_API_URL:-"$(kurtosis port print $enclave zkevm-bridge-service-001 rpc)"} | ||
|
||
readonly dry_run=${DRY_RUN:-"false"} | ||
readonly l1_rpc_network_id=$(cast call --rpc-url $l1_rpc_url $bridge_addr 'networkID() (uint32)') | ||
readonly l2_rpc_network_id=$(cast call --rpc-url $l2_rpc_url $bridge_addr 'networkID() (uint32)') | ||
gas_price=$(cast gas-price --rpc-url "$l2_rpc_url") | ||
readonly weth_token_addr=$(cast call --rpc-url $l2_rpc_url $bridge_addr 'WETHToken()' | cast parse-bytes32-address) | ||
} | ||
|
||
@test "Native Gas Token Deposit and Withdrawal Workflow" { | ||
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 first 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 | ||
|
||
echo "=== Running first LxLy claim on L2" >&3 | ||
timeout="120" | ||
claim_frequency="10" | ||
run wait_for_claim "$timeout" "$claim_frequency" "$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 one agglayer certificate to settle before the second transaction..." >&3 | ||
settle_certificates_target=1 | ||
agglayer_timeout=600 | ||
run $PROJECT_ROOT/../scripts/agglayer_certificates_monitor.sh "$settle_certificates_target" "$agglayer_timeout" "$l2_rpc_network_id" | ||
assert_success | ||
|
||
echo "=== Running second LxLy deposit on L1 to network: $l2_rpc_network_id native_token: $native_token_addr" >&3 | ||
destination_net=1 | ||
run bridge_asset "$native_token_addr" "$l1_rpc_url" | ||
assert_success | ||
|
||
echo "=== Running second LxLy claim on L2" >&3 | ||
run wait_for_claim "$timeout" "$claim_frequency" "$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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not expanding the existing one to send multiple deposits? Or even better to somehow parameterize how many of deposits we want to make?
So the optimal approach for me is to keep only the
bridge-e2e.bats
and either change the existingNative gas token deposit to WETH
test to perform multiple deposits, or parameterize that test with deposits count (so that we can provide only single deposit in case we want to debug it for example). WDYT?