Skip to content
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

Adding user command integration tests to github CI workflow. #282

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,54 @@ jobs:
--claimer-address 0x2222AAC0C980Cc029624b7ff55B88Bc6F63C538f \
--web3signer-url http://127.0.0.1:9001 \
--verbose \
--broadcast
--broadcast

UserIntegrationTests:
name: Integration Test - User Commands
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-c4a984fbf2c48b793c8cd53af84f56009dd1070c

- name: Checkout eigensdk-go
uses: actions/checkout@v4
with:
repository: layr-labs/eigensdk-go
token: ${{ github.token }}
ref: 549e0185cee644d0a6fc9c9863f1cf76d9ef971f

- name: Run anvil chain
run: |
nohup make start-anvil-with-contracts-deployed > nohup.out 2>&1 &

- name: Install EigenLayer CLI
uses: actions/checkout@v4
with:
path: eigenlayer-cli

- name: Setup BATS
uses: mig4/setup-bats@v1

- name: Install EigenLayer CLI
run: |
cd eigenlayer-cli
make build
./bin/eigenlayer --version

- name: Prepare Integration Test Environment
run: |
echo "Preparing environment for integration tests."
cd eigenlayer-cli
cd tests/user
chmod +x user-integration-tests-runner.sh

- name: Run User Command Integration Tests
run: |
cd eigenlayer-cli
bats tests/user/user-integration-tests-runner.sh
23 changes: 23 additions & 0 deletions tests/user/.env
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
311 changes: 311 additions & 0 deletions tests/user/admin/admin_lifecycle_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
#!/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" != *"$ACCOUNT_ADDRESS"* ]]
[[ "$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"* ]]
}
Loading
Loading