Skip to content

Commit 07e1e2d

Browse files
committed
feat(test-suite): add public decrypt several requests in same tx test
1 parent 8517b4c commit 07e1e2d

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

test-suite/e2e/contracts/TestAsyncDecrypt.sol

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ contract TestAsyncDecrypt is E2EFHEVMConfig {
1818
euint64 xUint64_2;
1919
euint64 xUint64_3;
2020
euint128 xUint128;
21+
euint128 xUint128_2;
22+
euint128 xUint128_3;
2123
eaddress xAddress;
2224
eaddress xAddress2;
2325
euint256 xUint256;
@@ -33,6 +35,8 @@ contract TestAsyncDecrypt is E2EFHEVMConfig {
3335
uint64 public yUint64_2;
3436
uint64 public yUint64_3;
3537
uint128 public yUint128;
38+
uint128 public yUint128_2;
39+
uint128 public yUint128_3;
3640
address public yAddress;
3741
address public yAddress2;
3842
uint256 public yUint256;
@@ -66,6 +70,10 @@ contract TestAsyncDecrypt is E2EFHEVMConfig {
6670
FHE.allowThis(xUint64_3);
6771
xUint128 = FHE.asEuint128(1267650600228229401496703205443);
6872
FHE.allowThis(xUint128);
73+
xUint128_2 = FHE.asEuint128(10000);
74+
FHE.allowThis(xUint128_2);
75+
xUint128_3 = FHE.asEuint128(20000);
76+
FHE.allowThis(xUint128_3);
6977
xUint256 = FHE.asEuint256(27606985387162255149739023449108101809804435888681546220650096895197251);
7078
FHE.allowThis(xUint256);
7179
xAddress = FHE.asEaddress(0x8ba1f109551bD432803012645Ac136ddd64DBA72);
@@ -300,6 +308,33 @@ contract TestAsyncDecrypt is E2EFHEVMConfig {
300308
return decryptedInput;
301309
}
302310

311+
function requestUint128_Many() public {
312+
bytes32[] memory cts = new bytes32[](1);
313+
cts[0] = FHE.toBytes32(xUint128_2);
314+
FHE.requestDecryption(cts, this.callbackUint128_2.selector);
315+
bytes32[] memory cts_2 = new bytes32[](1);
316+
cts_2[0] = FHE.toBytes32(xUint128_3);
317+
FHE.requestDecryption(cts_2, this.callbackUint128_3.selector);
318+
}
319+
320+
function callbackUint128_2(
321+
uint256 requestID,
322+
uint128 decryptedInput,
323+
bytes[] memory signatures
324+
) public {
325+
FHE.checkSignatures(requestID, signatures);
326+
yUint128_2 = decryptedInput;
327+
}
328+
329+
function callbackUint128_3(
330+
uint256 requestID,
331+
uint128 decryptedInput,
332+
bytes[] memory signatures
333+
) public {
334+
FHE.checkSignatures(requestID, signatures);
335+
yUint128_3 = decryptedInput;
336+
}
337+
303338
function requestUint256() public {
304339
bytes32[] memory cts = new bytes32[](1);
305340
cts[0] = FHE.toBytes32(xUint256);

test-suite/e2e/test/gatewayDecrypt/testAsyncDecrypt.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ describe('TestAsyncDecrypt', function () {
192192
expect(y).to.equal(1267650600228229401496703205443n);
193193
});
194194

195+
it('test async decrypt uint128 - two requests in same tx', async function () {
196+
const tx2 = await this.contract.connect(this.signers.carol).requestUint128_Many();
197+
await tx2.wait();
198+
await awaitAllDecryptionResults();
199+
const y2 = await this.contract.yUint128_2();
200+
expect(y2).to.equal(10000n);
201+
const y3 = await this.contract.yUint128_3();
202+
expect(y3).to.equal(20000n);
203+
});
204+
195205
it('test async decrypt uint128 non-trivial', async function () {
196206
const inputAlice = this.instances.alice.createEncryptedInput(this.contractAddress, this.signers.alice.address);
197207
inputAlice.add128(184467440737095500429401496n);

0 commit comments

Comments
 (0)