Skip to content

Commit 83b0b93

Browse files
h4x3rotabclaude
andcommitted
chore(kms/auth-eth): clean up Prek failures inherited from foundry branch
The Prek CI workflow runs `prek run --from-ref base --to-ref head` across the full PR diff, so pre-existing whitespace and shellcheck issues in the foundry branch's anvil helper scripts (added by the original migration contributor) were blocking the PR even though they predated this session. Auto-fixers (trailing-whitespace, end-of-file-fixer) cleaned up 10 files with no behavioral impact. Shellcheck warnings, all in kms/auth-eth/scripts/: - cleanup.sh: dropped unused RED/YELLOW color variables; added `# shellcheck source=/dev/null` for the dynamic source; switched `! -z` → `-n`; quoted `$ANVIL_PID`. - run-tests.sh: source directive; quoted `$ANVIL_PID`, `$SERVER_PID`, `$i`, `$ETH_RPC_URL`; switched `! -z` → `-n`. - setup-local-chain.sh: quoted `$i`. - test-all.sh: added source directive for `../.env.test`. Verification: prek run --from-ref origin/master --to-ref HEAD passes all hooks. forge test --ffi (46/46) and Slither (0 findings) still clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 10cd124 commit 83b0b93

10 files changed

Lines changed: 32 additions & 32 deletions

File tree

kms/auth-eth/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ KMS_CONTRACT_ADDR=0x0000000000000000000000000000000000000000
1818

1919
# For testing with testnet:
2020
# ETH_RPC_URL=https://rpc.sepolia.org
21-
# KMS_CONTRACT_ADDR=<your_deployed_contract_address>
21+
# KMS_CONTRACT_ADDR=<your_deployed_contract_address>

kms/auth-eth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,4 @@ forge snapshot
155155
anvil
156156
```
157157

158-
Documentation: https://book.getfoundry.sh/
158+
Documentation: https://book.getfoundry.sh/

kms/auth-eth/TESTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ npm run test:all # Complete: Anvil + Deploy + API tests + Cleanup
2020

2121
This automatically:
2222
1. Starts Anvil node
23-
2. Deploys contracts
23+
2. Deploys contracts
2424
3. Starts API server
2525
4. Tests all endpoints
2626
5. Cleans up
@@ -44,4 +44,4 @@ curl -X POST http://127.0.0.1:8000/bootAuth/app \
4444
### Cleanup
4545
```bash
4646
npm run test:cleanup # Stop all test processes
47-
```
47+
```

