Agent skill

aptos-move-testing

Expert on testing Move smart contracts including unit tests, integration tests, Move Prover formal verification, debugging strategies, test coverage, and CI/CD integration for Aptos development.

Stars 69
Forks 8

Install this agent skill to your Project

npx add-skill https://github.com/raintree-technology/claude-starter/tree/main/skills/aptos/move-testing

Metadata

Additional technical details for this skill

author
raintree
version
1.0

SKILL.md

Aptos Move Testing Expert

Expert on testing Move smart contracts on Aptos blockchain.

Triggers

  • move test, unit test, integration test
  • move prover, formal verification
  • debug, coverage, assert, expect
  • test failure, debugging

Test Attributes

move
#[test]
fun test_basic() { }

#[test(account = @0x1)]
fun test_with_signer(account: &signer) { }

#[test(alice = @0x123, bob = @0x456)]
fun test_multi_signer(alice: &signer, bob: &signer) { }

#[test]
#[expected_failure(abort_code = ERROR_CODE)]
fun test_should_fail() { }

#[test_only]
fun helper_function() { }

Basic Testing Pattern

move
#[test(account = @0x123)]
fun test_resource_creation(account: &signer) {
    let addr = signer::address_of(account);
    
    // Create resource
    create_resource(account);
    
    // Verify exists
    assert!(exists<MyResource>(addr), 0);
    
    // Verify state
    let resource = borrow_global<MyResource>(addr);
    assert!(resource.value == expected, 1);
}

Test Commands

bash
# Run all tests
aptos move test

# Run specific test
aptos move test --filter test_name

# With coverage
aptos move test --coverage

# With gas profiling
aptos move test --gas

# Verbose
aptos move test --verbose

Multi-Signer Testing

move
#[test(alice = @0x123, bob = @0x456)]
fun test_transfer(alice: &signer, bob: &signer) {
    let alice_addr = signer::address_of(alice);
    let bob_addr = signer::address_of(bob);
    
    initialize(alice);
    initialize(bob);
    
    transfer(alice, bob_addr, 100);
    
    assert!(get_balance(alice_addr) == 900, 0);
    assert!(get_balance(bob_addr) == 100, 1);
}

Error Testing

move
#[test]
#[expected_failure(abort_code = ERROR_INSUFFICIENT_BALANCE)]
fun test_insufficient_balance() {
    transfer(from, to, amount_too_large);
}

#[test]
#[expected_failure]  // Any failure
fun test_any_failure() {
    assert!(false, 0);
}

Test-Only Helpers

move
#[test_only]
module test_helpers {
    public fun setup_account(account: &signer): address {
        let addr = signer::address_of(account);
        // Setup logic
        addr
    }
}

Debugging

move
#[test_only]
use std::debug;

#[test]
fun test_with_debug() {
    debug::print(&b"Value:");
    debug::print(&value);
}

Move Prover Specs

move
spec transfer {
    requires sender_balance >= amount;
    ensures global<Balance>(sender).value == 
            old(global<Balance>(sender).value) - amount;
    aborts_if sender_balance < amount;
}

spec module {
    invariant forall addr: address:
        exists<Balance>(addr) ==> global<Balance>(addr).value >= 0;
}
bash
# Run prover
aptos move prove
aptos move prove --filter MyModule

Coverage Goals

Test coverage should include:

  • All public functions
  • All abort conditions
  • All state transitions
  • All access control checks
  • Edge cases (zero, max values, empty)

Common Issues

Resource Already Exists

move
// Check existence first
if (!exists<Resource>(addr)) {
    move_to(account, Resource {});
}

Need Signer

move
// Use test parameter
#[test(account = @0x1)]
fun test_with_signer(account: &signer) { }

Test Timeout

move
// Reduce iterations
#[test]
fun test_optimized() {
    for (i in 0..100) { }  // Not 1000000
}

CI/CD Integration

yaml
name: Move Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Aptos CLI
        run: curl -fsSL "https://aptos.dev/scripts/install_cli.py" | python3
      - name: Run Tests
        run: aptos move test --coverage
      - name: Run Prover
        run: aptos move prove

Best Practices

  • Test all public functions
  • Test all error conditions
  • Use specific abort codes
  • Break complex tests into smaller ones
  • Use test-only helpers for setup
  • Profile gas usage in tests
  • Run prover for critical code

Expand your agent's capabilities with these related and highly-rated skills.

raintree-technology/claude-starter

claude-mcp-expert

Model Context Protocol (MCP) expert for Claude Code. Install, configure, and troubleshoot MCP servers. Covers HTTP, SSE, and stdio transports, authentication, popular integrations (Sentry, GitHub, Jira, Notion, databases). Triggers on MCP, Model Context Protocol, MCP server, installing MCP, connecting tools, webhooks, remote server.

69 8
Explore
raintree-technology/claude-starter

claude-skill-builder

Interactive skill creator for Claude Code and Agent Skills ecosystem. Build SKILL.md files with proper frontmatter, triggers, and structure. Triggers on creating skills, building skills, skill templates, skill frontmatter, allowed-tools, npx add-skill, agent skills.

69 8
Explore
raintree-technology/claude-starter

move-prover

Move Prover formal verification expert for Aptos smart contracts. Write specifications (MSL), preconditions (requires), postconditions (ensures), invariants, abort conditions (aborts_if), quantifiers, schemas, and pragmas. Debug verification failures. Triggers on Move Prover, formal verification, spec, invariant, ensures, requires, aborts_if, precondition, postcondition.

69 8
Explore
raintree-technology/claude-starter

helius

Helius Solana RPC and API expert. High-performance infrastructure for Solana including RPC nodes, DAS API for NFTs/tokens, LaserStream real-time streaming, webhooks, Priority Fee API, Enhanced Transactions, and ZK Compression. Triggers on Helius, Solana RPC, DAS API, Digital Asset Standard, NFT metadata, Solana webhooks, priority fees, LaserStream, ZK compression.

69 8
Explore
raintree-technology/claude-starter

toon-formatter

Token-Oriented Object Notation (TOON) format expert for 30-60% token savings on structured data. Auto-applies to arrays with 5+ items, tables, logs, API responses, database results. Supports tabular, inline, and expanded formats with comma/tab/pipe delimiters. Triggers on large JSON, data optimization, token reduction, structured data, arrays, tables, logs, metrics, TOON.

69 8
Explore
raintree-technology/claude-starter

aptos

Aptos blockchain and Move language expert. Covers Move programming (abilities, generics, resources), Aptos framework modules, smart contract development, token standards (Coin, Fungible Asset, Digital Asset), object model, gas optimization, and dApp integration. Triggers on Aptos, Move language, Move smart contract, Aptos blockchain, abilities, generics, resources, fungible asset, digital asset.

69 8
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results