Testing AI wallet infrastructure requires more than just checking if transactions work—you need to validate everything from authentication layers to policy enforcement across multiple blockchain networks. When building financial infrastructure that AI agents will control, comprehensive test coverage becomes critical for preventing costly bugs in production.
Why Testing Matters for AI Wallet Infrastructure
AI agents operate autonomously, often without human oversight. Unlike traditional applications where users can catch and report bugs, AI agents might silently fail or worse—execute unintended transactions that cost real money. A robust testing strategy protects against these scenarios while enabling confident deployments.
The complexity multiplies when you're building a monorepo that spans multiple packages: core wallet functionality, REST APIs, CLI tools, Docker deployment, MCP integration, and DeFi protocol adapters. Each component needs isolated testing while ensuring the entire system works together seamlessly.
Our Monorepo Testing Architecture
WAIaaS uses a 15-package monorepo structure with 631+ test files distributed across packages. This architecture enables us to test each component in isolation while maintaining integration test coverage for the complete system.
Package-Level Test Distribution
The monorepo includes these key packages, each with comprehensive test coverage:
- daemon: Core API server with transaction pipeline testing
- core: Schema validation and business logic tests
- actions: DeFi protocol adapter tests for 15 different providers
- cli: Command-line interface tests covering 20 commands
- mcp: MCP server tests for 45 AI agent tools
- admin: Web UI component and integration tests
- sdk: TypeScript and Python SDK tests
- e2e-tests: End-to-end integration tests
Transaction Pipeline Testing
WAIaaS processes every transaction through a 7-stage pipeline. Each stage requires isolated unit tests plus integration tests for the complete flow:
// Example test for transaction validation stage
describe('Stage 1: Validate Transaction', () => {
it('should reject invalid recipient address', async () => {
const invalidTx = {
type: 'TRANSFER',
to: 'invalid-address',
amount: '0.1'
};
await expect(validateTransaction(invalidTx))
.rejects.toThrow('Invalid recipient address');
});
it('should validate token transfer parameters', async () => {
const tokenTx = {
type: 'TokenTransfer',
to: 'valid-address',
tokenAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: '100'
};
const result = await validateTransaction(tokenTx);
expect(result.isValid).toBe(true);
});
});
Policy Engine Testing
The policy engine enforces 21 different policy types across 4 security tiers. Testing this requires validating each policy type in isolation, then testing combinations that might interact in unexpected ways:
// Testing spending limit policy with multiple tiers
describe('SPENDING_LIMIT Policy', () => {
it('should assign INSTANT tier for small amounts', async () => {
const policy = {
type: 'SPENDING_LIMIT',
rules: {
instant_max_usd: 100,
notify_max_usd: 500,
delay_max_usd: 2000
}
};
const transaction = { amount: '50', type: 'TRANSFER' };
const tier = await evaluatePolicy(policy, transaction);
expect(tier).toBe('INSTANT');
});
it('should enforce daily limits across multiple transactions', async () => {
// Test cumulative spending limits
const policy = { rules: { daily_limit_usd: 1000 } };
// Simulate multiple transactions throughout the day
await executeTransaction({ amount: '800' });
const result = await evaluatePolicy(policy, { amount: '300' });
expect(result.denied).toBe(true);
expect(result.reason).toContain('daily limit exceeded');
});
});
DeFi Protocol Testing
With 15 DeFi protocol integrations, each provider needs comprehensive testing including successful operations, error handling, and edge cases:
// Testing Jupiter swap integration
describe('Jupiter Swap Provider', () => {
it('should calculate swap routes correctly', async () => {
const swapParams = {
inputMint: 'So11111111111111111111111111111111111111112', // SOL
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
amount: '1000000000' // 1 SOL
};
const route = await jupiterProvider.getRoute(swapParams);
expect(route.outAmount).toBeGreaterThan(0);
expect(route.priceImpactPct).toBeLessThan(5); // Max 5% slippage
});
it('should handle insufficient liquidity gracefully', async () => {
const largeSwap = {
inputMint: 'rare-token-address',
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
amount: '999999999999999' // Unreasonably large amount
};
await expect(jupiterProvider.getRoute(largeSwap))
.rejects.toThrow('Insufficient liquidity');
});
});
Authentication and Security Testing
Three authentication methods (masterAuth, sessionAuth, ownerAuth) require thorough security testing:
// Session authentication testing
describe('Session Authentication', () => {
it('should generate valid JWT tokens', async () => {
const session = await createSession({
walletId: 'test-wallet-id',
ttl: 3600
});
expect(session.token).toMatch(/^wai_sess_/);
const decoded = jwt.verify(session.token, JWT_SECRET);
expect(decoded.walletId).toBe('test-wallet-id');
});
it('should reject expired tokens', async () => {
const expiredToken = jwt.sign(
{ walletId: 'test', exp: Math.floor(Date.now() / 1000) - 3600 },
JWT_SECRET
);
await expect(validateSession(expiredToken))
.rejects.toThrow('Token expired');
});
it('should enforce session renewal limits', async () => {
const session = await createSession({
maxRenewals: 2
});
// Should allow renewals up to limit
await renewSession(session.id);
await renewSession(session.id);
// Third renewal should fail
await expect(renewSession(session.id))
.rejects.toThrow('Maximum renewals exceeded');
});
});
MCP Integration Testing
The MCP server provides 45 tools for AI agents. Testing requires validating both individual tool functionality and the MCP protocol implementation:
// MCP tool testing
describe('MCP Tools', () => {
it('should execute get_balance tool correctly', async () => {
const result = await mcpServer.executeTool('get_balance', {});
expect(result).toHaveProperty('balance');
expect(result).toHaveProperty('symbol');
expect(result).toHaveProperty('chain');
});
it('should handle invalid tool parameters', async () => {
const result = await mcpServer.executeTool('send_token', {
// Missing required 'to' parameter
amount: '0.1'
});
expect(result.error).toBeDefined();
expect(result.error.message).toContain('Missing required parameter: to');
});
});
Integration and End-to-End Testing
Beyond unit tests, we run comprehensive integration tests that verify the complete user journey:
// End-to-end transaction flow test
describe('Complete Transaction Flow', () => {
it('should handle AI agent transaction from start to finish', async () => {
// 1. Create wallet with master auth
const wallet = await createWallet({
name: 'test-wallet',
chain: 'solana'
}, { masterAuth: true });
// 2. Create session for AI agent
const session = await createSession({
walletId: wallet.id
});
// 3. Set up policies
await createPolicy({
walletId: wallet.id,
type: 'SPENDING_LIMIT',
rules: { instant_max_usd: 100 }
});
// 4. Execute transaction with session auth
const transaction = await sendToken({
to: 'recipient-address',
amount: '0.1'
}, { sessionToken: session.token });
// 5. Verify transaction completed
expect(transaction.status).toBe('COMPLETED');
expect(transaction.txHash).toBeDefined();
});
});
Testing Strategy for Docker Deployments
Docker deployment introduces additional testing requirements. We test both the container build process and runtime behavior:
# Dockerfile testing with container structure tests
container-structure-test test --image ghcr.io/minhoyoo-iotrust/waiaas:latest --config test/docker-tests.yaml
# Test auto-provision functionality
docker run --rm -e WAIAAS_AUTO_PROVISION=true waiaas:test
The Docker tests verify:
- Container starts correctly with auto-provision
- Health checks respond properly
- Non-root user permissions work
- Volume mounts persist data correctly
- Environment variable configuration applies
Continuous Integration Pipeline
Our CI pipeline runs the complete test suite across multiple environments:
- Unit Tests: All package-level tests in parallel
- Integration Tests: Cross-package integration scenarios
- Docker Tests: Container build and runtime tests
- E2E Tests: Complete user journey validation
- Security Tests: Authentication and policy enforcement
- Performance Tests: Transaction throughput and latency
Each test category must pass before deployment, ensuring consistent quality across all 15 packages.
Quick Start: Running the Test Suite
Want to explore our testing approach? Here's how to run the tests locally:
- Clone the repository:
git clone https://github.com/minhoyoo-iotrust/WAIaaS.git
cd WAIaaS
- Install dependencies:
pnpm install
- Run all tests:
pnpm test
- Run specific package tests:
pnpm --filter @waiaas/daemon test
- Run integration tests:
pnpm test:integration
This gives you hands-on experience with our testing strategy and helps you understand how each component contributes to the overall system reliability.
What's Next
Our comprehensive testing strategy ensures WAIaaS can safely handle AI agent transactions across multiple blockchains and DeFi protocols. The 631+ tests across 15 packages provide confidence for production deployments while maintaining development velocity.
Ready to build AI agents that can handle money safely? Check out the WAIaaS repository or visit waiaas.ai to get started with robust, well-tested wallet infrastructure for your AI agents.