kms/auth-eth/script/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,12 @@ contract MyCustomScript is BaseScript {
324324
function run() external {
325325
// Read parameters
326326
uint256 value = vm.envUint("MY_VALUE");
327-
327+
328328
// Execute transaction
329329
vm.startBroadcast();
330330
kms.someFunction(value);
331331
vm.stopBroadcast();
332-
332+
333333
// Log result
334334
console.log("Executed with value:", value);
335335
}
@@ -341,4 +341,4 @@ contract MyCustomScript is BaseScript {
341341
- Use `--dry-run` to simulate without broadcasting
342342
- Add `-vvvv` for detailed trace output
343343
- Check gas usage with `--gas-report`
344-
- Use `.env` files to manage environment variables
344+
- Use `.env` files to manage environment variables

kms/auth-eth/scripts/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,3 @@ The scripts generate the following log files:
122122
- Node.js and npm
123123
- Foundry (forge, anvil)
124124
- All npm dependencies installed (`npm install`)
125-

kms/auth-eth/scripts/cleanup.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
1111
ENV_FILE="$PROJECT_ROOT/.env.test"
1212

1313
# Colors for output
14-
RED='\033[0;31m'
1514
GREEN='\033[0;32m'
16-
YELLOW='\033[1;33m'
1715
NC='\033[0m'
1816

1917
echo "🧹 Cleaning up test environment..."
@@ -25,12 +23,13 @@ pkill -f "node dist/main.js" || true
2523

2624
# Load environment if exists
2725
if [ -f "$ENV_FILE" ]; then
26+
# shellcheck source=/dev/null
2827
source "$ENV_FILE"
29-
28+
3029
# Kill Anvil if PID is set
31-
if [ ! -z "$ANVIL_PID" ]; then
30+
if [ -n "$ANVIL_PID" ]; then
3231
echo "Stopping Anvil (PID: $ANVIL_PID)..."
33-
kill $ANVIL_PID 2>/dev/null || true
32+
kill "$ANVIL_PID" 2>/dev/null || true
3433
fi
3534
fi
3635

@@ -46,4 +45,4 @@ rm -f "$PROJECT_ROOT/deploy.log"
4645
rm -f "$PROJECT_ROOT/server-test.log"
4746
rm -f "$PROJECT_ROOT/integration-test.js"
4847

49-
echo -e "${GREEN}✅ Cleanup complete!${NC}"
48+
echo -e "${GREEN}✅ Cleanup complete!${NC}"

kms/auth-eth/scripts/run-tests.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if [ ! -f "$ENV_FILE" ]; then
2929
fi
3030

3131
# Load environment variables
32+
# shellcheck source=/dev/null
3233
source "$ENV_FILE"
3334

3435
# Export for child processes
@@ -37,7 +38,7 @@ export KMS_CONTRACT_ADDR
3738
export APP_IMPLEMENTATION
3839

3940
# Check if Anvil is running
40-
if ! kill -0 $ANVIL_PID 2>/dev/null; then
41+
if ! kill -0 "$ANVIL_PID" 2>/dev/null; then
4142
echo -e "${RED}❌ Error: Anvil is not running (PID: $ANVIL_PID)${NC}"
4243
echo -e "${YELLOW}Please run ./scripts/setup-local-chain.sh first${NC}"
4344
exit 1
@@ -59,8 +60,8 @@ npm run build
5960
cleanup() {
6061
echo ""
6162
echo "🧹 Cleaning up..."
62-
if [ ! -z "$SERVER_PID" ]; then
63-
kill $SERVER_PID 2>/dev/null || true
63+
if [ -n "$SERVER_PID" ]; then
64+
kill "$SERVER_PID" 2>/dev/null || true
6465
fi
6566
}
6667
trap cleanup EXIT
@@ -77,7 +78,7 @@ for i in {1..30}; do
7778
echo -e "${GREEN}✅ API server is ready!${NC}"
7879
break
7980
fi
80-
if [ $i -eq 30 ]; then
81+
if [ "$i" -eq 30 ]; then
8182
echo -e "${RED}❌ API server failed to start within 30 seconds${NC}"
8283
cat "$PROJECT_ROOT/server-test.log"
8384
exit 1
@@ -102,13 +103,13 @@ async function runIntegrationTests() {
102103
const baseUrl = 'http://127.0.0.1:8000';
103104
const rpcUrl = process.env.ETH_RPC_URL;
104105
const kmsAddress = process.env.KMS_CONTRACT_ADDR;
105-
106+
106107
console.log('Testing against:');
107108
console.log(' API URL:', baseUrl);
108109
console.log(' RPC URL:', rpcUrl);
109110
console.log(' KMS Contract:', kmsAddress);
110111
console.log('');
111-
112+
112113
const testData = {
113114
tcbStatus: 'UpToDate',
114115
advisoryIds: [],
@@ -120,14 +121,14 @@ async function runIntegrationTests() {
120121
instanceId: '0x3456789012345678901234567890123456789012',
121122
deviceId: '0x' + 'ef12ef12ef12ef12'.repeat(4)
122123
};
123-
124+
124125
const tests = [
125126
{
126127
name: 'Health Check',
127128
run: async () => {
128129
const res = await fetch(baseUrl + '/');
129130
const data = await res.json();
130-
return {
131+
return {
131132
passed: res.status === 200 && data.kmsContractAddr === kmsAddress,
132133
details: `Status: ${res.status}, Contract: ${data.kmsContractAddr}`
133134
};
@@ -191,10 +192,10 @@ async function runIntegrationTests() {
191192
}
192193
}
193194
];
194-
195+
195196
let passed = 0;
196197
let failed = 0;
197-
198+
198199
for (const test of tests) {
199200
try {
200201
const result = await test.run();
@@ -213,10 +214,10 @@ async function runIntegrationTests() {
213214
failed++;
214215
}
215216
}
216-
217+
217218
console.log('');
218219
console.log(`Summary: ${passed} passed, ${failed} failed`);
219-
220+
220221
return failed === 0;
221222
}
222223
@@ -237,7 +238,7 @@ rm -f "$PROJECT_ROOT/integration-test.js"
237238
# Run Foundry tests
238239
echo ""
239240
echo -e "${BLUE}🔨 Running Foundry tests...${NC}"
240-
ETHERSCAN_API_KEY=dummy forge test --ffi --rpc-url $ETH_RPC_URL
241+
ETHERSCAN_API_KEY=dummy forge test --ffi --rpc-url "$ETH_RPC_URL"
241242
FOUNDRY_RESULT=$?
242243

243244
# Summary
@@ -261,4 +262,4 @@ if [ $INTEGRATION_RESULT -ne 0 ] || [ $FOUNDRY_RESULT -ne 0 ]; then
261262
fi
262263

263264
echo ""
264-
echo -e "${GREEN}✅ All tests passed!${NC}"
265+
echo -e "${GREEN}✅ All tests passed!${NC}"

kms/auth-eth/scripts/setup-local-chain.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ for i in {1..30}; do
5353
echo -e "${GREEN}✅ Anvil is ready!${NC}"
5454
break
5555
fi
56-
if [ $i -eq 30 ]; then
56+
if [ "$i" -eq 30 ]; then
5757
echo -e "${RED}❌ Anvil failed to start within 30 seconds${NC}"
5858
cat "$PROJECT_ROOT/anvil.log"
5959
exit 1
@@ -125,4 +125,4 @@ echo " Anvil: $PROJECT_ROOT/anvil.log"
125125
echo " Deploy: $PROJECT_ROOT/deploy.log"
126126
echo ""
127127
echo -e "${YELLOW}ℹ️ To stop Anvil: kill $ANVIL_PID${NC}"
128-
echo -e "${YELLOW}ℹ️ To run tests: ./scripts/run-tests.sh${NC}"
128+
echo -e "${YELLOW}ℹ️ To run tests: ./scripts/run-tests.sh${NC}"

kms/auth-eth/scripts/test-all.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ echo "Step 2: Running tests..."
2828
"$SCRIPT_DIR/run-tests.sh" "$@"
2929

3030
# Load env to get PID
31+
# shellcheck source=/dev/null
3132
source "$SCRIPT_DIR/../.env.test"
3233

3334
echo ""
3435
echo -e "${GREEN}✅ Complete test suite finished!${NC}"
3536
echo ""
3637
echo -e "${YELLOW}ℹ️ To stop the local chain: kill $ANVIL_PID${NC}"
37-
echo -e "${YELLOW}ℹ️ To run tests again: ./scripts/run-tests.sh${NC}"
38+
echo -e "${YELLOW}ℹ️ To run tests again: ./scripts/run-tests.sh${NC}"

kms/auth-eth/src/ethereum.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { BootInfo, BootResponse } from './types';
88
// Minimal ABI for DstackKms contract
99
const DSTACK_KMS_ABI = [
1010
"function isAppAllowed((address appId,bytes32 composeHash,address instanceId,bytes32 deviceId,bytes32 mrAggregated,bytes32 mrSystem,bytes32 osImageHash,string tcbStatus,string[] advisoryIds) bootInfo) view returns (bool, string)",
11-
"function isKmsAllowed((address appId,bytes32 composeHash,address instanceId,bytes32 deviceId,bytes32 mrAggregated,bytes32 mrSystem,bytes32 osImageHash,string tcbStatus,string[] advisoryIds) bootInfo) view returns (bool, string)",
11+
"function isKmsAllowed((address appId,bytes32 composeHash,address instanceId,bytes32 deviceId,bytes32 mrAggregated,bytes32 mrSystem,bytes32 osImageHash,string tcbStatus,string[] advisoryIds) bootInfo) view returns (bool, string)",
1212
"function gatewayAppId() view returns (string)",
1313
"function appImplementation() view returns (address)"
1414
];

0 commit comments

Comments
 (0)