From 013a654c771000231503f04c2a5390dd906b621e Mon Sep 17 00:00:00 2001 From: danoctavian Date: Fri, 17 Jun 2022 09:21:44 +0300 Subject: [PATCH 1/4] fix enroll --- test/integration/index.js | 2 +- test/integration/setup.js | 40 +++++++++++++++++++++++++------- test/integration/utils/enroll.js | 5 ++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/test/integration/index.js b/test/integration/index.js index fbadf5213d..cd8c91f69b 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -2,7 +2,7 @@ const { takeSnapshot, revertToSnapshot, reset } = require('./utils').evm; const setup = require('./setup'); -describe.skip('INTEGRATION TESTS', function () { +describe.only('INTEGRATION TESTS', function () { before(setup); beforeEach(async function () { diff --git a/test/integration/setup.js b/test/integration/setup.js index 3cb2e9c5e9..c0b020818c 100644 --- a/test/integration/setup.js +++ b/test/integration/setup.js @@ -79,6 +79,9 @@ async function setup () { const IndividualClaims = artifacts.require('IndividualClaims'); const Assessment = artifacts.require('Assessment'); + const signers = await ethers.getSigners(); + const ethersAccounts = getAccounts(signers); + // external const WETH9 = artifacts.require('WETH9'); const CSMockSettlement = artifacts.require('CSMockSettlement'); @@ -213,6 +216,9 @@ async function setup () { [owner], // advisory board members ); + await mr.setKycAuthAddress(ethersAccounts.defaultSender.address); + + await pc.initialize(mr.address); for (const category of proposalCategories) { @@ -432,26 +438,42 @@ async function setup () { ethToDaiRate, }; - this.contractType = contractType; - const kycAuthSigner = ''; - await enrollMember(this.contracts, members, kycAuthSigner); + this.contractType = contractType; - const signers = await ethers.getSigners(); this.withEthers = web3ToEthers(this, signers); + await enrollMember(this.contracts, ethersAccounts.members, ethersAccounts.defaultSender); + + const DEFAULT_POOL_FEE = '5' + + const DEFAULT_PRODUCT_INITIALIZATION = [ + { + productId: 0, + weight: 100, + initialPrice: 1000, + targetPrice: 1000 + } + ] + for (let i = 0; i < 3; i++) { - const tx = await this.withEthers.contracts.cover.createStakingPool(stakingPoolManagers[i]); + const tx = await this.withEthers.contracts.cover.createStakingPool( + stakingPoolManagers[i], + false, // isPrivatePool, + DEFAULT_POOL_FEE, // initialPoolFee + DEFAULT_POOL_FEE, // maxPoolFee, + DEFAULT_PRODUCT_INITIALIZATION, + '0', // depositAmount, + '0', // trancheId + ); const receipt = await tx.wait(); const { stakingPoolAddress } = receipt.events[0].args; const stakingPoolInstance = await IntegrationMockStakingPool.at(stakingPoolAddress); - await stakingPoolInstance.setPrice(0, 100); - await stakingPoolInstance.setPrice(1, 100); - await stakingPoolInstance.setPrice(2, 100); - await stakingPoolInstance.setPrice(3, 100); + this.contracts['stakingPool' + i] = stakingPoolInstance; } + this.withEthers = web3ToEthers(this, signers); } diff --git a/test/integration/utils/enroll.js b/test/integration/utils/enroll.js index 2db883d2de..6ce3f0856c 100644 --- a/test/integration/utils/enroll.js +++ b/test/integration/utils/enroll.js @@ -41,9 +41,8 @@ async function enrollMember ({ mr, tk, tc }, members, kycAuthSigner, options = { value: JOINING_FEE, }); - - await tk.approve(tc.address, MAX_UINT256, { from: member }); - await tk.transfer(member, toBN(initialTokens)); + await tk.approve(tc.address, MAX_UINT256, { from: member.address }); + await tk.transfer(member.address, toBN(initialTokens)); } } From 6a54489b1d5bb364feae61e4183b778697148c28 Mon Sep 17 00:00:00 2001 From: danoctavian Date: Mon, 20 Jun 2022 08:49:02 +0300 Subject: [PATCH 2/4] upgrade cover data --- .../mocks/Disposables/DisposableCover.sol | 27 ++++++++++++------- test/integration/setup.js | 17 +++++++----- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/contracts/mocks/Disposables/DisposableCover.sol b/contracts/mocks/Disposables/DisposableCover.sol index 2537bd101a..f8dcb9506b 100644 --- a/contracts/mocks/Disposables/DisposableCover.sol +++ b/contracts/mocks/Disposables/DisposableCover.sol @@ -12,21 +12,22 @@ contract DisposableCover is MasterAwareV2 { /* ========== STATE VARIABLES ========== */ - Product[] public products; - ProductType[] public productTypes; + Product[] internal _products; + ProductType[] internal _productTypes; - CoverData[] private coverData; + CoverData[] private _coverData; mapping(uint => mapping(uint => PoolAllocation[])) public coverSegmentAllocations; /* Each Cover has an array of segments. A new segment is created everytime a cover is edited to deliniate the different cover periods. */ - mapping(uint => CoverSegment[]) coverSegments; + mapping(uint => CoverSegment[]) private _coverSegments; + uint24 public globalCapacityRatio; uint24 public globalRewardsRatio; - uint64 public stakingPoolCounter; + uint64 public stakingPoolCount; /* bit map representing which assets are globally supported for paying for and for paying out covers @@ -35,13 +36,19 @@ contract DisposableCover is MasterAwareV2 { */ uint32 public coverAssetsFallback; + // Global active cover amount per asset. + mapping(uint24 => uint) public totalActiveCoverInAsset; + + bool public coverAmountTrackingEnabled; + bool public activeCoverAmountCommitted; + function addProducts( Product[] calldata newProducts, string[] calldata ipfsMetadata ) external { - uint initialProuctsCount = products.length; + uint initialProuctsCount = _products.length; for (uint i = 0; i < newProducts.length; i++) { - products.push(newProducts[i]); + _products.push(newProducts[i]); emit ProductUpserted(initialProuctsCount + i, ipfsMetadata[i]); } } @@ -50,9 +57,9 @@ contract DisposableCover is MasterAwareV2 { ProductType[] calldata newProductTypes, string[] calldata ipfsMetadata ) public { - uint initialProuctTypesCount = productTypes.length; + uint initialProuctTypesCount = _productTypes.length; for (uint i = 0; i < newProductTypes.length; i++) { - productTypes.push(newProductTypes[i]); + _productTypes.push(newProductTypes[i]); emit ProductTypeUpserted(initialProuctTypesCount + i, ipfsMetadata[i]); } } @@ -63,7 +70,7 @@ contract DisposableCover is MasterAwareV2 { ) public { require(productIds.length == initialPriceRatios.length, "Cover: Array lengths must not be different"); for (uint i = 0; i < productIds.length; i++) { - products[productIds[i]].initialPriceRatio = initialPriceRatios[i]; + _products[productIds[i]].initialPriceRatio = initialPriceRatios[i]; } } diff --git a/test/integration/setup.js b/test/integration/setup.js index c0b020818c..7c48049e63 100644 --- a/test/integration/setup.js +++ b/test/integration/setup.js @@ -170,7 +170,11 @@ async function setup () { const as = await deployProxy(DisposableAssessment, []); const cl = await deployProxy(CoverMigrator, []); - const cover = await deployProxy(DisposableCover, []); + const coverUtilsLib = await CoverUtilsLib.new(); + await Cover.link(coverUtilsLib); + + let cover = await deployProxy(DisposableCover, []); + const coverNFT = await CoverNFT.new('Nexus Mutual Cover', 'NMC', cover.address); const stakingPool = await IntegrationMockStakingPool.new(tk.address, cover.address, tc.address, mr.address); @@ -328,14 +332,15 @@ async function setup () { await upgradeProxy(yt.address, YieldTokenIncidents, [tk.address, coverNFT.address]); await upgradeProxy(as.address, Assessment, [master.address]); - const coverUtilsLib = await CoverUtilsLib.new(); - await Cover.link(coverUtilsLib); + await upgradeProxy(cover.address, Cover, [ qd.address, productsV1.address, - stakingPool.address, - coverNFT.address + coverNFT.address, + stakingPool.address ]); + + cover = await Cover.at(cover.address); // // { // const params = {} @@ -467,7 +472,7 @@ async function setup () { '0', // trancheId ); const receipt = await tx.wait(); - const { stakingPoolAddress } = receipt.events[0].args; + const stakingPoolAddress = await cover.stakingPool(i); const stakingPoolInstance = await IntegrationMockStakingPool.at(stakingPoolAddress); this.contracts['stakingPool' + i] = stakingPoolInstance; From 2cd68c75d6b087e4317f834d01c8e13169861146 Mon Sep 17 00:00:00 2001 From: danoctavian Date: Wed, 22 Jun 2022 17:36:28 +0300 Subject: [PATCH 3/4] add index for cover tests --- test/integration/Cover/index.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/integration/Cover/index.js diff --git a/test/integration/Cover/index.js b/test/integration/Cover/index.js new file mode 100644 index 0000000000..e69de29bb2 From b6b985d17b78dffc760fe604c2611e5906512685 Mon Sep 17 00:00:00 2001 From: danoctavian Date: Fri, 24 Jun 2022 16:52:38 +0300 Subject: [PATCH 4/4] remove only for now --- test/integration/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/index.js b/test/integration/index.js index cd8c91f69b..fbadf5213d 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -2,7 +2,7 @@ const { takeSnapshot, revertToSnapshot, reset } = require('./utils').evm; const setup = require('./setup'); -describe.only('INTEGRATION TESTS', function () { +describe.skip('INTEGRATION TESTS', function () { before(setup); beforeEach(async function () {