Skip to content

Conversation

@nazreen
Copy link
Contributor

@nazreen nazreen commented Jan 7, 2026

This PR combines 2 issues into one.

DEVREL-1132 test(oft-solana): add solana tests

Problem

  • Solana OFT had no tests

Solution

  • Port in test harness from an existing implementation

Changes

  • Tests and helpers:
    • Add examples/oft-solana/test/anchor with suites, helpers, constants, and harness setup.
  • Tooling and scripts:
    • Add examples/oft-solana/scripts/generate-features.ts and the test:generate-features script.
  • Config and deps:
    • Update examples/oft-solana/Anchor.toml, examples/oft-solana/package.json, .gitignore, and examples/oft-solana/pnpm-lock.yaml.
  • Bonus: Also fixed existing lint warnings

How to test

  • pnpm test:anchor
    • Runs feature cache generation, Anchor build, and ts-mocha suite.
  • anchor test
    • Uses the Anchor.toml script to invoke pnpm test:anchor.

DEVREL-1077 migrate oft-solana anchor tests from solana-test-validator to Surfpool

Changes

  • LayerZero programs are now cloned from mainnet-beta
  • Replaced test:generate-features script with resolve-oft-id.js for dynamic OFT program ID resolution.
  • Rewrote index.test.ts to start Surfpool, clone LayerZero programs, and reset infrastructure accounts.
  • Extended got-shim.cjs with local program keypair generation for offline/local testing.
  • Updated layerzero-infrastructure.test.ts to use Surfpool RPC calls for program cloning.
  • Added README documentation for pnpm test:anchor with Surfpool environment variables.
  • Removed generate-features.ts (92 lines) and test:generate-features npm script.

Example Run

