go test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -v# Basic verification (1,000 iterations)
go run verify_hashing.go
# Comprehensive verification (4,000 iterations, 4 key types)
go run verify_hashing_comprehensive.gogo test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -vgo test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -run TestLedgerKeyHashing_Deterministic -vgo test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -racego test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -count=10go test ./internal/rpc -vgo test ./internal/rpc -bench=BenchmarkLedgerKeyHashing -benchmemgo test ./internal/rpc -bench=BenchmarkLedgerKeyHashing_ContractData -benchmemgo test ./internal/rpc -coverprofile=coverage.outgo tool cover -func=coverage.outgo tool cover -html=coverage.outgo test ./internal/rpc -coverprofile=coverage.out
go tool cover -func=coverage.out | grep cache.gogo run verify_hashing.goExpected Output:
SUCCESS: Consistent hash: 8b283a7411fb24e3540781a645517a01832265d055ba7d0ff3de20b6455c526b
go run verify_hashing_comprehensive.goExpected Output:
=== Comprehensive Hash Consistency Verification ===
Account Key: SUCCESS
Hash: 8b283a7411fb24e3540781a645517a01832265d055ba7d0ff3de20b6455c526b
Trustline Key (USDC): SUCCESS
Hash: 9a1e801b0c33aa25fd3a13d40f2ee71ac62bafc88c2d95e520e962115d7f0515
Offer Key: SUCCESS
Hash: 7f6843b658c09b807599243329053869de1a53bf629cb6086230526ccd026ab9
Contract Data Key: SUCCESS
Hash: 5440938817031b18a8f20ccf1cd25a15f20cccf9c9bf9488c2bce2c4652b6499
All tests passed! Hash consistency verified across 4,000 operations.
for i in {1..5}; do echo "=== Run $i ===" && go run verify_hashing.go; donego build ./internal/rpcgo test ./internal/rpc -v -run TestLedgerKeyHashing 2>&1 | tee test_output.logtime go test ./internal/rpc/cache_test.go ./internal/rpc/cache.gogo test ./internal/rpc -list=Testgo test ./internal/rpc -list=Benchmarkgo test ./internal/rpc -v -race -coverprofile=coverage.out
go tool cover -func=coverage.outgo test ./internal/rpc/cache_test.go ./internal/rpc/cache.go && \
go run verify_hashing.go && \
echo " All validations passed"#!/bin/bash
set -e
echo "Running unit tests..."
go test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -v
echo "Running race detection..."
go test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -race
echo "Running benchmarks..."
go test ./internal/rpc -bench=BenchmarkLedgerKeyHashing -benchmem
echo "Running manual verification..."
go run verify_hashing.go
echo "Running comprehensive verification..."
go run verify_hashing_comprehensive.go
echo "Generating coverage report..."
go test ./internal/rpc -coverprofile=coverage.out
go tool cover -func=coverage.out | grep cache.go
echo " All validations completed successfully!"# Check Go version
go version
# Download dependencies
go mod download
# Verify module integrity
go mod verify
# Clean build cache
go clean -cache# Run with timeout
go test ./internal/rpc -timeout 30s
# Run specific test only
go test ./internal/rpc -run TestLedgerKeyHashing_Deterministic# Make sure to include both files
go test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -v
# Or run the entire package
go test ./internal/rpc -v# Install entr: sudo apt install entr (Linux) or brew install entr (macOS)
ls internal/rpc/*.go | entr -c go test ./internal/rpc -vgo fmt ./internal/rpc/...golangci-lint run ./internal/rpc/...go test ./internal/rpc -coverprofile=coverage.out
go tool cover -func=coverage.out | grep "total:" | awk '{print $3}'| Task | Command |
|---|---|
| Run all tests | go test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -v |
| Run with race detection | go test ./internal/rpc/cache_test.go ./internal/rpc/cache.go -race |
| Run benchmarks | go test ./internal/rpc -bench=. -benchmem |
| Generate coverage | go test ./internal/rpc -coverprofile=coverage.out |
| Manual verification | go run verify_hashing.go |
| Comprehensive verification | go run verify_hashing_comprehensive.go |
All commands should complete successfully with:
- PASS status
- 0 failures
- 0 race conditions
- Consistent hash outputs
- Execution time < 1 second
If any command fails, refer to the troubleshooting section or review the test output for specific error messages.