Skip to content

Latest commit

 

History

History
194 lines (140 loc) · 8.85 KB

File metadata and controls

194 lines (140 loc) · 8.85 KB

Testing Sluice

Step-by-step instructions to verify that Sluice works. No setup is required for Part 1. Everything runs on Casper testnet.

Live instance: https://sluice.unitynodes.com


Part 1: verify the live deployment (about 5 minutes, nothing to install)

1. The matcher is alive

curl https://sluice.unitynodes.com/api/health

Expected:

{"ok":true,"contract":"f3710eaf12c30346eb1c642da832bc1af8ff900254c46bcc49a1efca81d8b971","chain":"casper-test"}

2. Real matched events are being delivered

curl -s https://sluice.unitynodes.com/api/snapshot.json | head -c 400

The recent_events array holds the last 20 real deliveries. Each entry carries the source swap's event.deploy_hash and event.block_height (nested under event, present on every entry — use these for on-chain verification). Escrow-backed lanes also carry the record_delivery receipt as the top-level tx_hash; demo lanes deliver but write no receipt, so their tx_hash is empty. Each entry has the webhook status (200), and the webhook dispatch latency_ms.

Open https://sluice.unitynodes.com/app to see the same data rendered, with the watched subscriptions and their predicates.

Where the traffic comes from: a cron on our side fires one real swap on the DemoDex contract every 15 minutes, so the public feed keeps moving between judging sessions. Those are genuine on-chain transactions, matched by the same engine as any other event, not replayed fixtures. Fire your own at any time with scripts/demo-swap.sh (Part 3) and watch it land.

3. Confirm a delivery against the chain

Take any event.deploy_hash (the source swap) or the top-level tx_hash (the record_delivery receipt) from recent_events and open it on the explorer:

https://testnet.cspr.live/transaction/<deploy_hash>

The transaction is a real swap call on the DemoDex contract. Sluice matched the CES Swap event it emitted and delivered it. Compare the amount_in, token_in, and token_out in the snapshot payload with the event on chain.

4. Pull a real event by paying with x402

Open https://sluice.unitynodes.com/app and press Pull a matched event via x402.

What happens: the browser calls POST /api/x402/pay. A CEP-18 payment is signed and settled through the official hosted Casper x402 facilitator (x402-facilitator.cspr.cloud). On settlement, the matcher releases one real queued event from subscription 200. The page shows the event that was bought and a link to the settlement transaction on testnet.cspr.live.

You are paying for an event Sluice actually matched, not a sample payload.

5. Point an AI agent at the hosted MCP server

The MCP server speaks Streamable HTTP at https://sluice.unitynodes.com/mcp.

curl -s -X POST https://sluice.unitynodes.com/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"probe","version":"1"}}}'

Expected: HTTP 200, content-type: text/event-stream, and a JSON-RPC result naming the server. The hosted endpoint exposes the 2 non-signing tools plus 4 resources, 3 resource templates and 2 prompts; subscribe, cancel and list_subscriptions are stdio-only (subscribe and cancel sign with your Casper key). Use recent_deliveries to read the same feed the dashboard shows.

To wire it into a client, add the URL as a Streamable HTTP MCP server.

6. Metrics

curl -s https://sluice.unitynodes.com/api/metrics | grep sluice_

Prometheus format. sluice_ws_connected reports the upstream CSPR.cloud stream health for both the transfers and the contract-events sockets.


Part 2: run the test suite (about 3 minutes)

Requires Node 20. The Rust toolchain (pinned in contract/rust-toolchain) is only needed for the contract tests.

git clone https://github.com/UnityNodes/Sluice.git
cd Sluice

cd matcher
npm ci
npm run lint      # tsc --noEmit
npm test          # 112 tests
npm run build

cd ../mcp
npm ci
npm run build

cd ../contract
cargo check
cargo test        # 6 tests

Expected: 112 matcher tests and 6 contract tests pass, and both typecheck and build are clean. This is exactly what CI runs on every push (.github/workflows/ci.yml).


