Skip to content

Commit

Permalink
fix: e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Dec 12, 2024
1 parent 5bcc3ba commit d79d4f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
36 changes: 19 additions & 17 deletions test/bats/pp-multi/bridge-l2_to_l2-e2e.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ setup() {
bridge_addr=$bridge_address
meta_bytes=${META_BYTES:-"0x1234"}
destination_addr=$target_address
timeout="240"
timeout="600"
claim_frequency="30"

gas_price=$(cast gas-price --rpc-url "$l2_rpc_url")
Expand All @@ -36,34 +36,36 @@ setup() {
destination_net=$l2_pp2b_network_id
bridge_asset "$native_token_addr" "$l1_rpc_url"
bridge_tx_hash_pp2=$bridge_tx_hash

echo "=== Running LxLy claim L1 to L2(PP1) for $bridge_tx_hash_pp1" >&3
run claim_tx_hash "$timeout" "$bridge_tx_hash_pp1" "$destination_addr" "$l2_pp1_url" "$l2_pp1b_url"
assert_success

echo "=== Running LxLy claim L1 to L2(PP2) for $bridge_tx_hash_pp2" >&3
run claim_tx_hash "$timeout" "$bridge_tx_hash_pp2" "$destination_addr" "$l2_pp2_url" "$l2_pp2b_url"
assert_success

# reduce eth
ether_value=${ETHER_VALUE:-"0.0100000054"}
amount=$(cast to-wei $ether_value ether)

echo "=== Running LxLy bridge L2(PP1) to L2(PP2) amount:$amount" >&3
destination_net=$l2_pp2b_network_id
bridge_asset "$native_token_addr" "$l2_pp1_url"

echo "=== Running LxLy claim L2(PP1) to L2(PP2) for: $bridge_tx_hash" >&3
# Must read the merkel proof from PP1
run claim_tx_hash "$timeout" "$bridge_tx_hash" "$destination_addr" "$l2_pp2_url" "$l2_pp1b_url"
amount=1234567
echo "=== Running LxLy bridge L2(PP2) to L2(PP1) amount:$amount" >&3
destination_net=$l2_pp1b_network_id
meta_bytes="0xbeef"
bridge_asset "$native_token_addr" "$l2_pp2_url"

echo "=== Running LxLy claim L2(PP2) to L2(PP1) for: $bridge_tx_hash" >&3
run claim_tx_hash "$timeout" "$bridge_tx_hash" "$destination_addr" "$l2_pp1_url" "$l2_pp2b_url"
assert_success

# Now a need to do a bridge on L2 to trigger a certificate:
echo "=== Running LxLy bridge eth L2(PP2) to L1 (trigger a certificate on PP2) amount:$amount" >&3
# Now a need to do a bridge on L2(PP1) to trigger a certificate:
ether_value=${ETHER_VALUE:-"0.0100000054"}
amount=$(cast to-wei $ether_value ether)
echo "=== Running LxLy bridge eth L2(PP1) to L1 (trigger a certificate on PP1) amount:$amount" >&3
destination_net=$l1_rpc_network_id
bridge_asset "$native_token_addr" "$l2_pp2_url"
meta_bytes="0xabcd"
bridge_asset "$native_token_addr" "$l2_pp1_url"

echo "=== Running LxLy claim L2(PP2) to L1 for $bridge_tx_hash" >&3
run claim_tx_hash "$timeout" "$bridge_tx_hash" "$destination_addr" "$l1_rpc_url" "$l2_pp2b_url"
echo "=== Running LxLy claim L2(PP1) to L1 for $bridge_tx_hash" >&3
run claim_tx_hash "$timeout" "$bridge_tx_hash" "$destination_addr" "$l1_rpc_url" "$l2_pp1b_url"
assert_success
}
5 changes: 2 additions & 3 deletions test/helpers/lxly-bridge-test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function claim_tx_hash() {
readonly current_deposit=$(mktemp)
jq '.[(0|tonumber)]' $bridge_deposit_file | tee $current_deposit
readonly current_proof=$(mktemp)
echo ".... requesting merkel proof for $tx_hash deposit_cnt=$curr_deposit_cnt" >&3
echo ".... requesting merkel proof for $tx_hash deposit_cnt=$curr_deposit_cnt network_id: $curr_network_id" >&3
request_merkel_proof "$curr_deposit_cnt" "$curr_network_id" "$bridge_provide_merkel_proof" "$current_proof"
echo ".... requesting claim for $tx_hash" >&3
request_claim $current_deposit $current_proof $destination_rpc_url
Expand Down Expand Up @@ -239,14 +239,13 @@ function request_claim(){
echo "Failed to calculate gas price" >&3
exit 1
fi

echo "... Claiming deposit: global_index: $in_global_index orig_net: $in_orig_net dest_net: $in_dest_net amount:$in_amount" >&3
echo "cast send --legacy --gas-price $comp_gas_price --rpc-url $destination_rpc_url --private-key $sender_private_key $bridge_addr \"$claim_sig\" \"$in_merkle_proof\" \"$in_rollup_merkle_proof\" $in_global_index $in_main_exit_root $in_rollup_exit_root $in_orig_net $in_orig_addr $in_dest_net $in_dest_addr $in_amount $in_metadata"
local tmp_response=$(mktemp)
cast send --legacy --gas-price $comp_gas_price \
--rpc-url $destination_rpc_url \
--private-key $sender_private_key \
$bridge_addr "$claim_sig" "$in_merkle_proof" "$in_rollup_merkle_proof" $in_global_index $in_main_exit_root $in_rollup_exit_root $in_orig_net $in_orig_addr $in_dest_net $in_dest_addr $in_amount $in_metadata 2> $tmp_response || check_claim_revert_code $tmp_response
echo "finish $tmp_res" >&3
fi
}

Expand Down

0 comments on commit d79d4f2

Please sign in to comment.