Skip to content

Commit 884d217

Browse files
committed
test(contracts): reset orchestrator-library state leaked by registry unit suite
The atsRegistry.generated unit suite seeds zero-address orchestrator library placeholders into a shared module singleton to construct facet factories in isolation, but never cleared them. Running the scripts suite on its own then leaked those zeros into later token deployments, linking scheduledTasksOps to address(0) and reverting initializeERC20. Add resetOrchestratorLibraryAddresses() and clear only the seeded state in an after hook. Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
1 parent 98ce4d2 commit 884d217

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

packages/ats/contracts/scripts/domain/orchestratorLibraries.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ export function hasOrchestratorLibraryAddresses(): boolean {
9494
return _addresses !== undefined;
9595
}
9696

97+
/**
98+
* Reset orchestrator library addresses to the unset state.
99+
*
100+
* Intended for test isolation: a suite that seeds placeholder addresses (e.g. to
101+
* construct facet factories without a real deployment) must reset afterwards, so a
102+
* later deployment re-links the actually-deployed libraries instead of inheriting
103+
* the placeholders through this module-level singleton.
104+
*/
105+
export function resetOrchestratorLibraryAddresses(): void {
106+
_addresses = undefined;
107+
}
108+
97109
/**
98110
* Determine which orchestrator libraries a facet requires for TypeChain linking.
99111
*

packages/ats/contracts/test/scripts/unit/domain/atsRegistry.generated.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
isLibraryDependentFacet,
3232
hasOrchestratorLibraryAddresses,
3333
setOrchestratorLibraryAddresses,
34+
resetOrchestratorLibraryAddresses,
3435
} from "@scripts/domain";
3536

3637
describe("atsRegistry.generated - Factory Functions", () => {
@@ -39,6 +40,10 @@ describe("atsRegistry.generated - Factory Functions", () => {
3940
// Cache signer to avoid repeated Hardhat network bootstrap (saves ~4+ seconds)
4041
let signer: Awaited<ReturnType<typeof ethers.getSigners>>[0];
4142

43+
// Tracks whether THIS suite seeded the placeholder library addresses, so the
44+
// after-hook only clears state it actually introduced.
45+
let didSeedLibAddresses = false;
46+
4247
before(async () => {
4348
[signer] = await ethers.getSigners();
4449
// Self-sufficient unit-suite bootstrap: when this file runs in isolation
@@ -60,6 +65,18 @@ describe("atsRegistry.generated - Factory Functions", () => {
6065
scheduledTasksOps: zero,
6166
scheduledTasksDispatchOps: zero,
6267
});
68+
didSeedLibAddresses = true;
69+
}
70+
});
71+
72+
// Reset the module singleton if we seeded it, so a later integration deployment
73+
// in the same process re-links the real orchestrator libraries rather than
74+
// inheriting these zero placeholders (which would make token init delegatecall a
75+
// no-code address and revert). Without this, running the scripts suite on its own
76+
// poisons upgradeConfigurations' proxy-update deployments.
77+
after(() => {
78+
if (didSeedLibAddresses) {
79+
resetOrchestratorLibraryAddresses();
6380
}
6481
});
6582

0 commit comments

Comments
 (0)