Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rachit77 authored and Stefan-Ethernal committed Feb 27, 2025
1 parent 9a00cf7 commit b404069
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/bats/helpers/lxly-bridge.bash
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,47 @@ function wait_for_expected_token() {
sleep "$poll_frequency"
done
}

function get_claims() {
local aggkit_node_url=$1
local l1_rpc_network_id=$2

claims_result=$(cast rpc --rpc-url "$aggkit_node_url" "bridge_getClaims" "$l1_rpc_network_id")

echo "------ claims_result ------"
echo "$claims_result"

count=$(jq -r '.count' <<< "$claims_result")
if [ "$count" -ne 1 ]; then
echo "Assertion failed. 'count' should be 1. Actual: $count"
exit 1
fi

required_fields=(
"block_num"
"block_timestamp"
"tx_hash"
"global_index"
"origin_address"
"origin_network"
"destination_address"
"destination_network"
"amount"
"from_address"
)

# Check that all required fields exist (and are not null) in claims[0]
for field in "${required_fields[@]}"; do
value=$(jq -r --arg fld "$field" '.claims[0][$fld]' <<< "$claims_result")
if [ "$value" = "null" ] || [ -z "$value" ]; then
echo "Assertion failed. Missing or null '$field' in the first claim object."
exit 1
fi
done

origin_network=$(jq -r '.claims[0].origin_network' <<< "$claims_result")
if [ "$origin_network" -ne 0 ]; then
echo "Assertion failed. 'origin_network' should be 0. Actual: $origin_network"
exit 1
fi
}
6 changes: 6 additions & 0 deletions test/bats/pp/bridge-e2e.bats
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ setup() {
run claim_tx_hash "$timeout" "$bridge_tx_hash" "$destination_addr" "$l2_rpc_url" "$bridge_api_url"
assert_success

echo "------- bridge_getClaims API testcase"
local aggkit_node_url=$(kurtosis port print $enclave cdk-node-001 rpc)
run get_claims $aggkit_node_url $l1_rpc_network_id
assert_success
echo "------- bridge_getClaims API testcase passed"

# Validate that the native token of receiver on L2 has increased by the bridge tokens amount
run verify_balance "$l2_rpc_url" "$native_token_addr" "$receiver" "$initial_receiver_balance" "$tokens_amount"
assert_success
Expand Down

0 comments on commit b404069

Please sign in to comment.