From da27351aebdb106c6a0332210dbe8d38f65add49 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:11:28 +0200 Subject: [PATCH 01/14] Rename file to ts --- .../IexecAccessors/{IexecAccessors.js => IexecAccessors.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/byContract/IexecAccessors/{IexecAccessors.js => IexecAccessors.ts} (100%) diff --git a/test/byContract/IexecAccessors/IexecAccessors.js b/test/byContract/IexecAccessors/IexecAccessors.ts similarity index 100% rename from test/byContract/IexecAccessors/IexecAccessors.js rename to test/byContract/IexecAccessors/IexecAccessors.ts From f1220cc9d4b3c47adabd0add4818f79543b0c2a2 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:35:36 +0200 Subject: [PATCH 02/14] Deploy RLC using factory --- deploy/0_deploy.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/deploy/0_deploy.ts b/deploy/0_deploy.ts index fea06dd80..640beccc2 100644 --- a/deploy/0_deploy.ts +++ b/deploy/0_deploy.ts @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2023-2024 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import fs from 'fs'; import hre, { ethers } from 'hardhat'; import path from 'path'; @@ -68,7 +67,7 @@ module.exports = async function () { // Deploy RLC const isTokenMode = deploymentOptions.asset == 'Token'; let rlcInstanceAddress = isTokenMode - ? await getOrDeployRlc(deploymentOptions.token, owner) // token + ? await getOrDeployRlc(deploymentOptions.token, factoryDeployer) // token : ethers.constants.AddressZero; // native console.log(`RLC: ${rlcInstanceAddress}`); // Deploy ERC1538 proxy contracts @@ -186,16 +185,8 @@ module.exports = async function () { } }; -async function getOrDeployRlc(token: string, owner: SignerWithAddress) { - return token // token - ? token - : await new RLC__factory() - .connect(owner) - .deploy() - .then((contract) => { - contract.deployed(); - return contract.address; - }); +async function getOrDeployRlc(token: string, factoryDeployer: FactoryDeployerHelper) { + return token ? token : await factoryDeployer.deployWithFactory(new RLC__factory()); } /** From 502714b70cc27ded655a9bff9d61407c59d883c1 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:35:56 +0200 Subject: [PATCH 03/14] Disable repetitive log message --- scripts/hardhat-fixture-deployer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/hardhat-fixture-deployer.ts b/scripts/hardhat-fixture-deployer.ts index a652ac859..f28d2d1dd 100644 --- a/scripts/hardhat-fixture-deployer.ts +++ b/scripts/hardhat-fixture-deployer.ts @@ -17,7 +17,7 @@ async function resetNetworkAndDeployAllContracts() { * @returns proxy address. */ export const loadHardhatFixtureDeployment = async () => { - console.log('Running hardhat-fixture'); + // console.log('Running hardhat-fixture'); await loadFixture(resetNetworkAndDeployAllContracts); return (await deployments.get('ERC1538Proxy')).address; }; From 72a76d51ec544cd5b994e2e3ae8f102c1556214a Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:36:48 +0200 Subject: [PATCH 04/14] Migrate IexecAccessors to TS and Hardhat --- .../IexecAccessors/IexecAccessors.ts | 214 +++++++++--------- 1 file changed, 104 insertions(+), 110 deletions(-) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index ad4a5dfb6..756aeb165 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -1,123 +1,117 @@ // SPDX-FileCopyrightText: 2020-2024 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 -// Config -var DEPLOYMENT = require('../../../config/config.json').chains.default; -// Artefacts -var RLC = artifacts.require('rlc-faucet-contract/contracts/RLC'); -var ERC1538Proxy = artifacts.require('iexec-solidity/ERC1538Proxy'); -var IexecInterface = artifacts.require(`IexecInterface${DEPLOYMENT.asset}`); -var AppRegistry = artifacts.require('AppRegistry'); -var DatasetRegistry = artifacts.require('DatasetRegistry'); -var WorkerpoolRegistry = artifacts.require('WorkerpoolRegistry'); -var App = artifacts.require('App'); -var Dataset = artifacts.require('Dataset'); -var Workerpool = artifacts.require('Workerpool'); - -const { BN, expectEvent, expectRevert } = require('@openzeppelin/test-helpers'); -const tools = require('../../../utils/tools'); -const enstools = require('../../../utils/ens-tools'); -const odbtools = require('../../../utils/odb-tools'); -const constants = require('../../../utils/constants'); - -Object.extract = (obj, keys) => keys.map((key) => obj[key]); - -contract('Accessors', async (accounts) => { - assert.isAtLeast(accounts.length, 10, 'should have at least 10 accounts'); - let iexecAdmin = null; - let appProvider = null; - let datasetProvider = null; - let scheduler = null; - let worker1 = null; - let worker2 = null; - let worker3 = null; - let worker4 = null; - let worker5 = null; - let user = null; - - var RLCInstance = null; - var IexecInstance = null; - var AppRegistryInstance = null; - var DatasetRegistryInstance = null; - var WorkerpoolRegistryInstance = null; - - var categories = []; - - /*************************************************************************** - * Environment configuration * - ***************************************************************************/ - before('configure', async () => { - console.log('# web3 version:', web3.version); - - /** - * Retreive deployed contracts - */ - IexecInstance = await IexecInterface.at((await ERC1538Proxy.deployed()).address); - AppRegistryInstance = await AppRegistry.deployed(); - DatasetRegistryInstance = await DatasetRegistry.deployed(); - WorkerpoolRegistryInstance = await WorkerpoolRegistry.deployed(); - ERC712_domain = await IexecInstance.domain(); - RLCInstance = - DEPLOYMENT.asset == 'Native' - ? { address: constants.NULL.ADDRESS } - : await RLC.at(await IexecInstance.token()); - - broker = new odbtools.Broker(IexecInstance); - iexecAdmin = new odbtools.iExecAgent(IexecInstance, accounts[0]); - appProvider = new odbtools.iExecAgent(IexecInstance, accounts[1]); - datasetProvider = new odbtools.iExecAgent(IexecInstance, accounts[2]); - scheduler = new odbtools.Scheduler(IexecInstance, accounts[3]); - worker1 = new odbtools.Worker(IexecInstance, accounts[4]); - worker2 = new odbtools.Worker(IexecInstance, accounts[5]); - worker3 = new odbtools.Worker(IexecInstance, accounts[6]); - worker4 = new odbtools.Worker(IexecInstance, accounts[7]); - worker5 = new odbtools.Worker(IexecInstance, accounts[8]); - user = new odbtools.iExecAgent(IexecInstance, accounts[9]); - await broker.initialize(); +import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; +import { deployments, ethers, expect } from 'hardhat'; +import { loadHardhatFixtureDeployment } from '../../../scripts/hardhat-fixture-deployer'; +import { IexecInterfaceNative, IexecInterfaceNative__factory } from '../../../typechain'; +import { getIexecAccounts } from '../../../utils/poco-tools'; + +describe('IexecAccessors', async () => { + let proxyAddress: string; + let iexecPoco: IexecInterfaceNative; + let iexecPocoAsAnyone: IexecInterfaceNative; + let [iexecAdmin, anyone]: SignerWithAddress[] = []; + + beforeEach('Deploy', async () => { + // Deploy all contracts + proxyAddress = await loadHardhatFixtureDeployment(); + // Initialize test environment + await loadFixture(initFixture); }); - /*************************************************************************** - * * - ***************************************************************************/ - describe('checking constant view methods', async () => { - describe('escrow', async () => { - it('token', async () => { - assert.equal(await IexecInstance.token(), RLCInstance.address); - }); + async function initFixture() { + const accounts = await getIexecAccounts(); + ({ anyone } = accounts); + iexecPoco = IexecInterfaceNative__factory.connect(proxyAddress, iexecAdmin); + iexecPocoAsAnyone = iexecPoco.connect(anyone); + } + + /** + * Constant view functions. + */ + describe('Config', function () { + it('token', async function () { + expect(await iexecPocoAsAnyone.token()).to.equal( + (await deployments.get('RLC')).address, + ); }); - - describe('ERC20 metadata', async () => { - it('name', async () => { - assert.equal(await IexecInstance.name(), 'Staked RLC'); - }); - - it('symbol', async () => { - assert.equal(await IexecInstance.symbol(), 'SRLC'); - }); - - it('decimals', async () => { - assert.equal(Number(await IexecInstance.decimals()), 9); - }); + it('teeBroker', async function () { + expect(await iexecPocoAsAnyone.teebroker()).to.equal(ethers.constants.AddressZero); + }); + it('callbackGas', async function () { + expect(await iexecPocoAsAnyone.callbackgas()).to.equal(100_000n); + }); + it('contributionDeadlineRatio', async function () { + expect(await iexecPocoAsAnyone.contribution_deadline_ratio()).to.equal(7); + }); + it('revealDeadlineRatio', async function () { + expect(await iexecPocoAsAnyone.reveal_deadline_ratio()).to.equal(2n); + }); + it('finalDeadlineRatio', async function () { + expect(await iexecPocoAsAnyone.final_deadline_ratio()).to.equal(10n); + }); + it('workerpoolStakeRatio', async function () { + expect(await iexecPocoAsAnyone.workerpool_stake_ratio()).to.equal(30n); }); + it('kittyRatio', async function () { + expect(await iexecPocoAsAnyone.kitty_ratio()).to.equal(10n); + }); + it('kittyMin', async function () { + expect(await iexecPocoAsAnyone.kitty_min()).to.equal(1_000_000_000n); + }); + it('kittyAddress', async function () { + expect(await iexecPocoAsAnyone.kitty_address()).to.equal( + '0x99c2268479b93fDe36232351229815DF80837e23', + ); + }); + it('groupMemberPurpose', async function () { + expect(await iexecPocoAsAnyone.groupmember_purpose()).to.equal(4n); + }); + it('eip712domainSeparator', async function () { + expect(await iexecPocoAsAnyone.eip712domain_separator()).to.equal( + '0xa7f6cdedcb45986a7899488be2922240b87b40530107380aa44c198d3b5550c6', + ); + }); + }); - describe('Registries', async () => { - it('AppRegistry', async () => { - assert.equal(await IexecInstance.appregistry(), AppRegistryInstance.address); - }); + describe('ERC', function () { + it('name', async function () { + expect(await iexecPocoAsAnyone.name()).to.equal('Staked RLC'); + }); + it('symbol', async function () { + expect(await iexecPocoAsAnyone.symbol()).to.equal('SRLC'); + }); + it('decimals', async function () { + expect(await iexecPocoAsAnyone.decimals()).to.equal(9n); + }); + it('totalSupply', async function () { + expect(await iexecPocoAsAnyone.totalSupply()).to.equal(0n); + }); + }); - it('DatasetRegistry', async () => { - assert.equal( - await IexecInstance.datasetregistry(), - DatasetRegistryInstance.address, - ); - }); + describe('Categories', function () { + it('countCategory', async function () { + expect(await iexecPocoAsAnyone.countCategory()).to.equal(5); + }); + }); - it('AppRegistry', async () => { - assert.equal( - await IexecInstance.workerpoolregistry(), - WorkerpoolRegistryInstance.address, - ); - }); + describe('registries', function () { + it('appRegistry', async function () { + expect(await iexecPocoAsAnyone.appregistry()).to.equal( + (await deployments.get('AppRegistry')).address, + ); + }); + it('datasetRegistry', async function () { + expect(await iexecPocoAsAnyone.datasetregistry()).to.equal( + (await deployments.get('DatasetRegistry')).address, + ); + }); + it('workerpoolRegistry', async function () { + expect(await iexecPocoAsAnyone.workerpoolregistry()).to.equal( + (await deployments.get('WorkerpoolRegistry')).address, + ); }); }); }); From b08822e993222f0fa4cec6ba200cc99e7f6f7fe1 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:40:23 +0200 Subject: [PATCH 05/14] Clean --- test/byContract/IexecAccessors/IexecAccessors.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index 756aeb165..4f4bfe626 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -8,6 +8,9 @@ import { loadHardhatFixtureDeployment } from '../../../scripts/hardhat-fixture-d import { IexecInterfaceNative, IexecInterfaceNative__factory } from '../../../typechain'; import { getIexecAccounts } from '../../../utils/poco-tools'; +/** + * Test constant view functions. + */ describe('IexecAccessors', async () => { let proxyAddress: string; let iexecPoco: IexecInterfaceNative; @@ -28,9 +31,6 @@ describe('IexecAccessors', async () => { iexecPocoAsAnyone = iexecPoco.connect(anyone); } - /** - * Constant view functions. - */ describe('Config', function () { it('token', async function () { expect(await iexecPocoAsAnyone.token()).to.equal( From 9be1b3cb509250d7ea4b86bdc3df1db6343868ce Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:09:59 +0200 Subject: [PATCH 06/14] Revert "Deploy RLC using factory" This reverts commit f1220cc9d4b3c47adabd0add4818f79543b0c2a2. --- deploy/0_deploy.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/deploy/0_deploy.ts b/deploy/0_deploy.ts index 113890e1d..363293196 100644 --- a/deploy/0_deploy.ts +++ b/deploy/0_deploy.ts @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: 2023-2024 IEXEC BLOCKCHAIN TECH // SPDX-License-Identifier: Apache-2.0 +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import fs from 'fs'; import hre, { ethers } from 'hardhat'; import path from 'path'; @@ -67,7 +68,7 @@ module.exports = async function () { // Deploy RLC const isTokenMode = deploymentOptions.asset == 'Token'; let rlcInstanceAddress = isTokenMode - ? await getOrDeployRlc(deploymentOptions.token, factoryDeployer) // token + ? await getOrDeployRlc(deploymentOptions.token, owner) // token : ethers.constants.AddressZero; // native console.log(`RLC: ${rlcInstanceAddress}`); // Deploy ERC1538 proxy contracts @@ -187,8 +188,16 @@ module.exports = async function () { } }; -async function getOrDeployRlc(token: string, factoryDeployer: FactoryDeployerHelper) { - return token ? token : await factoryDeployer.deployWithFactory(new RLC__factory()); +async function getOrDeployRlc(token: string, owner: SignerWithAddress) { + return token // token + ? token + : await new RLC__factory() + .connect(owner) + .deploy() + .then((contract) => { + contract.deployed(); + return contract.address; + }); } /** From 997750be4a7ac55c3e85fe30f6671ab76907e5bc Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:24:58 +0200 Subject: [PATCH 07/14] Fix tests --- scripts/hardhat-fixture-deployer.ts | 2 +- test/byContract/IexecAccessors/IexecAccessors.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/hardhat-fixture-deployer.ts b/scripts/hardhat-fixture-deployer.ts index f28d2d1dd..a652ac859 100644 --- a/scripts/hardhat-fixture-deployer.ts +++ b/scripts/hardhat-fixture-deployer.ts @@ -17,7 +17,7 @@ async function resetNetworkAndDeployAllContracts() { * @returns proxy address. */ export const loadHardhatFixtureDeployment = async () => { - // console.log('Running hardhat-fixture'); + console.log('Running hardhat-fixture'); await loadFixture(resetNetworkAndDeployAllContracts); return (await deployments.get('ERC1538Proxy')).address; }; diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index 4f4bfe626..1948be639 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -34,7 +34,7 @@ describe('IexecAccessors', async () => { describe('Config', function () { it('token', async function () { expect(await iexecPocoAsAnyone.token()).to.equal( - (await deployments.get('RLC')).address, + '0x5FbDB2315678afecb367f032d93F642f64180aa3', ); }); it('teeBroker', async function () { @@ -71,7 +71,7 @@ describe('IexecAccessors', async () => { }); it('eip712domainSeparator', async function () { expect(await iexecPocoAsAnyone.eip712domain_separator()).to.equal( - '0xa7f6cdedcb45986a7899488be2922240b87b40530107380aa44c198d3b5550c6', + '0xfc2178d8b8300e657cb9f8b5a4d1957174cf1392e294f3575b82a9cea1da1c4b', ); }); }); From 4979c965bbe37dadd50c570f138ea11540236e33 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:03:30 +0200 Subject: [PATCH 08/14] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8ddbd7e0..254b01b04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Changelog ## vNEXT -- Wait for transactions occurring during deployment. (#94) +- Migrate IexecAccessors tests Typescript & Hardhat. (#96) +- Wait for transactions occurring during deployment. (#95) - Deploy and configure ENS with hardhat. (#93) - Fix contribute & finalize with callbacks. (#92) - [Deploy Poco sponsoring on local fork of Bellecour](./scripts/sponsoring/README.md). (#91) From bf8302c6a1bdafbb05e98b29551a90c25a52a6a8 Mon Sep 17 00:00:00 2001 From: Zied Guesmi <26070035+zguesmi@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:02:31 +0200 Subject: [PATCH 09/14] Update test/byContract/IexecAccessors/IexecAccessors.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérémy James Toussaint <33313130+jeremyjams@users.noreply.github.com> --- test/byContract/IexecAccessors/IexecAccessors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index 1948be639..5532335ab 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -76,7 +76,7 @@ describe('IexecAccessors', async () => { }); }); - describe('ERC', function () { + describe('ERC20', function () { it('name', async function () { expect(await iexecPocoAsAnyone.name()).to.equal('Staked RLC'); }); From 1a63fc0410f6961825c84573033084dc0feed754 Mon Sep 17 00:00:00 2001 From: Zied Guesmi <26070035+zguesmi@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:02:37 +0200 Subject: [PATCH 10/14] Update test/byContract/IexecAccessors/IexecAccessors.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérémy James Toussaint <33313130+jeremyjams@users.noreply.github.com> --- test/byContract/IexecAccessors/IexecAccessors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index 5532335ab..eb900307e 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -97,7 +97,7 @@ describe('IexecAccessors', async () => { }); }); - describe('registries', function () { + describe('Registries', function () { it('appRegistry', async function () { expect(await iexecPocoAsAnyone.appregistry()).to.equal( (await deployments.get('AppRegistry')).address, From 7d814b0c25a874d8e66430b55c909c7bd1febb6b Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:04:30 +0200 Subject: [PATCH 11/14] Keep only pocoAsAnyone instance --- test/byContract/IexecAccessors/IexecAccessors.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index eb900307e..46692843d 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -13,9 +13,8 @@ import { getIexecAccounts } from '../../../utils/poco-tools'; */ describe('IexecAccessors', async () => { let proxyAddress: string; - let iexecPoco: IexecInterfaceNative; let iexecPocoAsAnyone: IexecInterfaceNative; - let [iexecAdmin, anyone]: SignerWithAddress[] = []; + let anyone: SignerWithAddress; beforeEach('Deploy', async () => { // Deploy all contracts @@ -27,8 +26,7 @@ describe('IexecAccessors', async () => { async function initFixture() { const accounts = await getIexecAccounts(); ({ anyone } = accounts); - iexecPoco = IexecInterfaceNative__factory.connect(proxyAddress, iexecAdmin); - iexecPocoAsAnyone = iexecPoco.connect(anyone); + iexecPocoAsAnyone = IexecInterfaceNative__factory.connect(proxyAddress, anyone); } describe('Config', function () { From d5afde94674ab7d2f0cc4a18814bb064b0d15ef8 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:21:15 +0200 Subject: [PATCH 12/14] Reorder tests according to source file functions order --- .../IexecAccessors/IexecAccessors.ts | 147 ++++++++---------- 1 file changed, 68 insertions(+), 79 deletions(-) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index 46692843d..b411b6bbc 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -29,87 +29,76 @@ describe('IexecAccessors', async () => { iexecPocoAsAnyone = IexecInterfaceNative__factory.connect(proxyAddress, anyone); } - describe('Config', function () { - it('token', async function () { - expect(await iexecPocoAsAnyone.token()).to.equal( - '0x5FbDB2315678afecb367f032d93F642f64180aa3', - ); - }); - it('teeBroker', async function () { - expect(await iexecPocoAsAnyone.teebroker()).to.equal(ethers.constants.AddressZero); - }); - it('callbackGas', async function () { - expect(await iexecPocoAsAnyone.callbackgas()).to.equal(100_000n); - }); - it('contributionDeadlineRatio', async function () { - expect(await iexecPocoAsAnyone.contribution_deadline_ratio()).to.equal(7); - }); - it('revealDeadlineRatio', async function () { - expect(await iexecPocoAsAnyone.reveal_deadline_ratio()).to.equal(2n); - }); - it('finalDeadlineRatio', async function () { - expect(await iexecPocoAsAnyone.final_deadline_ratio()).to.equal(10n); - }); - it('workerpoolStakeRatio', async function () { - expect(await iexecPocoAsAnyone.workerpool_stake_ratio()).to.equal(30n); - }); - it('kittyRatio', async function () { - expect(await iexecPocoAsAnyone.kitty_ratio()).to.equal(10n); - }); - it('kittyMin', async function () { - expect(await iexecPocoAsAnyone.kitty_min()).to.equal(1_000_000_000n); - }); - it('kittyAddress', async function () { - expect(await iexecPocoAsAnyone.kitty_address()).to.equal( - '0x99c2268479b93fDe36232351229815DF80837e23', - ); - }); - it('groupMemberPurpose', async function () { - expect(await iexecPocoAsAnyone.groupmember_purpose()).to.equal(4n); - }); - it('eip712domainSeparator', async function () { - expect(await iexecPocoAsAnyone.eip712domain_separator()).to.equal( - '0xfc2178d8b8300e657cb9f8b5a4d1957174cf1392e294f3575b82a9cea1da1c4b', - ); - }); + it('name', async function () { + expect(await iexecPocoAsAnyone.name()).to.equal('Staked RLC'); }); - - describe('ERC20', function () { - it('name', async function () { - expect(await iexecPocoAsAnyone.name()).to.equal('Staked RLC'); - }); - it('symbol', async function () { - expect(await iexecPocoAsAnyone.symbol()).to.equal('SRLC'); - }); - it('decimals', async function () { - expect(await iexecPocoAsAnyone.decimals()).to.equal(9n); - }); - it('totalSupply', async function () { - expect(await iexecPocoAsAnyone.totalSupply()).to.equal(0n); - }); + it('symbol', async function () { + expect(await iexecPocoAsAnyone.symbol()).to.equal('SRLC'); }); - - describe('Categories', function () { - it('countCategory', async function () { - expect(await iexecPocoAsAnyone.countCategory()).to.equal(5); - }); + it('decimals', async function () { + expect(await iexecPocoAsAnyone.decimals()).to.equal(9n); }); - - describe('Registries', function () { - it('appRegistry', async function () { - expect(await iexecPocoAsAnyone.appregistry()).to.equal( - (await deployments.get('AppRegistry')).address, - ); - }); - it('datasetRegistry', async function () { - expect(await iexecPocoAsAnyone.datasetregistry()).to.equal( - (await deployments.get('DatasetRegistry')).address, - ); - }); - it('workerpoolRegistry', async function () { - expect(await iexecPocoAsAnyone.workerpoolregistry()).to.equal( - (await deployments.get('WorkerpoolRegistry')).address, - ); - }); + it('totalSupply', async function () { + expect(await iexecPocoAsAnyone.totalSupply()).to.equal(0n); + }); + it('token', async function () { + expect(await iexecPocoAsAnyone.token()).to.equal( + '0x5FbDB2315678afecb367f032d93F642f64180aa3', + ); + }); + it('countCategory', async function () { + expect(await iexecPocoAsAnyone.countCategory()).to.equal(5); + }); + it('appRegistry', async function () { + expect(await iexecPocoAsAnyone.appregistry()).to.equal( + (await deployments.get('AppRegistry')).address, + ); + }); + it('datasetRegistry', async function () { + expect(await iexecPocoAsAnyone.datasetregistry()).to.equal( + (await deployments.get('DatasetRegistry')).address, + ); + }); + it('workerpoolRegistry', async function () { + expect(await iexecPocoAsAnyone.workerpoolregistry()).to.equal( + (await deployments.get('WorkerpoolRegistry')).address, + ); + }); + it('teeBroker', async function () { + expect(await iexecPocoAsAnyone.teebroker()).to.equal(ethers.constants.AddressZero); + }); + it('callbackGas', async function () { + expect(await iexecPocoAsAnyone.callbackgas()).to.equal(100_000n); + }); + it('contributionDeadlineRatio', async function () { + expect(await iexecPocoAsAnyone.contribution_deadline_ratio()).to.equal(7); + }); + it('revealDeadlineRatio', async function () { + expect(await iexecPocoAsAnyone.reveal_deadline_ratio()).to.equal(2n); + }); + it('finalDeadlineRatio', async function () { + expect(await iexecPocoAsAnyone.final_deadline_ratio()).to.equal(10n); + }); + it('workerpoolStakeRatio', async function () { + expect(await iexecPocoAsAnyone.workerpool_stake_ratio()).to.equal(30n); + }); + it('kittyRatio', async function () { + expect(await iexecPocoAsAnyone.kitty_ratio()).to.equal(10n); + }); + it('kittyMin', async function () { + expect(await iexecPocoAsAnyone.kitty_min()).to.equal(1_000_000_000n); + }); + it('kittyAddress', async function () { + expect(await iexecPocoAsAnyone.kitty_address()).to.equal( + '0x99c2268479b93fDe36232351229815DF80837e23', + ); + }); + it('groupMemberPurpose', async function () { + expect(await iexecPocoAsAnyone.groupmember_purpose()).to.equal(4n); + }); + it('eip712domainSeparator', async function () { + expect(await iexecPocoAsAnyone.eip712domain_separator()).to.equal( + '0xfc2178d8b8300e657cb9f8b5a4d1957174cf1392e294f3575b82a9cea1da1c4b', + ); }); }); From 9386532df244617133090cb97c08b0dc1604ab94 Mon Sep 17 00:00:00 2001 From: Zied <26070035+zguesmi@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:35:03 +0200 Subject: [PATCH 13/14] Add todo --- test/byContract/IexecAccessors/IexecAccessors.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index b411b6bbc..0457e18d2 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -41,6 +41,7 @@ describe('IexecAccessors', async () => { it('totalSupply', async function () { expect(await iexecPocoAsAnyone.totalSupply()).to.equal(0n); }); + // TODO test the case where token() == 0x0 in native mode. it('token', async function () { expect(await iexecPocoAsAnyone.token()).to.equal( '0x5FbDB2315678afecb367f032d93F642f64180aa3', From ac3f9a0335a2ff37802ce719f91bc7b652dbf212 Mon Sep 17 00:00:00 2001 From: Zied Guesmi <26070035+zguesmi@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:38:20 +0200 Subject: [PATCH 14/14] Update test/byContract/IexecAccessors/IexecAccessors.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérémy James Toussaint <33313130+jeremyjams@users.noreply.github.com> --- test/byContract/IexecAccessors/IexecAccessors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/byContract/IexecAccessors/IexecAccessors.ts b/test/byContract/IexecAccessors/IexecAccessors.ts index 0457e18d2..0bc0d91e7 100644 --- a/test/byContract/IexecAccessors/IexecAccessors.ts +++ b/test/byContract/IexecAccessors/IexecAccessors.ts @@ -9,7 +9,7 @@ import { IexecInterfaceNative, IexecInterfaceNative__factory } from '../../../ty import { getIexecAccounts } from '../../../utils/poco-tools'; /** - * Test constant view functions. + * Test state view functions. */ describe('IexecAccessors', async () => { let proxyAddress: string;