Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## vNEXT
- Clean some TODOs and harmonize unit tests. (#123)
- Add `set-callback-gas.ts` script. (#121)
- Accept any signature format in `SignatureVerifier.v8` when the account is a smart contract. (#120)
- Update UML class diagrams. (#112)
Expand Down
16 changes: 0 additions & 16 deletions contracts/libs/IexecLibCore_v5.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
// SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH <contact@iex.ec>
// SPDX-License-Identifier: Apache-2.0
// TODO: Remove header bellow
/******************************************************************************
* Copyright 2020 IEXEC BLOCKCHAIN TECH *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
******************************************************************************/

pragma solidity >=0.6.0;

Expand Down
51 changes: 26 additions & 25 deletions test/000_fullchain-boost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from '../typechain';
import constants from '../utils/constants';
import {
Orders,
OrdersActors,
OrdersAssets,
OrdersPrices,
Expand Down Expand Up @@ -131,14 +130,20 @@ describe('IexecPocoBoostDelegate (IT)', function () {
describe('MatchOrders', function () {
it('Should match orders (TEE)', async function () {
const callbackAddress = ethers.Wallet.createRandom().address;
const { orders, appOrder, datasetOrder, workerpoolOrder, requestOrder } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
beneficiary: beneficiary.address,
tag: teeDealTag,
prices: ordersPrices,
callback: callbackAddress,
});
const {
appOrder,
datasetOrder,
workerpoolOrder,
requesterOrder: requestOrder,
} = orders.toObject();
const dealPrice =
(appPrice + datasetPrice + workerpoolPrice) * // task price
1; // volume
Expand All @@ -157,17 +162,11 @@ describe('IexecPocoBoostDelegate (IT)', function () {
await signOrders(domain, orders, ordersActors);
const dealId = getDealId(domain, requestOrder, taskIndex);
const startTime = await setNextBlockTimestamp();
const matchOrdersArgs = [
appOrder,
datasetOrder,
workerpoolOrder,
requestOrder,
] as Orders;

expect(
await iexecPocoBoostInstance.callStatic.matchOrdersBoost(...matchOrdersArgs),
await iexecPocoBoostInstance.callStatic.matchOrdersBoost(...orders.toArray()),
).to.equal(dealId);
await expect(iexecPocoBoostInstance.matchOrdersBoost(...matchOrdersArgs))
await expect(iexecPocoBoostInstance.matchOrdersBoost(...orders.toArray()))
.to.emit(iexecPocoBoostInstance, 'SchedulerNoticeBoost')
.withArgs(
workerpoolAddress,
Expand Down Expand Up @@ -237,7 +236,7 @@ describe('IexecPocoBoostDelegate (IT)', function () {
requester: requester.address,
beneficiary: beneficiary.address,
tag: teeDealTag,
});
}).toObject();
await iexecOrderManagementInstance.connect(appProvider).manageAppOrder({
order: appOrder,
operation: 0,
Expand Down Expand Up @@ -292,14 +291,15 @@ describe('IexecPocoBoostDelegate (IT)', function () {

it('Should sponsor match orders (TEE)', async function () {
const callbackAddress = ethers.Wallet.createRandom().address;
const { orders, appOrder, datasetOrder, workerpoolOrder, requestOrder } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
beneficiary: beneficiary.address,
tag: teeDealTag,
prices: ordersPrices,
callback: callbackAddress,
});
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
const dealPrice =
(appPrice + datasetPrice + workerpoolPrice) * // task price
1; // volume
Expand All @@ -320,20 +320,16 @@ describe('IexecPocoBoostDelegate (IT)', function () {
await signOrders(domain, orders, ordersActors);
const dealId = getDealId(domain, requestOrder, taskIndex);
const startTime = await setNextBlockTimestamp();
const matchOrdersArgs = [
appOrder,
datasetOrder,
workerpoolOrder,
requestOrder,
] as Orders;

expect(
await iexecPocoBoostInstance
.connect(sponsor)
.callStatic.sponsorMatchOrdersBoost(...matchOrdersArgs),
.callStatic.sponsorMatchOrdersBoost(...orders.toArray()),
).to.equal(dealId);
await expect(
iexecPocoBoostInstance.connect(sponsor).sponsorMatchOrdersBoost(...matchOrdersArgs),
iexecPocoBoostInstance
.connect(sponsor)
.sponsorMatchOrdersBoost(...orders.toArray()),
)
.to.emit(iexecPocoBoostInstance, 'SchedulerNoticeBoost')
.withArgs(
Expand Down Expand Up @@ -402,11 +398,12 @@ describe('IexecPocoBoostDelegate (IT)', function () {

describe('PushResult', function () {
it('Should push result (TEE & callback)', async function () {
const { orders, appOrder, datasetOrder, workerpoolOrder, requestOrder } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
});
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
const oracleConsumerInstance = await new TestClient__factory()
.connect(anyone)
.deploy()
Expand Down Expand Up @@ -458,13 +455,14 @@ describe('IexecPocoBoostDelegate (IT)', function () {

it('Should push result (TEE with contribution authorization signed by scheduler)', async function () {
const volume = 3;
const { orders, appOrder, datasetOrder, workerpoolOrder, requestOrder } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
prices: ordersPrices,
volume: volume,
});
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
const taskPrice = appPrice + datasetPrice + workerpoolPrice;
const dealPrice = taskPrice * volume;
await iexecWrapper.depositInIexecAccount(requester, dealPrice);
Expand Down Expand Up @@ -569,10 +567,11 @@ describe('IexecPocoBoostDelegate (IT)', function () {

it('Should push result (TEE with contribution authorization signed by broker)', async function () {
await iexecWrapper.setTeeBroker(teeBroker.address);
const { orders, appOrder, datasetOrder, workerpoolOrder, requestOrder } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
});
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
await signOrders(domain, orders, ordersActors);
const dealId = getDealId(domain, requestOrder, taskIndex);
const taskId = getTaskId(dealId, taskIndex);
Expand Down Expand Up @@ -616,13 +615,14 @@ describe('IexecPocoBoostDelegate (IT)', function () {
const claimedTasks = 1;
const taskPrice = appPrice + datasetPrice + workerpoolPrice;
const dealPrice = taskPrice * expectedVolume;
const { orders, appOrder, datasetOrder, workerpoolOrder, requestOrder } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
prices: ordersPrices,
volume: expectedVolume,
});
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
await signOrders(domain, orders, ordersActors);
const dealId = getDealId(domain, requestOrder, taskIndex);
const taskId = getTaskId(dealId, taskIndex);
Expand Down Expand Up @@ -697,13 +697,14 @@ describe('IexecPocoBoostDelegate (IT)', function () {
const claimedTasks = 1;
const taskPrice = appPrice + datasetPrice + workerpoolPrice;
const dealPrice = taskPrice * expectedVolume;
const { orders, appOrder, datasetOrder, workerpoolOrder, requestOrder } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
tag: teeDealTag,
prices: ordersPrices,
volume: expectedVolume,
});
const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject();
await signOrders(domain, orders, ordersActors);
const dealId = getDealId(domain, requestOrder, taskIndex);
const taskId = getTaskId(dealId, taskIndex);
Expand Down
2 changes: 1 addition & 1 deletion test/000_fullchain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('IexecPoco (IT)', function () {
describe('MatchOrders', function () {
it('Should sponsor match orders (TEE)', async function () {
const callbackAddress = ethers.Wallet.createRandom().address;
const { orders } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
beneficiary: beneficiary.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('OrderManagement', async () => {
requester: requester.address,
prices: ordersPrices,
volume,
}));
}).toObject());
appOrderHash = iexecWrapper.hashOrder(appOrder);
datasetOrderHash = iexecWrapper.hashOrder(datasetOrder);
workerpoolOrderHash = iexecWrapper.hashOrder(workerpoolOrder);
Expand Down
53 changes: 28 additions & 25 deletions test/byContract/IexecPoco/01_initialize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const appPrice = 1000;
const datasetPrice = 1_000_000;
const workerpoolPrice = 1_000_000_000;

describe('Poco', async () => {
describe('IexecPoco2#initialize', async () => {
let proxyAddress: string;
let iexecPoco: IexecInterfaceNative;
let iexecPocoAsAnyone: IexecInterfaceNative;
Expand Down Expand Up @@ -60,13 +60,14 @@ describe('Poco', async () => {

describe('Initialize', function () {
it('Should initialize', async function () {
const { orders } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
prices: ordersPrices,
});
const { dealId, taskId, taskIndex, startTime } =
await iexecWrapper.signAndMatchOrders(orders);
const { dealId, taskId, taskIndex, startTime } = await iexecWrapper.signAndMatchOrders(
...orders.toArray(),
);
expect((await iexecPoco.viewTask(taskId)).status).equal(TaskStatusEnum.UNSET);

expect(await iexecPocoAsAnyone.callStatic.initialize(dealId, taskIndex)).to.equal(
Expand All @@ -93,7 +94,7 @@ describe('Poco', async () => {
requester: requester.address,
prices: ordersPrices,
volume: 10,
});
}).toObject();
const workerpoolOrder0 = {
...createEmptyWorkerpoolOrder(),
workerpool: workerpoolAddress,
Expand All @@ -107,18 +108,18 @@ describe('Poco', async () => {
volume: 9,
};
// Request order is matched in 2 deals
const { dealId: dealId0 } = await iexecWrapper.signAndMatchOrders({
app: appOrder,
dataset: datasetOrder,
workerpool: workerpoolOrder0,
requester: requestOrder,
});
const { dealId: dealId1 } = await iexecWrapper.signAndMatchOrders({
app: appOrder,
dataset: datasetOrder,
workerpool: workerpoolOrder1,
requester: requestOrder,
});
const { dealId: dealId0 } = await iexecWrapper.signAndMatchOrders(
appOrder,
datasetOrder,
workerpoolOrder0,
requestOrder,
);
const { dealId: dealId1 } = await iexecWrapper.signAndMatchOrders(
appOrder,
datasetOrder,
workerpoolOrder1,
requestOrder,
);
expect((await iexecPoco.viewDeal(dealId0)).botFirst).equal(0);
expect((await iexecPoco.viewDeal(dealId1)).botFirst).equal(1);

Expand All @@ -127,12 +128,12 @@ describe('Poco', async () => {
});

it('Should not initialize since index is too high', async function () {
const { orders } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
prices: ordersPrices,
});
const { dealId } = await iexecWrapper.signAndMatchOrders(orders);
const { dealId } = await iexecWrapper.signAndMatchOrders(...orders.toArray());
const deal = await iexecPoco.viewDeal(dealId);
expect(deal.botFirst).equal(0);
expect(deal.botSize).equal(1);
Expand All @@ -142,12 +143,14 @@ describe('Poco', async () => {
});

it('Should not initialize twice', async function () {
const { orders } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
prices: ordersPrices,
});
const { dealId, taskId, taskIndex } = await iexecWrapper.signAndMatchOrders(orders);
const { dealId, taskId, taskIndex } = await iexecWrapper.signAndMatchOrders(
...orders.toArray(),
);
await iexecPocoAsAnyone.initialize(dealId, taskIndex).then((tx) => tx.wait());
expect((await iexecPoco.viewTask(taskId)).status).equal(TaskStatusEnum.ACTIVE);

Expand All @@ -160,13 +163,13 @@ describe('Poco', async () => {
describe('Initialize array', function () {
it('Should initialize array', async function () {
const volume = 3;
const { orders } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
prices: ordersPrices,
volume,
});
const { dealId } = await iexecWrapper.signAndMatchOrders(orders);
const { dealId } = await iexecWrapper.signAndMatchOrders(...orders.toArray());
const dealIds = [dealId, dealId, dealId];
const taskIndexes = [0, 1, 2];
for (const taskIndex of taskIndexes) {
Expand Down Expand Up @@ -196,13 +199,13 @@ describe('Poco', async () => {

it('Should not initialize array if one specific fails', async function () {
const volume = 2;
const { orders } = buildOrders({
const orders = buildOrders({
assets: ordersAssets,
requester: requester.address,
prices: ordersPrices,
volume,
});
const { dealId } = await iexecWrapper.signAndMatchOrders(orders);
const { dealId } = await iexecWrapper.signAndMatchOrders(...orders.toArray());
const taskIndex0 = 0;
const taskIndex1 = 1;
await iexecPocoAsAnyone // Make first task already initialized
Expand Down
Loading