1
1
// SPDX-FileCopyrightText: 2020-2025 IEXEC BLOCKCHAIN TECH <[email protected] >
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- import { AddressZero , HashZero } from '@ethersproject/constants ' ;
4
+ import { SignerWithAddress } from '@nomicfoundation/hardhat-ethers/signers ' ;
5
5
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers' ;
6
- import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' ;
7
6
import { expect } from 'chai' ;
7
+ import { ZeroAddress , ZeroHash } from 'ethers' ;
8
8
import { deployments , ethers } from 'hardhat' ;
9
- import { IexecInterfaceNative , IexecInterfaceNative__factory } from '../../../typechain' ;
9
+ import {
10
+ IexecInterfaceNative ,
11
+ IexecInterfaceNative__factory ,
12
+ IexecLibOrders_v5 ,
13
+ } from '../../../typechain' ;
10
14
import {
11
15
OrdersAssets ,
12
16
OrdersPrices ,
@@ -24,6 +28,7 @@ import {
24
28
} from '../../../utils/poco-tools' ;
25
29
import { IexecWrapper } from '../../utils/IexecWrapper' ;
26
30
import { loadHardhatFixtureDeployment } from '../../utils/hardhat-fixture-deployer' ;
31
+ import { hashDomain } from '../IexecMaintenance/IexecMaintenance.test' ;
27
32
28
33
/**
29
34
* Test state view functions.
@@ -136,10 +141,10 @@ describe('IexecAccessors', async () => {
136
141
expect ( deal . workerpool . price ) . to . equal ( workerpoolPrice ) ;
137
142
expect ( deal . trust ) . to . equal ( 1 ) ;
138
143
expect ( deal . category ) . to . equal ( 0 ) ;
139
- expect ( deal . tag ) . to . equal ( HashZero ) ; // Standard
144
+ expect ( deal . tag ) . to . equal ( ZeroHash ) ; // Standard
140
145
expect ( deal . requester ) . to . equal ( requester . address ) ;
141
- expect ( deal . beneficiary ) . to . equal ( AddressZero ) ;
142
- expect ( deal . callback ) . to . equal ( AddressZero ) ;
146
+ expect ( deal . beneficiary ) . to . equal ( ZeroAddress ) ;
147
+ expect ( deal . callback ) . to . equal ( ZeroAddress ) ;
143
148
expect ( deal . params ) . to . equal ( '' ) ;
144
149
expect ( deal . startTime ) . to . be . greaterThan ( 0 ) ;
145
150
expect ( deal . botFirst ) . to . equal ( 0 ) ;
@@ -171,10 +176,8 @@ describe('IexecAccessors', async () => {
171
176
const { dealId, taskId, taskIndex, startTime, timeRef } = await createDeal ( ) ;
172
177
await iexecWrapper . initializeTask ( dealId , taskIndex ) ;
173
178
174
- const contributionDeadlineRatio = (
175
- await iexecPoco . contribution_deadline_ratio ( )
176
- ) . toNumber ( ) ;
177
- const finalDeadlineRatio = ( await iexecPoco . final_deadline_ratio ( ) ) . toNumber ( ) ;
179
+ const contributionDeadlineRatio = Number ( await iexecPoco . contribution_deadline_ratio ( ) ) ;
180
+ const finalDeadlineRatio = Number ( await iexecPoco . final_deadline_ratio ( ) ) ;
178
181
179
182
const task = await iexecPoco . viewTask ( taskId ) ;
180
183
expect ( task . status ) . to . equal ( TaskStatusEnum . ACTIVE ) ;
@@ -184,11 +187,11 @@ describe('IexecAccessors', async () => {
184
187
expect ( task . contributionDeadline ) . to . equal ( startTime + timeRef * contributionDeadlineRatio ) ;
185
188
expect ( task . revealDeadline ) . to . equal ( 0 ) ;
186
189
expect ( task . finalDeadline ) . to . equal ( startTime + timeRef * finalDeadlineRatio ) ;
187
- expect ( task . consensusValue ) . to . equal ( HashZero ) ;
190
+ expect ( task . consensusValue ) . to . equal ( ZeroHash ) ;
188
191
expect ( task . revealCounter ) . to . equal ( 0 ) ;
189
192
expect ( task . winnerCounter ) . to . equal ( 0 ) ;
190
193
expect ( task . contributors . length ) . to . equal ( 0 ) ;
191
- expect ( task . resultDigest ) . to . equal ( HashZero ) ;
194
+ expect ( task . resultDigest ) . to . equal ( ZeroHash ) ;
192
195
expect ( task . results ) . to . equal ( '0x' ) ;
193
196
expect ( task . resultsTimestamp ) . to . equal ( 0 ) ;
194
197
expect ( task . resultsCallback ) . to . equal ( '0x' ) ;
@@ -202,7 +205,7 @@ describe('IexecAccessors', async () => {
202
205
expect ( contribution . status ) . to . equal ( ContributionStatusEnum . CONTRIBUTED ) ;
203
206
expect ( contribution . resultHash . length ) . to . equal ( 66 ) ;
204
207
expect ( contribution . resultSeal . length ) . to . equal ( 66 ) ;
205
- expect ( contribution . enclaveChallenge ) . to . equal ( AddressZero ) ;
208
+ expect ( contribution . enclaveChallenge ) . to . equal ( ZeroAddress ) ;
206
209
expect ( contribution . weight ) . to . equal ( 1 ) ;
207
210
} ) ;
208
211
@@ -234,7 +237,7 @@ describe('IexecAccessors', async () => {
234
237
} ) ;
235
238
236
239
it ( 'teeBroker' , async function ( ) {
237
- expect ( await iexecPoco . teebroker ( ) ) . to . equal ( ethers . constants . AddressZero ) ;
240
+ expect ( await iexecPoco . teebroker ( ) ) . to . equal ( ethers . ZeroAddress ) ;
238
241
} ) ;
239
242
240
243
it ( 'callbackGas' , async function ( ) {
@@ -276,8 +279,15 @@ describe('IexecAccessors', async () => {
276
279
} ) ;
277
280
278
281
it ( 'eip712domainSeparator' , async function ( ) {
279
- expect ( await iexecPoco . eip712domain_separator ( ) ) . to . equal (
280
- '0xfc2178d8b8300e657cb9f8b5a4d1957174cf1392e294f3575b82a9cea1da1c4b' ,
282
+ expect ( await iexecPoco . eip712domain_separator ( ) ) . equal (
283
+ await hashDomain ( {
284
+ // TODO use IexecWrapper.getDomain() (with some modifications).
285
+ name : 'iExecODB' ,
286
+ version : '5.0.0' ,
287
+ chainId : ( await ethers . provider . getNetwork ( ) ) . chainId ,
288
+ // address is different between `test` and `coverage` deployment
289
+ verifyingContract : proxyAddress ,
290
+ } as IexecLibOrders_v5 . EIP712DomainStructOutput ) ,
281
291
) ;
282
292
} ) ;
283
293
@@ -300,7 +310,7 @@ describe('IexecAccessors', async () => {
300
310
. then ( ( tx ) => tx . wait ( ) ) ;
301
311
const task = await iexecPoco . viewTask ( taskId ) ;
302
312
expect ( task . status ) . to . equal ( TaskStatusEnum . COMPLETED ) ;
303
- expect ( await iexecPoco . callStatic . resultFor ( taskId ) ) . to . equal ( resultsCallback ) ;
313
+ expect ( await iexecPoco . resultFor ( taskId ) ) . to . equal ( resultsCallback ) ;
304
314
} ) ;
305
315
306
316
it ( 'Should not get result when task is not completed' , async function ( ) {
@@ -333,7 +343,7 @@ async function createDeal(volume: number = 1) {
333
343
...orders . toArray ( ) ,
334
344
) ;
335
345
const dealCategory = ( await iexecPoco . viewDeal ( dealId ) ) . category ;
336
- const timeRef = ( await iexecPoco . viewCategory ( dealCategory ) ) . workClockTimeRef . toNumber ( ) ;
346
+ const timeRef = Number ( ( await iexecPoco . viewCategory ( dealCategory ) ) . workClockTimeRef ) ;
337
347
return { dealId, taskId, taskIndex, startTime, timeRef, orders } ;
338
348
}
339
349
0 commit comments