Aere Network public source. Everything here can be checked against the live chain (chain id 2800, https://rpc.aere.network). Scope note, stated up front rather than buried: consensus on chain 2800 is classical secp256k1 ECDSA QBFT. The post-quantum work in this repository is at the signature, precompile, account and transport layers. Nothing here makes the consensus post-quantum, and no document in it should be read as claiming so.
59 lines
2.2 KiB
JavaScript
59 lines
2.2 KiB
JavaScript
const { expect } = require("chai");
|
|
const { ethers } = require("hardhat");
|
|
|
|
describe("AereValidatorManifest", () => {
|
|
let val1, val2, ds;
|
|
const DIGEST_A = ethers.keccak256(ethers.toUtf8Bytes("aere-besu-reproducible-A"));
|
|
const DIGEST_B = ethers.keccak256(ethers.toUtf8Bytes("aere-besu-reproducible-B"));
|
|
|
|
beforeEach(async () => {
|
|
[val1, val2] = await ethers.getSigners();
|
|
const F = await ethers.getContractFactory("AereValidatorManifest");
|
|
ds = await F.deploy();
|
|
await ds.waitForDeployment();
|
|
});
|
|
|
|
it("a validator declares + we read back", async () => {
|
|
await expect(
|
|
ds.connect(val1).declare(
|
|
DIGEST_A,
|
|
"https://aere.network/.well-known/besu-image-digest",
|
|
"AERE Foundation",
|
|
"EU-Central / DE / Hetzner FSN-1"
|
|
)
|
|
).to.emit(ds, "CommitmentDeclared");
|
|
const c = await ds.commitmentOf(val1.address);
|
|
expect(c.binaryDigest).to.equal(DIGEST_A);
|
|
expect(c.operatorLabel).to.equal("AERE Foundation");
|
|
expect(c.serial).to.equal(1n);
|
|
expect(await ds.isDeclared(val1.address)).to.equal(true);
|
|
});
|
|
|
|
it("rejects malformed declarations", async () => {
|
|
await expect(
|
|
ds.connect(val1).declare(ethers.ZeroHash, "u", "l", "r")
|
|
).to.be.revertedWithCustomError(ds, "ZeroDigest");
|
|
await expect(
|
|
ds.connect(val1).declare(DIGEST_A, "", "l", "r")
|
|
).to.be.revertedWithCustomError(ds, "EmptyManifestUri");
|
|
await expect(
|
|
ds.connect(val1).declare(DIGEST_A, "u", "", "r")
|
|
).to.be.revertedWithCustomError(ds, "EmptyOperatorLabel");
|
|
});
|
|
|
|
it("overwriting bumps serial; serials are per-validator", async () => {
|
|
await ds.connect(val1).declare(DIGEST_A, "u", "l", "r");
|
|
await ds.connect(val1).declare(DIGEST_B, "u", "l", "r");
|
|
expect((await ds.commitmentOf(val1.address)).serial).to.equal(2n);
|
|
expect((await ds.commitmentOf(val1.address)).binaryDigest).to.equal(DIGEST_B);
|
|
|
|
await ds.connect(val2).declare(DIGEST_A, "u", "l", "r");
|
|
expect((await ds.commitmentOf(val2.address)).serial).to.equal(1n);
|
|
});
|
|
|
|
it("validators write only their own slot", async () => {
|
|
await ds.connect(val1).declare(DIGEST_A, "u", "l", "r");
|
|
expect(await ds.isDeclared(val2.address)).to.equal(false);
|
|
});
|
|
});
|