-
Notifications
You must be signed in to change notification settings - Fork 1
Init community scripts #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
21db2f0
c2fee83
b32da00
7fee421
58c05d1
1d7d01e
bd5959b
7ce0f6e
984286d
99f100a
f5129a8
c3d6033
ce3c54f
177d543
25da0e7
52dbe67
30481ce
27bd1f5
c3d4559
daf3534
0c9594f
5bf2c0b
d24fe2b
f695f0e
b0d30b7
249933c
a85c420
be2c85f
1749467
7cf502f
d5a4123
adf0d7f
cb18e14
aa6e6f3
b9fdf90
a16790f
834888d
f40b3b5
0466224
ea5daa0
cc3adb1
df322d2
cf68698
ee86dfb
889cf17
00fdb67
1c05fc2
06e0baa
842dbaa
b2fb04d
1d8dd60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| name: Community Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, init-community-scripts] | ||
| pull_request: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
| inputs: | ||
| run_test13: | ||
| description: 'Run on test-13' | ||
| type: boolean | ||
| default: true | ||
| run_test12: | ||
| description: 'Run on test12' | ||
| type: boolean | ||
| default: true | ||
| test_type: | ||
| description: 'Test type' | ||
| type: choice | ||
| default: both | ||
| options: [one-shot, repeatable, both] | ||
|
|
||
| # Optional repository variables (Settings → Secrets and variables → Actions → Variables): | ||
| # vars.REMOTES_TEST13 — comma-separated RPC list for test-13 | ||
| # vars.CHAINID_TEST13 — chain ID for test-13 (default: test-13) | ||
| # vars.REMOTES_TEST12 — comma-separated RPC list for test12 | ||
| # vars.CHAINID_TEST12 — chain ID for test12 (default: test12) | ||
| # | ||
| # The test1 funder mnemonic is public and hardcoded in funders/ — no secret needed. | ||
| # The funder script runs inside a gnokey Docker container — no local | ||
| # gnokey installation required on the runner. | ||
|
|
||
| jobs: | ||
| tests-one-shot: | ||
| name: One-shot — ${{ matrix.network.name }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| network: | ||
| - name: test-13 | ||
| remotes: ${{ vars.REMOTES_TEST13 || 'https://rpc.test-13-aeddi-1.gnoland.network,https://rpc.test-13-gfanton-1.gnoland.network,https://rpc.test-13-moul-1.gnoland.network' }} | ||
| chainid: ${{ vars.CHAINID_TEST13 || 'test-13' }} | ||
| - name: test12 | ||
| remotes: ${{ vars.REMOTES_TEST12 || 'https://rpc.test12.testnets.gno.land' }} | ||
| chainid: ${{ vars.CHAINID_TEST12 || 'test12' }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Run one-shot tests | ||
| if: > | ||
| github.event_name != 'workflow_dispatch' || | ||
| (inputs.test_type == 'one-shot' || inputs.test_type == 'both') && ( | ||
| (matrix.network.name == 'test-13' && inputs.run_test13 == true) || | ||
| (matrix.network.name == 'test12' && inputs.run_test12 == true) | ||
| ) | ||
| run: | | ||
| make tests-one-shot \ | ||
| REMOTES="${{ matrix.network.remotes }}" \ | ||
| CHAINID=${{ matrix.network.chainid }} | ||
|
|
||
| tests-repeatable: | ||
| name: Repeatable — ${{ matrix.network.name }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| network: | ||
| - name: test-13 | ||
| remotes: ${{ vars.REMOTES_TEST13 || 'https://rpc.test-13-aeddi-1.gnoland.network' }} | ||
| chainid: ${{ vars.CHAINID_TEST13 || 'test-13' }} | ||
| - name: test12 | ||
| remotes: ${{ vars.REMOTES_TEST12 || 'https://rpc.test12.testnets.gno.land' }} | ||
| chainid: ${{ vars.CHAINID_TEST12 || 'test12' }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Run repeatable tests | ||
| if: > | ||
| github.event_name != 'workflow_dispatch' || | ||
| (inputs.test_type == 'repeatable' || inputs.test_type == 'both') && ( | ||
| (matrix.network.name == 'test-13' && inputs.run_test13 == true) || | ||
| (matrix.network.name == 'test12' && inputs.run_test12 == true) | ||
| ) | ||
| run: | | ||
| make tests-repeatable \ | ||
| REMOTES="${{ matrix.network.remotes }}" \ | ||
| CHAINID=${{ matrix.network.chainid }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| .PHONY: tests-one-shot tests-repeatable help | ||
|
|
||
| comma := , | ||
| REMOTES ?= | ||
| REMOTE ?= $(if $(REMOTES),$(firstword $(subst $(comma), ,$(REMOTES))),https://rpc.test-13-aeddi-1.gnoland.network) | ||
| CHAINID ?= test-13 | ||
| FUNDER_SCRIPT ?= ./funders/gnoland.sh | ||
| FUNDER_MNEMONIC ?= source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove this please? |
||
| GNOKEY_IMAGE ?= ghcr.io/gnolang/gno/gnokey:master | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing for this gnokey image: if my funder script doesn’t need gnokey to work, it shouldn’t be in the root Makefile. Can you remove it please? |
||
|
|
||
| export FUNDER_MNEMONIC | ||
|
|
||
| # Contributor subdirectories are detected automatically. | ||
| CONTRIB_DIRS := $(filter-out _%, $(patsubst %/Makefile,%,$(wildcard */Makefile))) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move them to a tests subdir please, it will be cleaner and less error prone. |
||
| # Run the funder script inside a gnokey Docker container. | ||
| # No local gnokey installation required — compatible with GitHub Actions. | ||
| define run-funder | ||
| docker run --rm \ | ||
| -e REMOTE=$(REMOTE) \ | ||
| -e CHAINID=$(CHAINID) \ | ||
| -e FUNDER_MNEMONIC \ | ||
| -v "$(CURDIR)/funders:/funders:ro" \ | ||
| --entrypoint /bin/sh \ | ||
| $(GNOKEY_IMAGE) \ | ||
| /funders/$(notdir $(FUNDER_SCRIPT)) $(1) | ||
| endef | ||
|
Comment on lines
+16
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this entirely please. |
||
|
|
||
| ## tests-one-shot : fund accounts then run one-shot tests (REMOTES, CHAINID) | ||
| tests-one-shot: | ||
| @for dir in $(CONTRIB_DIRS); do \ | ||
| echo ""; \ | ||
| echo "==> $$dir — funding (one-shot)"; \ | ||
| ARGS=$$($(MAKE) -C $$dir list-funding-one-shot --no-print-directory \ | ||
| REMOTE=$(REMOTE) REMOTES=$(REMOTES) CHAINID=$(CHAINID)); \ | ||
| if [ -n "$$ARGS" ]; then \ | ||
| $(call run-funder,$$ARGS) || exit 1; \ | ||
| fi; \ | ||
| echo "==> $$dir — tests (one-shot)"; \ | ||
| $(MAKE) -C $$dir tests-one-shot --no-print-directory \ | ||
| REMOTE=$(REMOTE) REMOTES=$(REMOTES) CHAINID=$(CHAINID) || exit 1; \ | ||
| done | ||
|
|
||
| ## tests-repeatable : fund accounts then run repeatable tests (REMOTES, CHAINID) | ||
| tests-repeatable: | ||
| @for dir in $(CONTRIB_DIRS); do \ | ||
| echo ""; \ | ||
| echo "==> $$dir — funding (repeatable)"; \ | ||
| ARGS=$$($(MAKE) -C $$dir list-funding-repeatable --no-print-directory \ | ||
| REMOTE=$(REMOTE) CHAINID=$(CHAINID)); \ | ||
| if [ -n "$$ARGS" ]; then \ | ||
| $(call run-funder,$$ARGS) || exit 1; \ | ||
| fi; \ | ||
| echo "==> $$dir — tests (repeatable)"; \ | ||
| $(MAKE) -C $$dir tests-repeatable --no-print-directory \ | ||
| REMOTE=$(REMOTE) CHAINID=$(CHAINID) || exit 1; \ | ||
| done | ||
|
|
||
| ## help : show available targets | ||
| help: | ||
| @grep -E '^## ' Makefile | sed 's/## / /' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,141 @@ | ||
| # community-scripts | ||
| A collection of various community scripts and tests that will eventually become mainstream | ||
|
|
||
| A collection of community-contributed test suites for [gnoland](https://gno.land) chains. | ||
|
|
||
| ## Purpose | ||
|
|
||
| This repository lets contributors package their own tests and run them against any gnoland network via its RPC endpoint — no local node required. The goal is to provide a shared, extensible testing framework that can be wired into CI and executed against public testnets (e.g. `test-13`) or any custom deployment. | ||
|
|
||
| ## Structure | ||
|
|
||
| ```text | ||
| community-scripts/ | ||
| ├── Makefile # root orchestrator | ||
| ├── funders/ | ||
| │ └── gnoland.sh # funds test accounts from test1 (works on any gnoland network) | ||
| ├── _template/ | ||
| │ └── Makefile # copy-paste template for new contributors | ||
| └── <contributor>/ | ||
| ├── Makefile # exposes the 4 required rules (see below) | ||
| └── Dockerfile # self-contained test runner (any language) | ||
| ``` | ||
|
|
||
| ## Makefile interface | ||
|
|
||
| Every contributor subdirectory must expose these four rules: | ||
|
|
||
| | Rule | Description | | ||
| | ------------------------- | ------------------------------------------------------------------- | | ||
| | `list-funding-one-shot` | Prints `address amount` pairs to fund before one-shot tests | | ||
| | `list-funding-repeatable` | Prints `address amount` pairs to fund before repeatable tests | | ||
| | `tests-one-shot` | Runs tests that deploy on-chain state (realm deploys...) | | ||
| | `tests-repeatable` | Runs tests that can be re-executed safely | | ||
|
|
||
| All rules accept `REMOTES` (comma-separated RPC list) and `CHAINID` variables. | ||
| `REMOTE` is automatically derived from the first entry in `REMOTES`. | ||
|
|
||
| Before each run, the root Makefile calls `list-funding-*`, passes the returned | ||
| addresses to the funder script (test1), then runs the tests. | ||
|
|
||
| Run `make help` from any directory to list available targets. | ||
|
|
||
| ## Running tests | ||
|
|
||
| Against test-13 (default): | ||
|
|
||
| ```sh | ||
| make tests-one-shot | ||
| make tests-repeatable | ||
| ``` | ||
|
|
||
| Against a single custom RPC: | ||
|
|
||
| ```sh | ||
| make tests-one-shot REMOTES=https://rpc.test12.testnets.gno.land CHAINID=test12 | ||
| ``` | ||
|
|
||
| Against multiple validator nodes (stress tests will hit each one): | ||
|
|
||
| ```sh | ||
| make tests-one-shot \ | ||
| REMOTES=https://rpc1.gnoland.network,https://rpc2.gnoland.network,https://rpc3.gnoland.network \ | ||
| CHAINID=test-13 | ||
| ``` | ||
|
|
||
| With a custom funder script: | ||
|
|
||
| ```sh | ||
| make tests-one-shot FUNDER_SCRIPT=./funders/gnoland.sh REMOTES=... CHAINID=test-13 | ||
| ``` | ||
|
|
||
| Directly from a contributor subdirectory: | ||
|
|
||
| ```sh | ||
| cd samourai-crew | ||
| make help | ||
| make tests-one-shot REMOTES=https://rpc.test12.testnets.gno.land CHAINID=test12 | ||
| ``` | ||
|
|
||
| ## Adding your own tests | ||
|
|
||
| ### 1. Create your directory | ||
|
|
||
| ```sh | ||
| cp -r _template my-name | ||
| ``` | ||
|
|
||
| ### 2. Generate a testnet keypair | ||
|
|
||
| Generate a dedicated testnet account for your tests (no real value): | ||
|
|
||
| ```sh | ||
| gnokey generate # save the mnemonic | ||
| gnokey add my-test-account -recover | ||
| ``` | ||
|
|
||
| ### 3. Edit the Makefile | ||
|
|
||
| Declare your test account address and funding amounts: | ||
|
|
||
| ```makefile | ||
| ADDR_1 := g1your_address_here | ||
|
|
||
| FUND_AMOUNT_ONE_SHOT := 30000000ugnot # ~30 transactions at 1M ugnot each | ||
| FUND_AMOUNT_REPEATABLE := 10000000ugnot | ||
|
|
||
| list-funding-one-shot: | ||
| @echo "$(ADDR_1) $(FUND_AMOUNT_ONE_SHOT)" | ||
|
|
||
| list-funding-repeatable: | ||
| @echo "$(ADDR_1) $(FUND_AMOUNT_REPEATABLE)" | ||
| ``` | ||
|
|
||
| **Multiple wallets:** declare all addresses in `list-funding-*` as space-separated | ||
| `address amount` pairs. The funder will fund each one before the tests run. | ||
|
|
||
| ### 4. Write your Dockerfile | ||
|
|
||
| Your `Dockerfile` must: | ||
|
|
||
| - Accept `one-shot` or `repeatable` as a command argument | ||
| - Contain your test account mnemonic (testnet key, no real value) | ||
| - Read `REMOTE`, `REMOTES`, and `CHAINID` from env | ||
| - Sign the network CLA if required (see `samourai-crew/run_tests.sh` for an example) | ||
|
|
||
| The image can use **any language** (shell, Go, Python, etc.). See `samourai-crew/` for a shell-based example. | ||
|
|
||
| ### 5. What your container receives at runtime | ||
|
|
||
| | Variable | Description | | ||
| | --------- | --------------------------------------------------- | | ||
| | `REMOTE` | Primary RPC endpoint (first entry of `REMOTES`) | | ||
| | `REMOTES` | Comma-separated list of RPC endpoints | | ||
| | `CHAINID` | Chain ID | | ||
|
|
||
| The funding has already been done by the time your container starts. | ||
|
|
||
| ## Current contributors | ||
|
|
||
| | Directory | Description | | ||
| | --------------- | ------------------------------------------------------------------ | | ||
| | `samourai-crew` | GnoVM audit scripts, E2E transaction tests, and sybil stress tests | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| .PHONY: list-funding-one-shot list-funding-repeatable tests-one-shot tests-repeatable build help | ||
|
|
||
| # Override REMOTES and CHAINID to target a live network: | ||
| # make tests-one-shot REMOTES=https://rpc.test-13-aeddi-1.gnoland.network CHAINID=test-13 | ||
| comma := , | ||
| REMOTES ?= | ||
| REMOTE ?= $(if $(REMOTES),$(firstword $(subst $(comma), ,$(REMOTES))),http://127.0.0.1:26657) | ||
| CHAINID ?= test | ||
| IMAGE := $(shell basename $(CURDIR)) | ||
|
|
||
| # TODO: replace with your testnet account address(es) | ||
| ADDR_1 := TODO_REPLACE_ADDR_1 | ||
|
|
||
| # Funding amounts — adjust to match your tests' gas needs (~1M ugnot per tx) | ||
| FUND_AMOUNT_ONE_SHOT := 30000000ugnot | ||
| FUND_AMOUNT_REPEATABLE := 10000000ugnot | ||
|
|
||
| ## list-funding-one-shot : print address/amount pairs to fund before one-shot tests | ||
| list-funding-one-shot: | ||
| @echo "$(ADDR_1) $(FUND_AMOUNT_ONE_SHOT)" | ||
|
|
||
| ## list-funding-repeatable : print address/amount pairs to fund before repeatable tests | ||
| list-funding-repeatable: | ||
| @echo "$(ADDR_1) $(FUND_AMOUNT_REPEATABLE)" | ||
|
|
||
| ## build : build the Docker test image | ||
| build: | ||
| docker build -t $(IMAGE) . | ||
|
|
||
| ## tests-one-shot : run one-shot tests (REMOTES, CHAINID) | ||
| tests-one-shot: build | ||
| docker run --rm \ | ||
| -e REMOTE=$(REMOTE) \ | ||
| -e REMOTES=$(REMOTES) \ | ||
| -e CHAINID=$(CHAINID) \ | ||
| $(IMAGE) one-shot | ||
|
|
||
| ## tests-repeatable : run repeatable tests (REMOTES, CHAINID) | ||
| tests-repeatable: build | ||
| docker run --rm \ | ||
| -e REMOTE=$(REMOTE) \ | ||
| -e CHAINID=$(CHAINID) \ | ||
| $(IMAGE) repeatable | ||
|
|
||
| ## help : show available targets | ||
| help: | ||
| @grep -E '^## ' Makefile | sed 's/## / /' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make all this generic please by removing:
run_test13andrun_test12inputs (keep thetest_typechoice as is)pushandpull_requesttriggersAnd by adding:
chain_id,remote, andfunder_scriptworkflow_calltrigger with the same 4 inputs as theworkflow_dispatchoneThen create a
test-13.ymlwith the triggerspushon main,pull_requeston main, and aworkflow_dispatchwith only one inputtest_type. This test-13 workflow calls the generic workflow with the right test-13chain_id,remote, andfunder_script.This way, we can launch a
workflow_dispatchon test-13 with a single click or run a custom one if we want to. And we might later add a cron job intest-13.ymlthat won’t be the same as for the other chains.