Skip to content

Commit 0ee2059

Browse files
update: test:
1 parent e21f0e9 commit 0ee2059

6 files changed

Lines changed: 428 additions & 20 deletions

File tree

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ ships **no** auth/chain JS.
130130
> All list/detail reads are **bounded** — there is no unbounded view, so views
131131
> never revert as the ledger grows.
132132
133+
### Live deployment
134+
135+
| Network | Contract address | Explorer |
136+
| --- | --- | --- |
137+
| **GenLayer Studio** | `0xb9b501D7c617Cd26d93B61BA996fc67a6002379c` | [view contract ↗](https://explorer-studio.genlayer.com/address/0xb9b501D7c617Cd26d93B61BA996fc67a6002379c) |
138+
139+
The frontend reads this from `NEXT_PUBLIC_GRUDGE_CONTRACT_ADDRESS`; redeploys
140+
update `apps/web/.env.local` and `contracts/deployments.json`.
141+
133142
## Deploy to GenLayer
134143

135144
The default real-network target is hosted **GenLayer Studio** (feeless).
@@ -176,10 +185,17 @@ curl -X POST https://studio.genlayer.com/api -H "Content-Type: application/json"
176185
pnpm typecheck && pnpm lint && pnpm test # web: TS strict, ESLint, vitest, wallet-lib guard
177186
pnpm guard:wallet # fail if wagmi/rainbowkit/window.ethereum return
178187
pnpm e2e # Playwright core-loop (mock mode)
179-
make -C contracts lint # ruff --select ALL, mypy --strict, genvm_lint.py
180-
make -C contracts test # settle-math units + gltest --network studionet
188+
make -C contracts lint # ruff --select ALL, mypy --strict, genvm-lint check+typecheck
189+
make -C contracts test # Direct Mode tests (real contract, in-memory) + settle-math
190+
make -C contracts test-chain # Studio-mode integration suite (needs a GenLayer simulator)
181191
```
182192

193+
Contract tests use GenLayer's **Direct Mode** ([docs](https://docs.genlayer.com/api-references/genlayer-test)):
194+
`make test` deploys and runs the REAL `grudge.py` in-memory with the LLM mocked
195+
(`direct_vm.mock_llm`) and the clock controllable (`warp`) — no Docker, no
196+
network, milliseconds. The Studio-mode suite (`test-chain`, `tests/test_grudge.py`)
197+
runs the same flows over real multi-validator consensus against a simulator.
198+
183199
`contracts/scripts/genvm_lint.py` enforces GenVM rules via AST: a `Depends`
184200
header, exactly one `gl.Contract`, storable state, public decorators, no state
185201
mutation in views, nondet calls only inside `gl.eq_principle_*` closures, no

apps/web/app/docs/DocsView.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Link from "next/link";
44
import { useEffect, useState } from "react";
55
import { cn } from "@/lib/utils";
6+
import { explorerAddressUrl, grudgeContractAddress } from "@/lib/chain/bradbury";
67
import { CodeBlock } from "./CodeBlock";
78

89
/**
@@ -57,6 +58,28 @@ function Lead({ children }: { children: React.ReactNode }) {
5758
return <p className="text-mut">{children}</p>;
5859
}
5960

61+
/** Deployed-contract address + explorer link (hidden in mock mode). */
62+
function ContractAddressCard() {
63+
const address = grudgeContractAddress();
64+
if (!address) return null;
65+
return (
66+
<a
67+
href={explorerAddressUrl(address)}
68+
target="_blank"
69+
rel="noopener noreferrer"
70+
className="flex flex-wrap items-center gap-x-3 gap-y-1 rounded-card border border-ink-line bg-ink-soft px-4 py-3 font-mono text-xs transition-colors hover:border-gold/50"
71+
title={`View ${address} on the GenLayer explorer`}
72+
>
73+
<span className="flex items-center gap-2 uppercase tracking-widest text-mut">
74+
<span className="h-1.5 w-1.5 rounded-full bg-gold" />
75+
Deployed contract
76+
</span>
77+
<span className="text-paper">{address}</span>
78+
<span className="text-gold">on GenLayer Explorer ↗</span>
79+
</a>
80+
);
81+
}
82+
6083
function Term({ children }: { children: React.ReactNode }) {
6184
return <code className="rounded bg-ink-raised px-1.5 py-0.5 font-mono text-[13px] text-gold">{children}</code>;
6285
}
@@ -247,6 +270,7 @@ result = gl.eq_principle_prompt_comparative(
247270
Every chain access in the app goes through one adapter; the public methods below are the
248271
full surface of <Term>contracts/grudge.py</Term>.
249272
</Lead>
273+
<ContractAddressCard />
250274
<div className="overflow-x-auto rounded-card border border-ink-line">
251275
<table className="w-full border-collapse text-left text-sm">
252276
<thead>

contracts/Makefile

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,74 @@
44
# pip install ruff mypy pytest gltest (or: make setup)
55
# npm i -g genlayer (GenLayer CLI, for deploy)
66

7-
PY ?= python3
7+
# Use the local virtualenv's tools when it exists (so `make` works without
8+
# manually activating .venv), otherwise fall back to whatever is on PATH.
9+
# The venv bin is also prepended to PATH so tools that shell out to siblings
10+
# (genvm-lint → pyright) find them too.
11+
VENV_BIN := $(if $(wildcard .venv/bin),$(abspath .venv/bin)/,)
12+
ifneq ($(VENV_BIN),)
13+
export PATH := $(abspath .venv/bin):$(PATH)
14+
endif
15+
PY ?= $(if $(VENV_BIN),$(VENV_BIN)python,python3)
16+
RUFF := $(VENV_BIN)ruff
17+
MYPY := $(VENV_BIN)mypy
18+
PYTEST := $(VENV_BIN)pytest
19+
GENVM_LINT := $(VENV_BIN)genvm-lint
820
CONTRACT = grudge.py
921

10-
.PHONY: setup lint format test test-math test-bradbury deploy clean
22+
# gltest is part of the GenLayer toolchain (not on PyPI). Use the venv copy if
23+
# present, otherwise whatever is on PATH.
24+
GLTEST := $(if $(wildcard .venv/bin/gltest),$(VENV_BIN)gltest,gltest)
25+
26+
.PHONY: setup lint check typecheck format test test-math test-chain test-bradbury deploy clean
1127

1228
setup:
13-
$(PY) -m pip install --quiet ruff mypy pytest gltest genvm-linter pyright
29+
$(PY) -m pip install --quiet ruff mypy pytest genlayer-test genvm-linter pyright
1430

1531
lint:
16-
ruff check . --config pyproject.toml
17-
ruff format --check .
18-
MYPYPATH=stubs mypy $(CONTRACT) --strict --config-file pyproject.toml
32+
$(RUFF) check . --config pyproject.toml
33+
$(RUFF) format --check .
34+
MYPYPATH=stubs $(MYPY) $(CONTRACT) --strict --config-file pyproject.toml
1935
$(PY) scripts/genvm_lint.py $(CONTRACT)
20-
genvm-lint check $(CONTRACT) --json
21-
genvm-lint typecheck $(CONTRACT) --json
36+
$(GENVM_LINT) check $(CONTRACT) --json
37+
$(GENVM_LINT) typecheck $(CONTRACT) --json
38+
39+
# GenVM rule lint + contract validation (Depends header, one gl.Contract,
40+
# storable state, public-method ABI, etc.)
41+
check:
42+
$(GENVM_LINT) check $(CONTRACT) --json
43+
44+
# GenVM static typecheck of the contract.
45+
typecheck:
46+
$(GENVM_LINT) typecheck $(CONTRACT) --json
2247

2348
format:
24-
ruff format .
49+
$(RUFF) format .
50+
51+
# CI default: fast Direct Mode tests that run the REAL contract in-memory
52+
# (no Docker, no network, LLM mocked) per the official GenLayer docs, plus the
53+
# pure settlement-math units. Milliseconds, runs everywhere.
54+
test: test-unit
55+
56+
test-unit:
57+
$(PY) -m pytest tests/test_grudge_direct.py tests/test_settle_math.py -q
2558

26-
# CI default: settlement-math unit tests (no network) + gltest vs studionet.
27-
test: test-math
28-
gltest --network studionet
59+
# Back-compat alias.
60+
test-math: test-unit
2961

30-
test-math:
31-
$(PY) -m pytest tests/test_settle_math.py -q
62+
# Studio-mode integration suite (multi-validator consensus over RPC). Point
63+
# NETWORK at a localnet simulator (default) or studionet. Needs gltest
64+
# installed AND a running simulator — run `make setup`.
65+
NETWORK ?= localnet
66+
test-chain:
67+
@command -v $(GLTEST) >/dev/null 2>&1 || { \
68+
echo "✘ gltest not installed. Run: make setup"; exit 1; }
69+
$(GLTEST) tests/test_grudge.py --network $(NETWORK)
3270

3371
# Pre-release verification target — Bradbury history resets periodically,
3472
# so this is NOT the CI default.
3573
test-bradbury:
36-
gltest --network testnet_bradbury
74+
$(GLTEST) --network testnet_bradbury
3775

3876
# Deploys to Bradbury and writes the address into the web app env + a record.
3977
deploy:

contracts/gltest.config.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
networks:
55
default: studionet
6-
# localnet/studionet work out of the box; Bradbury is defined explicitly so
7-
# `gltest --network testnet_bradbury` works for pre-release verification.
8-
# NOTE: Bradbury history resets periodically — verification target, not CI.
6+
# studionet is a preconfigured network, but genlayer-test requires the
7+
# default network to be listed here explicitly. An empty map ({}) keeps its
8+
# preconfigured URL/settings.
9+
studionet: {}
10+
# Bradbury is defined explicitly so `gltest --network testnet_bradbury` works
11+
# for pre-release verification. NOTE: Bradbury history resets periodically.
912
testnet_bradbury:
1013
url: "https://rpc-bradbury.genlayer.com"
1114
leader_only: false

0 commit comments

Comments
 (0)