Setting up test environment...
Starting surfpool (upstream: https://api.mainnet-beta.solana.com)...
Waiting for surfnet to start...
Surfnet started.
Priming LayerZero programs from https://api.mainnet-beta.solana.com...
Cloning endpoint...
Cloning uln...
Cloning executor...
Cloning pricefeed...
Cloning dvn...
Program oft (27cGdR9zfM4G1TVXxZQqCv6ebHbhczBFp9rpdr9g9wRR) not found upstream; deploying locally.
Skipping program authority update for OFT: Surfnet RPC surfnet_setProgramAuthority failed: Invalid program account 27cGdR9zfM4G1TVXxZQqCv6ebHbhczBFp9rpdr9g9wRR
Deploying OFT program to Surfnet...
Program Id: 27cGdR9zfM4G1TVXxZQqCv6ebHbhczBFp9rpdr9g9wRR

Signature: 2qqG4GJVTupgkwNP5wVsJF1BnhAZL3jGk1EHuQHjGtZXEQvpkp2seMHN99t2J6tSbEAKmE34WXMDLYkJR5X4sSbH

Test environment ready.
LayerZero Infrastructure
LayerZero Infrastructure Setup
✔ Init Endpoint (1640ms)
✔ Init Executor (370ms)
✔ Init PriceFeed (392ms)
✔ Init DVN (400ms)
✔ Init UltraLightNode (1221ms)
✔ Init address lookup table (1185ms)
Instruction Tests
init_oft
✔ rejects init_oft when shared decimals exceed mint decimals (1316ms)
✔ initializes native and adapter OFTs (712ms)
✔ sets OApp libraries and nonces (784ms)
set_oft_config
native config
✔ rejects unauthorized config updates (461ms)
✔ rejects invalid default fee bps (40ms)
✔ sets minimum default fee bps (309ms)
✔ sets maximum default fee bps (410ms)
✔ updates admin, delegate, and fee (2017ms)
adapter config
✔ rejects unauthorized config updates (458ms)
✔ rejects invalid default fee bps (49ms)
✔ sets minimum default fee bps (304ms)
✔ sets maximum default fee bps (409ms)
✔ updates admin, delegate, and fee (1993ms)
set_peer_config
native peer config
✔ rejects unauthorized peer updates (521ms)
✔ rejects invalid fee bps (109ms)
✔ rejects invalid enforced options (80ms)
✔ sets peer addresses and enforced options (907ms)
✔ sets outbound rate limit values (790ms)
adapter peer config
✔ rejects unauthorized peer updates (511ms)
✔ rejects invalid fee bps (150ms)
✔ rejects invalid enforced options (89ms)
✔ sets peer addresses and enforced options (904ms)
✔ sets outbound rate limit values (793ms)
quote instructions
native quotes
✔ rejects slippage when min amount exceeds computed amount (337ms)
✔ returns quoteSend and quoteOft results (338ms)
adapter quotes
✔ rejects slippage when min amount exceeds computed amount (332ms)
✔ returns quoteSend and quoteOft results (345ms)
send instruction
native send failures
✔ rejects slippage when min amount exceeds computed amount (255ms)
✔ rejects invalid sender when remaining accounts are tampered (245ms)
adapter send failures
✔ rejects slippage when min amount exceeds computed amount (258ms)
✔ rejects invalid sender when remaining accounts are tampered (242ms)
LayerZero Simulation
✔ simulates send and receive for native (12990ms)
✔ simulates send and receive for adapter (3226ms)
withdraw_fee
native fee withdrawal
✔ rejects unauthorized fee withdrawal (449ms)
✔ rejects withdrawal above available fees (800ms)
✔ withdraws available fees (1191ms)
adapter fee withdrawal
✔ rejects unauthorized fee withdrawal (395ms)
✔ rejects withdrawal above available fees (860ms)
✔ withdraws available fees (1133ms)
Cleaning up test environment...
Cleanup completed.

45 passing (1m)

How to test

  • Run pnpm test:anchor from examples/oft-solana.
    • Verify Surfpool starts and clones LayerZero programs from mainnet.
    • Verify all 45 tests pass in ~1 minute.

@socket-security
Copy link

socket-security bot commented Jan 7, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🧪 E2E Test Status

E2E tests are non-blocking and validate real blockchain interactions. Failures may occur due to network issues, RPC rate limits, or external service downtime.

Test Runs (Newest First):

  • Run #6716 - Passed - 2026-02-10 17:07 (UTC)
  • Run #6712 - Failed - 2026-02-10 16:33 (UTC)
  • Run #6553 - Passed - 2026-01-09 22:51 (UTC)
  • Run #6549 - Passed - 2026-01-08 08:00 (UTC)
  • Run #6548 - Passed - 2026-01-08 07:10 (UTC)
  • Run #6546 - Passed - 2026-01-08 06:58 (UTC)
  • Run #6545 - Passed - 2026-01-08 01:56 (UTC)
  • Run #6544 - Failed - 2026-01-08 01:30 (UTC)
  • Run #6543 - Failed - 2026-01-07 18:15 (UTC)
  • Run #6542 - Failed - 2026-01-07 17:50 (UTC)

@nazreen nazreen changed the title Init solana tests DEVREL-1132 Init solana tests Jan 7, 2026
@nazreen nazreen changed the title DEVREL-1132 Init solana tests DEVREL-1132 test(oft-solana): add solana tests Jan 7, 2026
@nazreen
Copy link
Contributor Author

nazreen commented Jan 8, 2026

Proof of Test

Ran anchor test successfully locally

  OFT Solana Tests
Setting up test environment...
Downloading LayerZero programs...
Loading mainnet feature flags...
Loaded 26 inactive features from cache.
Starting solana-test-validator...
Waiting for solana to start...
Solana test validator started.
Test environment ready.
    LayerZero Infrastructure
      LayerZero Infrastructure Setup
        ✔ Init Endpoint (17309ms)
        ✔ Init Executor (469ms)
        ✔ Init PriceFeed (459ms)
        ✔ Init DVN (472ms)
        ✔ Init SimpleMessageLib (470ms)
        ✔ Init UltraLightNode (948ms)
        ✔ Init address lookup table (1406ms)
    Instruction Tests
      init_oft
        ✔ rejects init_oft when shared decimals exceed mint decimals (1410ms)
        ✔ initializes native and adapter OFTs (936ms)
        ✔ sets OApp libraries and nonces (928ms)
      set_oft_config
        native config
          ✔ rejects unauthorized config updates (472ms)
          ✔ rejects invalid default fee bps
          ✔ sets minimum default fee bps (465ms)
          ✔ sets maximum default fee bps (465ms)
          ✔ updates admin, delegate, and fee (2350ms)
        adapter config
          ✔ rejects unauthorized config updates (463ms)
          ✔ rejects invalid default fee bps
          ✔ sets minimum default fee bps (467ms)
          ✔ sets maximum default fee bps (465ms)
          ✔ updates admin, delegate, and fee (2332ms)
      set_peer_config
        native peer config
          ✔ rejects unauthorized peer updates (471ms)
          ✔ rejects invalid fee bps
          ✔ rejects invalid enforced options
          ✔ sets peer addresses and enforced options (1407ms)
          ✔ sets outbound rate limit values (928ms)
        adapter peer config
          ✔ rejects unauthorized peer updates (466ms)
          ✔ rejects invalid fee bps
          ✔ rejects invalid enforced options
          ✔ sets peer addresses and enforced options (1403ms)
          ✔ sets outbound rate limit values (937ms)
      quote instructions
        native quotes
          ✔ rejects slippage when min amount exceeds computed amount
          ✔ returns quoteSend and quoteOft results
        adapter quotes
          ✔ rejects slippage when min amount exceeds computed amount
          ✔ returns quoteSend and quoteOft results
      send instruction
        native send failures
          ✔ rejects slippage when min amount exceeds computed amount
          ✔ rejects invalid sender when remaining accounts are tampered
        adapter send failures
          ✔ rejects slippage when min amount exceeds computed amount
          ✔ rejects invalid sender when remaining accounts are tampered
      LayerZero Simulation
        ✔ simulates send and receive for native (3144ms)
        ✔ simulates send and receive for adapter (3257ms)
      withdraw_fee
        native fee withdrawal
          ✔ rejects unauthorized fee withdrawal (472ms)
          ✔ rejects withdrawal above available fees (477ms)
          ✔ withdraws available fees (921ms)
        adapter fee withdrawal
          ✔ rejects unauthorized fee withdrawal (466ms)
          ✔ rejects withdrawal above available fees (471ms)
          ✔ withdraws available fees (928ms)
Cleaning up test environment...
Cleanup completed.


  46 passing (54s)

@nazreen nazreen marked this pull request as ready for review January 8, 2026 08:38
@cursor
Copy link

cursor bot commented Jan 8, 2026

PR Summary

Low Risk
Changes are limited to test tooling/config/docs for the example project and do not affect runtime or on-chain program logic.

Overview
Improves the OFT Solana example’s Anchor testing flow by routing anchor test through pnpm test:anchor, and updating test:anchor to build with a dynamically resolved OFT_ID and run the suite via ts-mocha.

Adds tooling/deps to support the new test harness (axios, ts-mocha, @noble/secp256k1), ignores local test ledger output (test-ledger), and expands README guidance for running Surfpool-backed tests (including SURFPOOL_RPC_URL and SURFPOOL_USE_LOCAL_PROGRAMS).

Includes a changeset bump noting added Solana test coverage and the test-run shim.

Written by Cursor Bugbot for commit 10995bb. This will update automatically on new commits. Configure here.

@nazreen nazreen requested review from fabianhug and lzJxhn January 29, 2026 01:06
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@nazreen nazreen enabled auto-merge February 10, 2026 16:26
@socket-security
Copy link

socket-security bot commented Feb 10, 2026

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Medium
Low adoption: npm @layerzerolabs/metadata-tools

Location: Package overview

From: examples/oft-solana/package.jsonnpm/@layerzerolabs/metadata-tools@3.0.3

ℹ Read more on: This package | This alert | What are unpopular packages?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Unpopular packages may have less maintenance and contain other problems.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@layerzerolabs/metadata-tools@3.0.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant