-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding user command integration tests to github CI workflow. (#282)
Co-authored-by: Brandon Chatham <brandon.chatham@eigenlabs.org>
- Loading branch information
Showing
8 changed files
with
992 additions
and
1 deletion.
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,23 @@ | ||
CLI_PATH=../../bin/eigenlayer | ||
NETWORK=anvil | ||
RPC_URL=http://localhost:8545 | ||
OUTPUT_FILE_FOLDER=output | ||
|
||
ACCOUNT_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 | ||
FIRST_ADMIN_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | ||
SECOND_ADMIN_ADDRESS=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC | ||
|
||
ACCOUNT_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
FIRST_ADMIN_PRIVATE_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d | ||
SECOND_ADMIN_PRIVATE_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a | ||
|
||
APPOINTEE_1=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | ||
APPOINTEE_2=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC | ||
APPOINTEE_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | ||
|
||
TARGET_ADDRESS=0x3Aa5ebB10DC797CAC828524e59A333d0A371443c | ||
|
||
SELECTOR_1=0x4f906cf9 | ||
SELECTOR_2=0x268959e5 | ||
|
||
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 |
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,310 @@ | ||
#!/usr/bin/env bats | ||
|
||
load './admin_utils.sh' | ||
|
||
setup() { | ||
echo "Setting up test environment..." | ||
rm -f "$OUTPUT_FILE_FOLDER/output_*.txt" | ||
|
||
echo "Listing admins for account $ACCOUNT_ADDRESS..." | ||
output_list_admins=$($CLI_PATH user admin list-admins \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK") | ||
echo "$output_list_admins" | ||
|
||
echo "Running conditional_add_admin..." | ||
output_conditional_add=$(conditional_add_admin \ | ||
"$ACCOUNT_ADDRESS" \ | ||
"$ACCOUNT_ADDRESS" \ | ||
"$ACCOUNT_PRIVATE_KEY" \ | ||
"$PERMISSION_CONTROLLER_ADDRESS" \ | ||
"$RPC_URL" \ | ||
"$NETWORK" \ | ||
"$OUTPUT_ADD_FILE" \ | ||
"$OUTPUT_ACCEPT_FILE") | ||
echo "$output_conditional_add" | ||
} | ||
|
||
teardown() { | ||
echo "Cleaning up test environment..." | ||
rm -f "$OUTPUT_FILE_FOLDER/output_*.txt" | ||
} | ||
|
||
@test "Add $FIRST_ADMIN_ADDRESS as admin (calldata)" { | ||
run $CLI_PATH user admin add-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$ACCOUNT_PRIVATE_KEY" \ | ||
--output-type "calldata" \ | ||
--output-file "$OUTPUT_FILE_FOLDER/output_add_first_admin.txt" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ -s "$OUTPUT_FILE_FOLDER/output_add_first_admin.txt" ]] | ||
} | ||
|
||
@test "Add $FIRST_ADMIN_ADDRESS as admin (broadcast)" { | ||
run $CLI_PATH user admin add-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$ACCOUNT_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Verify $FIRST_ADMIN_ADDRESS is a pending admin" { | ||
run $CLI_PATH user admin is-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--pending-admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" | ||
|
||
echo "$output" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ "$output" == *"Address provided is a pending admin"* ]] | ||
} | ||
|
||
@test "Remove $FIRST_ADMIN_ADDRESS as pending admin (calldata)" { | ||
run $CLI_PATH user admin remove-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$ACCOUNT_PRIVATE_KEY" \ | ||
--output-type "calldata" \ | ||
--output-file "$OUTPUT_FILE_FOLDER/output_remove_pending_first_admin.txt" | ||
|
||
echo "$output" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ -s "$OUTPUT_FILE_FOLDER/output_remove_pending_first_admin.txt" ]] | ||
} | ||
|
||
@test "Remove $FIRST_ADMIN_ADDRESS as pending admin (broadcast)" { | ||
run $CLI_PATH user admin remove-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$ACCOUNT_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Add $FIRST_ADMIN_ADDRESS as admin after removal (broadcast)" { | ||
run $CLI_PATH user admin add-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$ACCOUNT_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Accept $FIRST_ADMIN_ADDRESS as admin (calldata)" { | ||
run $CLI_PATH user admin accept-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--caller-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$FIRST_ADMIN_PRIVATE_KEY" \ | ||
--output-type "calldata" \ | ||
--output-file "$OUTPUT_FILE_FOLDER/output_accept_first_admin.txt" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ -s "$OUTPUT_FILE_FOLDER/output_accept_first_admin.txt" ]] | ||
} | ||
|
||
@test "Accept $FIRST_ADMIN_ADDRESS as admin (broadcast)" { | ||
run $CLI_PATH user admin accept-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$FIRST_ADMIN_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Add $SECOND_ADMIN_ADDRESS as admin (calldata)" { | ||
run $CLI_PATH user admin add-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$SECOND_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$FIRST_ADMIN_PRIVATE_KEY" \ | ||
--output-type "calldata" \ | ||
--output-file "$OUTPUT_FILE_FOLDER/output_add_second_admin.txt" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ -s "$OUTPUT_FILE_FOLDER/output_add_second_admin.txt" ]] | ||
} | ||
|
||
@test "Add $SECOND_ADMIN_ADDRESS as admin (broadcast)" { | ||
run $CLI_PATH user admin add-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$SECOND_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$FIRST_ADMIN_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Verify $SECOND_ADMIN_ADDRESS is listed as a pending admin" { | ||
run $CLI_PATH user admin list-pending-admins \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
|
||
[ "$status" -eq 0 ] | ||
[[ "$output" != *"$FIRST_ADMIN_ADDRESS"* ]] | ||
[[ "$output" == *"$SECOND_ADMIN_ADDRESS"* ]] | ||
} | ||
|
||
@test "Verify $SECOND_ADMIN_ADDRESS is a pending admin" { | ||
run $CLI_PATH user admin is-pending-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--pending-admin-address "$SECOND_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" | ||
|
||
echo "$output" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ "$output" == *"Address provided is a pending admin"* ]] | ||
} | ||
|
||
@test "Accept $SECOND_ADMIN_ADDRESS as admin (calldata)" { | ||
run $CLI_PATH user admin accept-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--caller-address "$SECOND_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$SECOND_ADMIN_PRIVATE_KEY" \ | ||
--output-type "calldata" \ | ||
--output-file "$OUTPUT_FILE_FOLDER/output_accept_second_admin.txt" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ -s "$OUTPUT_FILE_FOLDER/output_accept_second_admin.txt" ]] | ||
} | ||
|
||
@test "Accept $SECOND_ADMIN_ADDRESS as admin (broadcast)" { | ||
run $CLI_PATH user admin accept-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$SECOND_ADMIN_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Verify all three admins are listed after acceptance" { | ||
run $CLI_PATH user admin list-admins \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" | ||
|
||
echo "$output" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ "$output" == *"$ACCOUNT_ADDRESS"* ]] | ||
[[ "$output" == *"$FIRST_ADMIN_ADDRESS"* ]] | ||
[[ "$output" == *"$SECOND_ADMIN_ADDRESS"* ]] | ||
} | ||
|
||
@test "Remove $SECOND_ADMIN_ADDRESS as admin (calldata)" { | ||
run $CLI_PATH user admin remove-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$SECOND_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$FIRST_ADMIN_PRIVATE_KEY" \ | ||
--output-type "calldata" \ | ||
--output-file "$OUTPUT_FILE_FOLDER/output_remove_second_admin.txt" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ -s "$OUTPUT_FILE_FOLDER/output_remove_second_admin.txt" ]] | ||
} | ||
|
||
@test "Remove $SECOND_ADMIN_ADDRESS as admin (broadcast)" { | ||
run $CLI_PATH user admin remove-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$SECOND_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$FIRST_ADMIN_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Remove $FIRST_ADMIN_ADDRESS as admin (calldata)" { | ||
run $CLI_PATH user admin remove-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$ACCOUNT_PRIVATE_KEY" \ | ||
--output-type "calldata" \ | ||
--output-file "$OUTPUT_FILE_FOLDER/output_remove_first_admin.txt" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ -s "$OUTPUT_FILE_FOLDER/output_remove_first_admin.txt" ]] | ||
} | ||
|
||
@test "Remove $FIRST_ADMIN_ADDRESS as admin (broadcast)" { | ||
run $CLI_PATH user admin remove-admin \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--admin-address "$FIRST_ADMIN_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" \ | ||
--ecdsa-private-key "$ACCOUNT_PRIVATE_KEY" \ | ||
--broadcast | ||
|
||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "Verify only root admins remains" { | ||
run $CLI_PATH user admin list-admins \ | ||
--account-address "$ACCOUNT_ADDRESS" \ | ||
--permission-controller-address "$PERMISSION_CONTROLLER_ADDRESS" \ | ||
--eth-rpc-url "$RPC_URL" \ | ||
--network "$NETWORK" | ||
|
||
[ "$status" -eq 0 ] | ||
[[ "$output" == *"$ACCOUNT_ADDRESS"* ]] | ||
[[ "$output" != *"$FIRST_ADMIN_ADDRESS"* ]] | ||
[[ "$output" != *"$SECOND_ADMIN_ADDRESS"* ]] | ||
} |
Oops, something went wrong.