Skip to content

Commit a211292

Browse files
committed
test: Test all combinations of TEE tags in dataset and workerpool orders
1 parent 5645e3d commit a211292

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

test/byContract/IexecPoco/IexecPoco1.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ import {
1717
OwnableMock__factory,
1818
} from '../../../typechain';
1919
import {
20+
ALL_TEE_TAGS,
2021
TAG_ALL_TEE_FRAMEWORKS,
2122
TAG_BIT_2,
2223
TAG_BIT_4,
2324
TAG_BIT_4_AND_TEE,
25+
TAG_NAMES,
2426
TAG_STANDARD,
2527
TAG_TEE,
2628
TAG_TEE_GRAMINE,
@@ -637,6 +639,29 @@ describe('IexecPoco1', () => {
637639
);
638640
});
639641

642+
/**
643+
* Successful match orders with all combinations of TEE tags in dataset and workerpool orders.
644+
* Validates ignored dataset tag bits.
645+
*/
646+
ALL_TEE_TAGS.forEach((datasetTag) => {
647+
ALL_TEE_TAGS.forEach((workerpoolTag) => {
648+
it(`Should match orders with compatible TEE tags [dataset:${TAG_NAMES[datasetTag]}, workerpool:${TAG_NAMES[workerpoolTag]}]`, async () => {
649+
orders.dataset.tag = datasetTag;
650+
orders.workerpool.tag = workerpoolTag;
651+
orders.app.tag = TAG_TEE;
652+
orders.requester.tag = TAG_TEE;
653+
654+
await depositForRequesterAndSchedulerWithDefaultPrices(volume);
655+
await signOrders(iexecWrapper.getDomain(), orders, ordersActors);
656+
657+
await expect(iexecPocoAsRequester.matchOrders(...orders.toArray())).to.emit(
658+
iexecPoco,
659+
'OrdersMatched',
660+
);
661+
});
662+
});
663+
});
664+
640665
[
641666
{
642667
datasetTag: TAG_TEE_SCONE,

utils/constants.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected]>
22
// SPDX-License-Identifier: Apache-2.0
33

4-
/**
5-
* Tag constants:
6-
* - Bit 0: TEE
7-
* - Bit 1: Scone
8-
* - Bit 2: Gramine
9-
* - Bit 3: TDX
10-
* - Bit 4: GPU (0x10)
11-
*/
4+
// Tag constants.
5+
// For TEE bits positions, see IexecPoco1Facet.sol#_ignoreTeeFramework
126
export const TAG_STANDARD = '0x0000000000000000000000000000000000000000000000000000000000000000';
137
export const TAG_TEE = '0x0000000000000000000000000000000000000000000000000000000000000001';
148
export const TAG_TEE_SCONE = '0x0000000000000000000000000000000000000000000000000000000000000003'; // 0b0011 = TEE + Scone
@@ -20,6 +14,22 @@ export const TAG_BIT_2 = '0x0000000000000000000000000000000000000000000000000000
2014
export const TAG_BIT_4 = '0x0000000000000000000000000000000000000000000000000000000000000010'; // 0b10000 (bit 4 in 0-indexed)
2115
export const TAG_BIT_4_AND_TEE =
2216
'0x0000000000000000000000000000000000000000000000000000000000000011'; // 0b10001
17+
// Tag helpers:
18+
export const ALL_TEE_TAGS = [
19+
TAG_TEE,
20+
TAG_TEE_SCONE,
21+
TAG_TEE_GRAMINE,
22+
TAG_TEE_TDX,
23+
TAG_ALL_TEE_FRAMEWORKS,
24+
];
25+
export const TAG_NAMES: { [key: string]: string } = {
26+
[TAG_STANDARD]: 'STANDARD',
27+
[TAG_TEE]: 'TEE',
28+
[TAG_TEE_SCONE]: 'TEE_SCONE',
29+
[TAG_TEE_GRAMINE]: 'TEE_GRAMINE',
30+
[TAG_TEE_TDX]: 'TEE_TDX',
31+
[TAG_ALL_TEE_FRAMEWORKS]: 'TEE_ALL',
32+
};
2333

2434
export const NULL = {
2535
BYTES32: '0x0000000000000000000000000000000000000000000000000000000000000000',

0 commit comments

Comments
 (0)