fix: enforce optional manifest fields
This commit is contained in:
@@ -159,7 +159,9 @@ function assertExactSchema(manifest) {
|
||||
|
||||
function assertManifestUrls(manifest, spec) {
|
||||
if (manifest.network === "anvil") {
|
||||
if (manifest.rpcUrl !== spec.rpcUrl) throw new Error("manifest anvil rpcUrl must use the local public endpoint");
|
||||
if (Object.hasOwn(manifest, "rpcUrl") && manifest.rpcUrl !== spec.rpcUrl) {
|
||||
throw new Error("manifest anvil rpcUrl must use the local public endpoint");
|
||||
}
|
||||
if (Object.hasOwn(manifest, "explorerBaseUrl")) throw new Error("manifest anvil must omit explorerBaseUrl");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,19 @@ test("finalizer confirms a nested public actor manifest and preserves omitted Ba
|
||||
});
|
||||
});
|
||||
|
||||
test("finalizer accepts an Anvil manifest with omitted optional rpcUrl and preserves its absence", async () => {
|
||||
await withFixture(async (root) => {
|
||||
const pending = manifest({ deploymentBlock: 0 });
|
||||
delete pending.rpcUrl;
|
||||
await writeJson(join(root, "deployments", "pending.json"), pending);
|
||||
await writeBroadcast(root, pending);
|
||||
|
||||
const output = await finalizeDeployment({ root, rpc: fakeRpc() });
|
||||
assert.equal(Object.hasOwn(output.manifest, "rpcUrl"), false);
|
||||
assert.equal(Object.hasOwn(await readJson(output.path), "rpcUrl"), false);
|
||||
});
|
||||
});
|
||||
|
||||
test("validator rejects the legacy parallel actor and explorer schema", () => {
|
||||
assert.throws(
|
||||
() => validateManifest(legacyManifest()),
|
||||
|
||||
Reference in New Issue
Block a user