diff --git a/CHANGELOG.md b/CHANGELOG.md index 07fa17e39..7320aba5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - test/*fullchain* (#190, #196) - IexecAccessors (#189, #191, #196) - IexecPoco (#196) + - `trust` specific field (#201) - IexecPocoBoost (#198) - Migrate scripts to TypeScript: (#184) - `getFunctionSignatures.js`, `common-test-snapshot.js`, `test-storage.js`, `timelock.js` diff --git a/test/000_fullchain.test.ts b/test/000_fullchain.test.ts index c48c72c1f..31f971de5 100644 --- a/test/000_fullchain.test.ts +++ b/test/000_fullchain.test.ts @@ -117,7 +117,7 @@ describe('Integration tests', function () { beneficiary: beneficiary.address, callback: callbackAddress, volume, - trust: workers.length ** 2 - 1, + trust: BigInt(workers.length ** 2 - 1), }); const { dealId, schedulerStakePerDeal } = await iexecWrapper.signAndSponsorMatchOrders( ...orders.toArray(), @@ -208,7 +208,7 @@ describe('Integration tests', function () { beneficiary: beneficiary.address, callback: callbackAddress, volume, - trust: workers.length ** 2 - 1, + trust: BigInt(workers.length ** 2 - 1), }); const { dealId, schedulerStakePerDeal } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), @@ -296,7 +296,7 @@ describe('Integration tests', function () { beneficiary: beneficiary.address, callback: callbackAddress, volume, - trust: 1, + trust: 1n, }); const { dealId, schedulerStakePerDeal } = await iexecWrapper.signAndSponsorMatchOrders( ...orders.toArray(), @@ -374,7 +374,7 @@ describe('Integration tests', function () { beneficiary: beneficiary.address, callback: callbackAddress, volume, - trust: 1, + trust: 1n, }); const { dealId, schedulerStakePerDeal } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), @@ -450,7 +450,7 @@ describe('Integration tests', function () { requester: requester.address, tag: teeDealTag, volume, - trust: 1, + trust: 1n, }); const { dealId, dealPrice, schedulerStakePerDeal } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), @@ -522,7 +522,7 @@ describe('Integration tests', function () { requester: requester.address, tag: standardDealTag, volume, - trust: workerNumber ** 2 - 1, + trust: BigInt(workerNumber ** 2 - 1), }); const { dealId, dealPrice, schedulerStakePerDeal } = await iexecWrapper.signAndMatchOrders(...orders.toArray()); @@ -624,7 +624,7 @@ describe('Integration tests', function () { requester: requester.address, tag: standardDealTag, volume, - trust: winningWorkers.length, + trust: BigInt(winningWorkers.length), }); const { dealId, dealPrice, schedulerStakePerDeal } = await iexecWrapper.signAndMatchOrders( diff --git a/test/200_fullchain-bot.test.ts b/test/200_fullchain-bot.test.ts index fec2268cf..6a4ce788a 100644 --- a/test/200_fullchain-bot.test.ts +++ b/test/200_fullchain-bot.test.ts @@ -111,7 +111,7 @@ describe('Integration tests', function () { requester: requester.address, tag: standardDealTag, volume, - trust: 4, + trust: 4n, }); const { dealId, dealPrice, schedulerStakePerDeal } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), diff --git a/test/300_fullchain-reopen.test.ts b/test/300_fullchain-reopen.test.ts index 0ea76dced..d7a9b5481 100644 --- a/test/300_fullchain-reopen.test.ts +++ b/test/300_fullchain-reopen.test.ts @@ -114,7 +114,7 @@ describe('Integration tests', function () { requester: requester.address, tag: standardDealTag, volume, - trust: 4, + trust: 4n, }); const { dealId, dealPrice, schedulerStakePerDeal } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), diff --git a/test/byContract/IexecAccessors/IexecAccessorsABILegacy.test.ts b/test/byContract/IexecAccessors/IexecAccessorsABILegacy.test.ts index e71e61a4c..6ac920435 100644 --- a/test/byContract/IexecAccessors/IexecAccessorsABILegacy.test.ts +++ b/test/byContract/IexecAccessors/IexecAccessorsABILegacy.test.ts @@ -4,15 +4,12 @@ import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers'; import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; import { expect } from 'chai'; -import { ZeroAddress } from 'ethers'; -import { ethers } from 'hardhat'; +import { Wallet, ZeroAddress } from 'ethers'; import { - IexecInterfaceNative, IexecInterfaceNativeABILegacy, IexecInterfaceNativeABILegacy__factory, - IexecInterfaceNative__factory, } from '../../../typechain'; -import { OrdersActors, OrdersAssets, OrdersPrices, buildOrders } from '../../../utils/createOrders'; +import { OrdersAssets, OrdersPrices, buildOrders } from '../../../utils/createOrders'; import { ContributionStatusEnum, TaskStatusEnum, @@ -24,19 +21,18 @@ import { IexecWrapper } from '../../utils/IexecWrapper'; import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deployer'; const standardDealTag = '0x0000000000000000000000000000000000000000000000000000000000000000'; -const volume = 1; -const trust = 1; +const volume = 1n; +const trust = 1n; const categoryId = 1; -const appPrice = 1000; -const datasetPrice = 1_000_000; -const workerpoolPrice = 1_000_000_000; -const callbackAddress = ethers.Wallet.createRandom().address; +const appPrice = 1000n; +const datasetPrice = 1_000_000n; +const workerpoolPrice = 1_000_000_000n; +const callbackAddress = Wallet.createRandom().address; const dealParams = 'params'; const { resultDigest } = buildUtf8ResultAndDigest('result'); -const taskIndex = 0; +const taskIndex = 0n; let proxyAddress: string; -let iexecPoco: IexecInterfaceNative; let iexecPocoABILegacy: IexecInterfaceNativeABILegacy; let iexecWrapper: IexecWrapper; let [appAddress, workerpoolAddress, datasetAddress]: string[] = []; @@ -49,7 +45,6 @@ let [ anyone, worker1, ]: SignerWithAddress[] = []; -let ordersActors: OrdersActors; let ordersAssets: OrdersAssets; let ordersPrices: OrdersPrices; let [dealId, taskId, resultHash, resultSeal]: string[] = []; @@ -68,14 +63,7 @@ describe('IexecAccessorsABILegacy', function () { accounts); iexecWrapper = new IexecWrapper(proxyAddress, accounts); ({ appAddress, datasetAddress, workerpoolAddress } = await iexecWrapper.createAssets()); - iexecPoco = IexecInterfaceNative__factory.connect(proxyAddress, anyone); iexecPocoABILegacy = IexecInterfaceNativeABILegacy__factory.connect(proxyAddress, anyone); - ordersActors = { - appOwner: appProvider, - datasetOwner: datasetProvider, - workerpoolOwner: scheduler, - requester: requester, - }; ordersAssets = { app: appAddress, dataset: datasetAddress, @@ -142,7 +130,7 @@ describe('IexecAccessorsABILegacy', function () { }); it('[ABILegacy] Should return account', async function () { - const balanceAmount = 3; + const balanceAmount = 3n; await iexecWrapper.depositInIexecAccount(requester, balanceAmount); const account = await iexecPocoABILegacy.viewAccountABILegacy(requester.address); expect(account.length).to.equal(2); diff --git a/test/byContract/IexecPoco/IexecPoco1.test.ts b/test/byContract/IexecPoco/IexecPoco1.test.ts index a05b0f25f..79659cf0e 100644 --- a/test/byContract/IexecPoco/IexecPoco1.test.ts +++ b/test/byContract/IexecPoco/IexecPoco1.test.ts @@ -349,7 +349,7 @@ describe('IexecPoco1', () => { describe('Match orders', () => { it('Should match orders with: all assets, beneficiary, BoT, callback, replication', async () => { - const trust = 3; + const trust = 3n; const category = 2; const params = ''; // Use orders with full configuration. @@ -453,7 +453,7 @@ describe('IexecPoco1', () => { }); it('[Standard] Should match orders with: all assets, beneficiary, BoT, callback, replication', async () => { - const trust = 3; + const trust = 3n; const category = 2; const params = ''; // Use orders with full configuration. diff --git a/test/byContract/IexecPoco/IexecPoco2-claim.test.ts b/test/byContract/IexecPoco/IexecPoco2-claim.test.ts index 4d79bb2d3..054170c2d 100644 --- a/test/byContract/IexecPoco/IexecPoco2-claim.test.ts +++ b/test/byContract/IexecPoco/IexecPoco2-claim.test.ts @@ -78,7 +78,7 @@ describe('IexecPoco2#claim', async () => { requester: requester.address, prices: ordersPrices, volume: expectedVolume, - trust: 4, // Consensus is reachable with 2 fresh workers + trust: 4n, // Consensus is reachable with 2 fresh workers }); const { dealId, taskId, taskIndex, dealPrice, startTime } = await iexecWrapper.signAndSponsorMatchOrders(...orders.toArray()); @@ -238,7 +238,7 @@ describe('IexecPoco2#claim', async () => { assets: ordersAssets, requester: requester.address, prices: ordersPrices, - trust: 0, + trust: 0n, }); const { dealId, taskId, taskIndex } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), diff --git a/test/byContract/IexecPoco/IexecPoco2-contribute-and-finalize.test.ts b/test/byContract/IexecPoco/IexecPoco2-contribute-and-finalize.test.ts index f78ad40f3..1ebba9b85 100644 --- a/test/byContract/IexecPoco/IexecPoco2-contribute-and-finalize.test.ts +++ b/test/byContract/IexecPoco/IexecPoco2-contribute-and-finalize.test.ts @@ -31,7 +31,7 @@ const datasetPrice = 1_000_000n; const workerpoolPrice = 1_000_000_000n; const taskPrice = appPrice + datasetPrice + workerpoolPrice; const timeRef = BigInt(CONFIG.categories[0].workClockTimeRef); -const trust = 1; +const trust = 1n; const volume = 1n; const teeDealTag = '0x0000000000000000000000000000000000000000000000000000000000000001'; const standardDealTag = ZeroHash; @@ -361,7 +361,7 @@ describe('IexecPoco2#contributeAndFinalize', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 3, + trust: 3n, tag: standardDealTag, }).toArray(), ); diff --git a/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts b/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts index 8ea7b88da..4cbc92222 100644 --- a/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts +++ b/test/byContract/IexecPoco/IexecPoco2-contribute.test.ts @@ -93,7 +93,7 @@ describe('IexecPoco2#contribute', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 0, + trust: 0n, tag: standardDealTag, }); } @@ -107,7 +107,7 @@ describe('IexecPoco2#contribute', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 3, + trust: 3n, tag: teeDealTag, }).toArray(), ); @@ -212,7 +212,7 @@ describe('IexecPoco2#contribute', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 0, + trust: 0n, tag: teeDealTag, }).toArray(), ); @@ -337,7 +337,7 @@ describe('IexecPoco2#contribute', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 3, // so consensus is not yet reached on first contribution + trust: 3n, // so consensus is not yet reached on first contribution tag: standardDealTag, }).toArray(), ); @@ -395,7 +395,7 @@ describe('IexecPoco2#contribute', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 0, + trust: 0n, tag: teeDealTag, }).toArray(), ); @@ -460,7 +460,7 @@ describe('IexecPoco2#contribute', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 0, + trust: 0n, tag: teeDealTag, }).toArray(), ); diff --git a/test/byContract/IexecPoco/IexecPoco2-finalize.test.ts b/test/byContract/IexecPoco/IexecPoco2-finalize.test.ts index 697a7b922..3fb34c262 100644 --- a/test/byContract/IexecPoco/IexecPoco2-finalize.test.ts +++ b/test/byContract/IexecPoco/IexecPoco2-finalize.test.ts @@ -597,7 +597,7 @@ describe('IexecPoco2#finalize', async () => { requester: requester.address, prices: ordersPrices, volume: 1n, - trust: 3, + trust: 3n, }); const { dealId, taskId, taskIndex } = await iexecWrapper.signAndMatchOrders( ...orders.toArray(), @@ -725,7 +725,7 @@ describe('IexecPoco2#finalize', async () => { ...buildOrders({ assets: ordersAssets, requester: requester.address, - trust: 3, + trust: 3n, }).toArray(), ); await iexecPoco.initialize(dealId, taskIndex).then((tx) => tx.wait()); diff --git a/test/byContract/IexecPoco/IexecPoco2-reopen.test.ts b/test/byContract/IexecPoco/IexecPoco2-reopen.test.ts index 7aee3af1e..811593a8a 100644 --- a/test/byContract/IexecPoco/IexecPoco2-reopen.test.ts +++ b/test/byContract/IexecPoco/IexecPoco2-reopen.test.ts @@ -73,7 +73,7 @@ describe('IexecPoco2#reopen', async () => { } it('Should reopen task after reveal deadline', async () => { - await matchOrdersAndInitializeTask(3); // Multiple workers. + await matchOrdersAndInitializeTask(3n); // Multiple workers. const resultHash = buildResultHash(taskId, resultDigest); const badResultDigest = buildUtf8ResultAndDigest('bad-result').resultDigest; const contributions = [ @@ -131,7 +131,7 @@ describe('IexecPoco2#reopen', async () => { }); it('Should not reopen task when sender is not the scheduler', async () => { - await matchOrdersAndInitializeTask(1); + await matchOrdersAndInitializeTask(1n); await contribute(worker, resultDigest); const task = await iexecPoco.viewTask(taskId); // Time travel beyond reveal deadline but before final deadline. @@ -145,7 +145,7 @@ describe('IexecPoco2#reopen', async () => { }); it('Should not reopen task when status is before revealing', async () => { - await matchOrdersAndInitializeTask(3); + await matchOrdersAndInitializeTask(3n); // Only 1 contribution, consensus not reached yet. await contribute(worker1, resultDigest); const task = await iexecPoco.viewTask(taskId); @@ -156,7 +156,7 @@ describe('IexecPoco2#reopen', async () => { }); it('Should not reopen task when status is after revealing', async () => { - await matchOrdersAndInitializeTask(1); + await matchOrdersAndInitializeTask(1n); const { results, resultDigest } = buildUtf8ResultAndDigest('result'); await contribute(worker, resultDigest); // Move task to the next status (COMPLETED). @@ -173,7 +173,7 @@ describe('IexecPoco2#reopen', async () => { }); it('Should not reopen task after final deadline', async () => { - await matchOrdersAndInitializeTask(1); + await matchOrdersAndInitializeTask(1n); await contribute(worker, resultDigest); const task = await iexecPoco.viewTask(taskId); // Time travel beyond final deadline. @@ -187,7 +187,7 @@ describe('IexecPoco2#reopen', async () => { }); it('Should not reopen task before reveal deadline', async () => { - await matchOrdersAndInitializeTask(1); + await matchOrdersAndInitializeTask(1n); await contribute(worker, resultDigest); const task = await iexecPoco.viewTask(taskId); // No time travel. @@ -200,7 +200,7 @@ describe('IexecPoco2#reopen', async () => { }); it('Should not reopen task with at least 1 reveal', async () => { - await matchOrdersAndInitializeTask(3); + await matchOrdersAndInitializeTask(3n); await contribute(worker1, resultDigest); await contribute(worker2, resultDigest); // Consensus reached, reveal for worker 1. @@ -223,7 +223,7 @@ describe('IexecPoco2#reopen', async () => { * Create orders with the provided trust, match deal, and initialize task. * @param trust */ - async function matchOrdersAndInitializeTask(trust: number) { + async function matchOrdersAndInitializeTask(trust: bigint) { const orders = buildOrders({ assets: ordersAssets, prices: ordersPrices, diff --git a/test/byContract/IexecPoco/IexecPoco2-reveal.test.ts b/test/byContract/IexecPoco/IexecPoco2-reveal.test.ts index b613d77ca..b349b9768 100644 --- a/test/byContract/IexecPoco/IexecPoco2-reveal.test.ts +++ b/test/byContract/IexecPoco/IexecPoco2-reveal.test.ts @@ -79,7 +79,7 @@ describe('IexecPoco2#reveal', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 1, + trust: 1n, tag: standardDealTag, }); ({ dealId, taskIndex, taskId } = await iexecWrapper.signAndMatchOrders( @@ -195,7 +195,7 @@ describe('IexecPoco2#reveal', () => { requester: requester.address, prices: ordersPrices, volume, - trust: 3, + trust: 3n, tag: standardDealTag, salt: ethers.zeroPadValue(ethers.toBeHex(Date.now()), 32), // make }).toArray(), // app and dataset orders unique since already matched in diff --git a/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts b/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts index dc8156dd5..313c11c7d 100644 --- a/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts +++ b/test/byContract/IexecPocoBoost/IexecPocoBoost.test.ts @@ -434,7 +434,7 @@ describe('IexecPocoBoost', function () { }); const { appOrder, datasetOrder, workerpoolOrder, requestOrder } = orders.toObject(); // Change trust. - requestOrder.trust = 1; + requestOrder.trust = 1n; // Sign & hash orders. await signOrders(domain, orders, ordersActors); // Run & verify. @@ -886,7 +886,7 @@ describe('IexecPocoBoost', function () { requester: requester.address, }); // Set bad trust (> 1). - orders.requester.trust = 2; + orders.requester.trust = 2n; await expect( iexecPocoBoostInstance.matchOrdersBoost(...orders.toArray()), ).to.be.revertedWith('PocoBoost: Bad trust level'); diff --git a/test/byContract/IexecRelay/IexecRelay.test.ts b/test/byContract/IexecRelay/IexecRelay.test.ts index b887b637c..17b8752f6 100644 --- a/test/byContract/IexecRelay/IexecRelay.test.ts +++ b/test/byContract/IexecRelay/IexecRelay.test.ts @@ -17,7 +17,7 @@ const datasetPrice = 2; const workerpoolPrice = 3; const volume = 4; const category = 5; -const trust = 6; +const trust = 6n; const tag = ethers.id('tag'); const salt = ethers.id('salt'); let sign: string; diff --git a/utils/createOrders.ts b/utils/createOrders.ts index b00b118b5..ab8d91743 100644 --- a/utils/createOrders.ts +++ b/utils/createOrders.ts @@ -28,7 +28,7 @@ export interface MatchOrdersArgs { prices?: OrdersPrices; volume?: bigint; callback?: string; - trust?: number; + trust?: bigint; category?: number; params?: string; salt?: string; @@ -122,7 +122,7 @@ export function createEmptyRequestOrder(): IexecLibOrders_v5.RequestOrderStruct volume: 1, tag: constants.NULL.BYTES32, category: 0, - trust: 0, + trust: 0n, requester: constants.NULL.ADDRESS, beneficiary: constants.NULL.ADDRESS, callback: constants.NULL.ADDRESS, @@ -139,7 +139,7 @@ export function createEmptyWorkerpoolOrder(): IexecLibOrders_v5.WorkerpoolOrderS volume: 1, tag: constants.NULL.BYTES32, category: 0, - trust: 0, + trust: 0n, apprestrict: constants.NULL.ADDRESS, datasetrestrict: constants.NULL.ADDRESS, requesterrestrict: constants.NULL.ADDRESS,