Skip to content

Commit

Permalink
feat: split bats tests for fep and pessimistic
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Nov 13, 2024
1 parent 9c48e95 commit d2787e9
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- "fork11-rollup"
- "fork12-validium"
- "fork12-rollup"
- "fork12-pessimistic"
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
5 changes: 5 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ test-e2e-fork12-rollup: stop
./run-e2e.sh fork12 rollup
bats .

.PHONY: test-e2e-fork12-pessimistic
test-e2e-fork12-pessimistic: stop
./run-e2e.sh fork12 pessimistic
bats .

.PHONY: stop
stop:
kurtosis clean --all
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
82 changes: 82 additions & 0 deletions test/bats/pessimistic/bridge-e2e.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
setup() {
load 'helpers/common-setup'
_common_setup
load 'helpers/common'
load 'helpers/lxly-bridge-test'

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 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

destination_net=$l2_rpc_network_id
run bridgeAsset "$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

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 bridgeAsset "$weth_token_addr" "$l2_rpc_url"
assert_success

echo "=== Claim in L1 ETH" >&3
timeout="400"
claim_frequency="60"
run wait_for_claim "$timeout" "$claim_frequency" "$l1_rpc_url"
assert_success
}

14 changes: 14 additions & 0 deletions test/combinations/fork12-pessimistic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
args:
agglayer_image: ghcr.io/agglayer/agglayer:0.2.0-rc.10
cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.60.0-beta8
zkevm_bridge_proxy_image: haproxy:3.0-bookworm
zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.6.0-RC1
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_contracts_image: nulyjkdhthz/zkevm-contracts:v9.0.0-rc.3-pp-fork.12
additional_services: []
consensus_contract_type: pessimistic
sequencer_type: erigon
erigon_strict_mode: false
zkevm_use_gas_token_contract: true
agglayer_prover_sp1_key:
enable_normalcy: true

0 comments on commit d2787e9

Please sign in to comment.