Part 3: fire your own on-chain event (optional, needs a funded testnet key)

Requires casper-client and a testnet key with a few CSPR.

scripts/demo-swap.sh 500000 CSPR USDC

This submits a real swap transaction to the DemoDex contract. The contract emits a CES Swap event, CSPR.cloud streams it, the matcher evaluates it against the active predicates, and the match is delivered. Watch it land at https://sluice.unitynodes.com/app, typically within a few seconds of the block being finalized.


Deployed testnet contracts

Contract Package hash What it does
SubscriptionRegistry f3710eaf12c30346eb1c642da832bc1af8ff900254c46bcc49a1efca81d8b971 Holds each subscription and its CSPR escrow. record_delivery(id, event_hash) decrements the escrow once per delivery.
DemoDex ffb5a95650e034784bb8c2f2a2bd03c814f8edf9a895b10d3edd4690e907b7b7 A minimal DeFi contract whose non-payable swap emits a CES Swap event. Used to generate real contract events on demand.
WCSPR (CEP-18) 3d80df21ba4ee4d66a2a1f60c32570dd5685e4b279f6538162a5fd1314847c1e Wrapped CSPR, the canonical wrapped-native asset on testnet and the token x402 payments settle in. Contract v8 (032706ae…5f4a) exposes transfer_with_authorization, receive_with_authorization, authorization_state and cancel_authorization, the full surface the exact scheme needs. Because WCSPR is 1:1 with native CSPR, the 0.1 per-delivery price is a real CSPR price.

Third-party contracts Sluice watches on testnet

These belong to other Casper teams. Contract events are public data, so watching them needs no coordination. They demonstrate that the engine works against real DeFi and RWA contracts, not only our own.

Project Package hash
Wisp Dollar (stablecoin) 65bedddde009284db1bd62614afc8bbeb405590ddec1669eca3db38b5e18810f
STEWARD Institutional Fund (RWA) 1d25c895320b16f37eb57b344b8b655f56c30ca6e941e903976fc0e97a803409
Meridian RWA 0d5ae3015928b0070f03b9a377cf09fa86c63f3ce86f24b357f570977b786d8d

Sample testnet transactions

Transaction What it shows
37d55534…1eb0 An x402 micropayment settled on-chain through the hosted facilitator. 0.1 WCSPR moved from the paying agent to the feed publisher, and the facilitator paid the gas. This is the payment that buys one matched event delivery.
3fb89280…939efd A swap call on DemoDex at block 8453751. It emitted the CES Swap event (520,000 CSPR in, 518,700 CSPRX out) that Sluice matched and delivered to a webhook in 117 ms.
f665f4f7…14b419 Another DemoDex swap, matched and delivered on the next cycle.
67cb9683…4c7a75 A record_delivery receipt: Sluice matched a swap, POSTed the webhook in 74 ms, then wrote this on-chain and decremented the escrow by 1 CSPR. Delivery and billing, end to end.

Which lanes are escrow-backed

The genuinely escrow-backed lanes are the whale-transfer subscriptions funded from a real wallet (owner ecf442…7309). When one of those matches, the matcher calls record_delivery, decrements the on-chain escrow, and the row is labelled CONFIRMED with a transaction hash you can open on cspr.live.

The DemoDex swap feed (subscription 4) and the RWA watcher lanes are injected demo lanes: they use placeholder owners (aaaa1111…, not a real account hash) and hold no escrow to bill. Their deliveries are real webhook dispatches, but no receipt is written, so they are labelled DELIVERED rather than CONFIRMED. The matcher classifies these by construction — any subscription whose owner is not a plausible on-chain account hash is treated as a demo lane and its balance is zeroed everywhere it is shown (looksSyntheticOwner, matcher/src/index.ts), so a demo lane can never be presented as real escrow. This keeps the public feed running without spending escrow on contracts that are not ours.

To see the difference yourself, compare a CONFIRMED row's transaction hash on the explorer against sluice_record_delivery_results_total in /api/metrics. The full list of prototype limits is in HONEST_LIMITS.md.