Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,55 @@ jobs:
# true
# fi

dev-test:
vitest-test:
runs-on:
labels: bare-metal
permissions:
contents: read
needs: ["set-tags", "build"]
timeout-minutes: 20
env:
DEBUG_COLORS: 1
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ needs.set-tags.outputs.git_ref }}
- name: Create local folders
run: |
mkdir -p target/release/wbuild/${{ matrix.chain }}-runtime/
- name: "Download branch built runtime"
uses: actions/download-artifact@v5
with:
name: runtimes
path: target/release/wbuild/${{ matrix.chain }}-runtime/
- name: "Download branch built node"
uses: actions/download-artifact@v5
with:
name: moonbeam
path: target/release
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version-file: "test/.nvmrc"
cache: "pnpm"
cache-dependency-path: pnpm-lock.yaml

- name: "Install and run dev test"
shell: bash
env:
DEBUG_COLOURS: "1"
NODE_OPTIONS: "--max-old-space-size=12288"
run: |
chmod uog+x target/release/moonbeam
cd test
pnpm install
pnpm compile-solidity
pnpm vitest

moonwall-test:
runs-on:
labels: bare-metal
permissions:
Expand Down
117 changes: 117 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"lint": "biome lint .",
"compile-solidity": "tsx scripts/compile-contracts.ts compile",
"typecheck": "pnpm tsc --noEmit",
"print-failed-tests": "tsx scripts/print-failed-tests.ts"
"print-failed-tests": "tsx scripts/print-failed-tests.ts",
"vitest": "vitest run --dir suites/simple"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@acala-network/chopsticks": "1.2.2",
"@acala-network/chopsticks-testing": "1.2.2",
"@biomejs/biome": "^2.2.5",
"@moonbeam-network/api-augment": "workspace:*",
"@moonbeam-network/types-bundle": "workspace:*",
Expand Down
86 changes: 86 additions & 0 deletions test/suites/simple/test-chopsticks-fake-signature.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { afterAll, describe, expect, it } from "vitest";
import {
setupContext,
signFake,
signFakeWithApi,
testingPairs,
} from "@acala-network/chopsticks-testing";

describe(
"Chopsticks Fake Signature",
async () => {
const { api, dev, teardown } = await setupContext({
endpoint: ["wss://wss.api.moonbase.moonbeam.network"],
timeout: 400_000,
});

afterAll(async () => await teardown());

it("accept valid signature", async () => {
const { alith, baltathar } = testingPairs();
await dev.setStorage({
System: {
Account: [[[alith.address], { providers: 1, data: { free: 1000 * 1e12 } }]],
},
});

const tx = api.tx.balances.transferAllowDeath(baltathar.address, 100);

await tx.signAsync(alith);

await expect(tx.send()).resolves.toBeTruthy();
});

it("reject invalid signature", async () => {
const { alith, baltathar } = testingPairs();
const { nonce } = await api.query.system.account(alith.address);
const tx = api.tx.balances.transferAllowDeath(baltathar.address, 100);

tx.signFake(alith.address, {
nonce,
genesisHash: api.genesisHash,
runtimeVersion: api.runtimeVersion,
blockHash: api.genesisHash,
});

await expect(tx.send()).rejects.toThrow('1010: {"invalid":{"badProof":null}}');
});

it("accept mock signature (with api)", async () => {
const { alith, baltathar } = testingPairs();
await dev.setStorage({
System: {
Account: [[[alith.address], { providers: 1, data: { free: 1000 * 1e12 } }]],
},
});

const tx = api.tx.balances.transferAllowDeath(baltathar.address, 100);

await signFakeWithApi(api, tx, alith.address);

await expect(tx.send()).resolves.toBeTruthy();
});

it("accept mock signature (manually input options)", async () => {
const { alith, baltathar } = testingPairs();
await dev.setStorage({
System: {
Account: [[[alith.address], { providers: 1, data: { free: 1000 * 1e12 } }]],
},
});

const { nonce } = await api.query.system.account(alith.address);
const tx = api.tx.balances.transferAllowDeath(baltathar.address, 100);

signFake(tx, alith.address, {
nonce,
genesisHash: api.genesisHash,
runtimeVersion: api.runtimeVersion,
blockHash: api.genesisHash,
});

await expect(tx.send()).resolves.toBeTruthy();
});
},
{ timeout: 120_000 }
);