Skip to content

Commit 4230f9f

Browse files
committed
feat(test-suite): e2e asserts KMSGeneration canonical-only topology
Adds two tests to the multi-chain isolation suite that verify on-chain state across all host RPCs: - KMSGeneration must have code only on the canonical host, not extras. - ProtocolConfig must have code on every host chain. Plumbs PROTOCOL_CONFIG_CONTRACT_ADDRESS and KMS_GENERATION_CONTRACT_ADDRESS through the fhevm-cli test-suite env so the e2e process can read them. Part of zama-ai/fhevm-internal#1268
1 parent 1111545 commit 4230f9f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test-suite/e2e/test/multiChain/multiChainIsolation.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ describe('Multi-Chain State Isolation', function () {
4848
}
4949
});
5050

51+
describe('Canonical Host Contracts Topology', function () {
52+
it('KMSGeneration is deployed only on the canonical host', async function () {
53+
const kmsGenAddress = process.env.KMS_GENERATION_CONTRACT_ADDRESS;
54+
expect(kmsGenAddress, 'KMS_GENERATION_CONTRACT_ADDRESS must be set in the e2e env').to.match(
55+
/^0x[0-9a-fA-F]{40}$/,
56+
);
57+
58+
const canonicalCode = await getProvider(this.chains[0]).getCode(kmsGenAddress!);
59+
expect(canonicalCode, 'KMSGeneration should be deployed on the canonical host').to.not.eq('0x');
60+
61+
for (let i = 1; i < this.chains.length; i++) {
62+
const extraCode = await getProvider(this.chains[i]).getCode(kmsGenAddress!);
63+
expect(
64+
extraCode,
65+
`KMSGeneration should not be deployed on non-canonical chain ${this.chains[i].rpcUrl}`,
66+
).to.eq('0x');
67+
}
68+
});
69+
70+
it('ProtocolConfig is deployed on every host chain', async function () {
71+
const protocolConfigAddress = process.env.PROTOCOL_CONFIG_CONTRACT_ADDRESS;
72+
expect(protocolConfigAddress, 'PROTOCOL_CONFIG_CONTRACT_ADDRESS must be set in the e2e env').to.match(
73+
/^0x[0-9a-fA-F]{40}$/,
74+
);
75+
76+
for (const chain of this.chains) {
77+
const code = await getProvider(chain).getCode(protocolConfigAddress!);
78+
expect(code, `ProtocolConfig should be deployed on ${chain.rpcUrl}`).to.not.eq('0x');
79+
}
80+
});
81+
});
82+
5183
describe('User Input Across Chains', function () {
5284
it('encrypted input and FHE computation work independently on both chains', async function () {
5385
const erc20A = this.chainA.erc20 as unknown as EncryptedERC20;

test-suite/fhevm/src/generate/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ const applyDiscoveryEnv = (
171171
ACL_CONTRACT_ADDRESS: primaryHost.ACL_CONTRACT_ADDRESS,
172172
INPUT_VERIFIER_CONTRACT_ADDRESS: primaryHost.INPUT_VERIFIER_CONTRACT_ADDRESS,
173173
FHEVM_EXECUTOR_CONTRACT_ADDRESS: primaryHost.FHEVM_EXECUTOR_CONTRACT_ADDRESS,
174+
PROTOCOL_CONFIG_CONTRACT_ADDRESS: primaryHost.PROTOCOL_CONFIG_CONTRACT_ADDRESS,
175+
KMS_GENERATION_CONTRACT_ADDRESS: primaryHost.KMS_GENERATION_CONTRACT_ADDRESS,
174176
});
175177
};
176178

0 commit comments

Comments
 (0)