===========================================
POP TEST CONTRACT
===========================================

Test a smart contract

Usage: pop test [OPTIONS] [PATH] [FILTER]

Arguments:
  [PATH]  Directory path without flag for your project [default: current directory]

Options:
  -p, --path <PATH>  Directory path for your project [default: current directory]
  -h, --help         Print help

Smart contract testing options:
  -e, --e2e           Run end-to-end tests
  -n, --node <NODE>   Path to the contracts node binary to run e2e tests [default: none]
  -y, --skip-confirm  Automatically source the needed binary required without prompting for
                      confirmation
  [FILTER]            Run with the specified test filter

===========================================
USAGE
===========================================

# Run unit tests
cd my-contract
pop test

# Run end-to-end tests (deploys to local chain)
pop test --e2e

# Run e2e tests against custom node
pop test --e2e --node ../my-chain

# Run specific test
pop test test_transfer_works

# Run with filter
pop test transfer

# Auto-source binaries without prompt
pop test --e2e --skip-confirm

===========================================
WHAT IT DOES
===========================================

Unit Tests (pop test):
- Runs tests marked with #[ink::test]
- Can only test state in the contract. Not of another contract or blockchain state.
- Fast feedback during development
- Tests individual functions in isolation

E2E Tests (pop test --e2e):
- Automatically launches local ink-node if `--node` is not provided.
- Deploys contract to actual blockchain
- Executes real transactions
- Tests full deployment and interaction flow
- Validates contract behavior on-chain

===========================================
EXAMPLES
===========================================

# Standard development testing
pop test

# Run specific test by name
pop test test_constructor_works

# Run tests with filter pattern
pop test transfer

# Full integration testing
pop test --e2e

# E2E with custom node binary
pop test --e2e --node ./target/release/my-node

# E2E with auto-confirm (CI/CD)
pop test --e2e --skip-confirm

===========================================
TROUBLESHOOTING
===========================================

Tests fail to compile:
- Check ink! version matches cargo-contract
- Update dependencies: cargo update
- Clean and rebuild: pop clean && pop build

E2E tests hang:
- Kill existing ink-node: lsof -i :9944 | grep LISTEN
- Use --skip-confirm flag
- Check if port 9944 is available

E2E tests fail with "connection refused":
- ink-node binary not found
- Use --node flag to specify path
- Or run: pop install

===========================================
NEXT STEPS
===========================================

After successful tests:

pop build --release
pop up --use-wallet

See: build/contract.txt, up/contract.txt
