This commit is contained in:
2026-02-26 16:17:30 +01:00
commit 96e58bbf62
19 changed files with 5835 additions and 0 deletions

44
test/Counter.ts Normal file
View File

@@ -0,0 +1,44 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { network } from "hardhat";
const { viem } = await network.connect();
const publicClient = await viem.getPublicClient();
describe("Counter", async function () {
it("The value should match the sum of the increments", async function () {
const counter = await viem.deployContract("Counter");
await counter.write.inc();
// run a series of increments
// 3+...+10 = 52
for (let i = 3n; i <= 10n; i++) {
await counter.write.incBy([i]);
}
// read the value
const value = await counter.read.x();
assert.equal(value, 1n + 52n);
});
it("Demo reading from a public client with Viem", async function () {
const counter = await viem.deployContract("Counter");
await counter.write.inc();
await counter.write.inc();
await counter.write.inc();
// read the value
const value = await publicClient.readContract({
address: counter.address,
abi: counter.abi,
functionName: "x",
});
assert.equal(value, 3n);
});
});

20
test/Gradebook.ts Normal file
View File

@@ -0,0 +1,20 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { network } from "hardhat";
const { viem } = await network.connect();
const publicClient = await viem.getPublicClient();
describe("Gradebook", async function () {
it("Only the teacher can add students and points", async function () {
});
it("Everyone can read the grade for a student by their address", async function () {
});
it("An event is fired when the teacher submits points for a student", async function () {
});
});

5
test/accounts/index.ts Normal file
View File

@@ -0,0 +1,5 @@
export const account1 = '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
export const account2 = '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
export const account3 = '0xcccccccccccccccccccccccccccccccccccccccc';
export const account4 = '0xdddddddddddddddddddddddddddddddddddddddd';
export const account5 = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';