Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sporadic failures due to promises #1

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"ethereum-checksum-address": "^0.0.8",
"ethereum-waffle": "^3.4.4",
"ethers": "^5.7.2",
"hardhat": "~2.20.1",
"hardhat": "~2.22.2",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-gas-reporter": "^2.0.2",
"prettier": "^3.2.5",
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/aaveV2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const { AaveV2Fixture } = require('./aaveV2Fixture');
const { getSigners } = require('../helpers/accountUtil');
const { snapshotBlockchain, revertBlockchain } = require('../helpers/evmUtil.js');

describe('AaveV2Fixture', async () => {
const [owner, protocolFeeRecipient] = await getSigners();
describe('AaveV2Fixture', () => {
const [owner, protocolFeeRecipient] = getSigners();
const systemFixture = new SystemFixture(owner, protocolFeeRecipient);
const aaveV2Fixture = new AaveV2Fixture(owner);

Expand All @@ -28,7 +28,7 @@ describe('AaveV2Fixture', async () => {
await revertBlockchain(snapshotId);
});

describe('init', async () => {
describe('init', () => {
let snapshotId;
beforeEach(async () => {
snapshotId = await snapshotBlockchain();
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/uniswap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const { getSigners } = require('../helpers/accountUtil');
const { ZERO, MAX_UINT_256 } = require('../helpers/constants');
const { snapshotBlockchain, revertBlockchain } = require('../helpers/evmUtil.js');

describe('class UniswapFixture', async () => {
const [owner, protocolFeeRecipient] = await getSigners();
describe('class UniswapFixture', () => {
const [owner, protocolFeeRecipient] = getSigners();
const systemFixture = new SystemFixture(owner, protocolFeeRecipient);
const uniswapFixture = new UniswapFixture(owner);

Expand All @@ -29,7 +29,7 @@ describe('class UniswapFixture', async () => {
await revertBlockchain(snapshotId);
});

describe('init', async () => {
describe('init', () => {
let snapshotId;
beforeEach(async () => {
snapshotId = await snapshotBlockchain();
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('class UniswapFixture', async () => {
});
});

describe('addLiquidity', async () => {
describe('addLiquidity', () => {
let snapshotId;
beforeEach(async () => {
snapshotId = await snapshotBlockchain();
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('class UniswapFixture', async () => {
});
});

describe('stake', async () => {
describe('stake', () => {
let stakeAmount;

beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/addressArrayUtil.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { testCases, others } = require('../cases/addressArrayUtil.json');
const { compareArray, quickPopArrayItem } = require('../helpers/arrayUtil');
const { snapshotBlockchain, revertBlockchain } = require('../helpers/evmUtil.js');

describe('library AddressArrayUtil', async () => {
describe('library AddressArrayUtil', () => {
let arrayMock;

let snapshotId;
Expand Down
2 changes: 1 addition & 1 deletion test/lib/exactSafeErc20.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { deployContract } = require('../helpers/deploy');
const { testCases } = require('../cases/exactSafeErc20.json');
const { snapshotBlockchain, revertBlockchain } = require('../helpers/evmUtil.js');

describe('library ExactSafeErc20', async () => {
describe('library ExactSafeErc20', () => {
let appMock;
let erc20Mock;
const [owner, userA, userB] = provider.getWallets();
Expand Down
2 changes: 1 addition & 1 deletion test/lib/preciseUnitMath.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
preciseDivFloorInt,
} = require('../helpers/mathUtil');

describe('library PreciseUnitMath', async () => {
describe('library PreciseUnitMath', () => {
let mathMock;

let snapshotId;
Expand Down
4 changes: 2 additions & 2 deletions test/lib/uint256ArrayUtil.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { compareArray } = require('../helpers/arrayUtil');
const { testCases } = require('../cases/uint256ArrayUtil.json');
const { snapshotBlockchain, revertBlockchain } = require('../helpers/evmUtil.js');

describe('library Uint256ArrayUtil', async () => {
describe('library Uint256ArrayUtil', () => {
let arrayMock;

let snapshotId;
Expand All @@ -25,7 +25,7 @@ describe('library Uint256ArrayUtil', async () => {
});

testCases.map((testCase, i) => {
describe(`test case ${i}`, async () => {
describe(`test case ${i}`, () => {
const array1 = testCase.array1;
const array2 = testCase.array2;
const result1 = testCase.result;
Expand Down
2 changes: 1 addition & 1 deletion test/lib/unitConversionUtil.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { ethToWei, usdToWei } = require('../helpers/unitUtil');
const { testCases } = require('../cases/unitConversionUtil.json');
const { snapshotBlockchain, revertBlockchain } = require('../helpers/evmUtil.js');

describe('library UnitConversionUtil', async () => {
describe('library UnitConversionUtil', () => {
const usdcDecimals = 6;
let unitMock;

Expand Down
28 changes: 14 additions & 14 deletions test/protocol/controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { getSigners } = require('../helpers/accountUtil');
const { snapshotBlockchain, revertBlockchain } = require('../helpers/evmUtil.js');
const { ZERO_ADDRESS, ZERO, ONE } = require('../helpers/constants');

describe('contract Controller', async () => {
describe('contract Controller', () => {
const [owner, protocolFeeRecipient, basicIssuanceModule, matrixTokenFactory, priceOracle, matrixToken, userMock, randomAccount] = getSigners();
const protocolFeeRecipientAddress = protocolFeeRecipient.address;

Expand Down Expand Up @@ -42,7 +42,7 @@ describe('contract Controller', async () => {
revertBlockchain(snapshotId);
});

describe('constructor', async () => {
describe('constructor', () => {
let snapshotId;
before(async () => {
snapshotId = await snapshotBlockchain();
Expand All @@ -63,7 +63,7 @@ describe('contract Controller', async () => {
});
});

describe('initialize', async () => {
describe('initialize', () => {
let resourceId;
let factories;
let modules;
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('contract Controller', async () => {
});
});

describe('addMatrix', async () => {
describe('addMatrix', () => {
const matrixTokenAddr = matrixToken.address;

async function addMatrix() {
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('contract Controller', async () => {
});
});

describe('removeMatrix', async () => {
describe('removeMatrix', () => {
const matrixTokenAddr = matrixToken.address;

async function removeMatrix() {
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('contract Controller', async () => {
});
});

describe('addFactory', async () => {
describe('addFactory', () => {
let factory;

async function addFactory() {
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('contract Controller', async () => {
});
});

describe('removeFactory', async () => {
describe('removeFactory', () => {
let factory;

async function removeFactory() {
Expand Down Expand Up @@ -410,7 +410,7 @@ describe('contract Controller', async () => {
});
});

describe('addModule', async () => {
describe('addModule', () => {
let module;

async function addModule() {
Expand Down Expand Up @@ -467,7 +467,7 @@ describe('contract Controller', async () => {
});
});

describe('removeModule', async () => {
describe('removeModule', () => {
let module;

async function removeModule() {
Expand Down Expand Up @@ -525,7 +525,7 @@ describe('contract Controller', async () => {
});
});

describe('addResource', async () => {
describe('addResource', () => {
let resource;
let resourceId;
let priceOracleAddress;
Expand Down Expand Up @@ -596,7 +596,7 @@ describe('contract Controller', async () => {
});
});

describe('removeResource', async () => {
describe('removeResource', () => {
let resource;
let resourceId;

Expand Down Expand Up @@ -661,7 +661,7 @@ describe('contract Controller', async () => {
});
});

describe('addFee', async () => {
describe('addFee', () => {
let module;
let feeType;
let feePercentage;
Expand Down Expand Up @@ -718,7 +718,7 @@ describe('contract Controller', async () => {
});
});

describe('editFee', async () => {
describe('editFee', () => {
let module;
let feeType;
let feePercentage;
Expand Down Expand Up @@ -776,7 +776,7 @@ describe('contract Controller', async () => {
});
});

describe('editFeeRecipient', async () => {
describe('editFeeRecipient', () => {
let protocolFeeRecipient;

async function editFeeRecipient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const { SystemFixture } = require('../../../fixtures/systemFixture');
const { snapshotBlockchain, revertBlockchain } = require('../../../helpers/evmUtil.js');
const { ZERO, MAX_UINT_256, ZERO_ADDRESS, EMPTY_BYTES } = require('../../../helpers/constants');

describe('contract KyberLegacyExchangeAdapter', async () => {
const [owner, protocolFeeRecipient, matrixTokenMock] = await getSigners();
describe('contract KyberLegacyExchangeAdapter', () => {
const [owner, protocolFeeRecipient, matrixTokenMock] = getSigners();
const systemFixture = new SystemFixture(owner, protocolFeeRecipient);
const wbtcRate = ethToWei(33); // 1 WBTC = 33 ETH

Expand All @@ -37,14 +37,14 @@ describe('contract KyberLegacyExchangeAdapter', async () => {
await revertBlockchain(snapshotId);
});

describe('getSpender', async () => {
describe('getSpender', () => {
it('should return the correct spender address', async () => {
const actualKyberAddress = await kyberLegacyExchangeAdapter.getSpender();
expect(actualKyberAddress).eq(kyberNetworkProxy.address);
});
});

describe('getConversionRates', async () => {
describe('getConversionRates', () => {
async function getConversionRates() {
const srcToken = systemFixture.wbtc.address;
const destToken = systemFixture.weth.address;
Expand All @@ -58,7 +58,7 @@ describe('contract KyberLegacyExchangeAdapter', async () => {
});
});

describe('getTradeCalldata', async () => {
describe('getTradeCalldata', () => {
const srcQuantity = btcToWei(1); // Trade 1 WBTC
const minDestQuantity = ethToWei(33); // Receive at least 33 ETH
const pathBytes = EMPTY_BYTES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const { ethToWei, btcToWei } = require('../../../helpers/unitUtil');
const { snapshotBlockchain, revertBlockchain } = require('../../../helpers/evmUtil.js');
const { ZERO, ONE, EMPTY_BYTES, ZERO_ADDRESS } = require('../../../helpers/constants');

describe('contract OneInchExchangeAdapter', async () => {
const [owner, matrixTokenMock, wbtcMock, wethMock, oneInchSpenderMock, randomAccount] = await getSigners();
describe('contract OneInchExchangeAdapter', () => {
const [owner, matrixTokenMock, wbtcMock, wethMock, oneInchSpenderMock, randomAccount] = getSigners();

let oneInchExchangeMock;
let oneInchExchangeAdapter;
Expand All @@ -42,7 +42,7 @@ describe('contract OneInchExchangeAdapter', async () => {
await revertBlockchain(snapshotId);
});

describe('constructor', async () => {
describe('constructor', () => {
it('should have the correct approve address', async () => {
const actualAddress = await oneInchExchangeAdapter.getSpender();
expect(actualAddress).eq(oneInchSpenderMock.address);
Expand All @@ -59,7 +59,7 @@ describe('contract OneInchExchangeAdapter', async () => {
});
});

describe('getTradeCalldata', async () => {
describe('getTradeCalldata', () => {
const srcQuantity = ONE;
const minDestQuantity = ONE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const { UniswapFixture } = require('../../../fixtures/uniswapFixture');
const { snapshotBlockchain, revertBlockchain, getLastBlockTimestamp } = require('../../../helpers/evmUtil.js');
const { ZERO, EMPTY_BYTES } = require('../../../helpers/constants');

describe('contract UniswapV2ExchangeAdapter', async () => {
const [owner, protocolFeeRecipient, matrixTokenMock] = await getSigners();
describe('contract UniswapV2ExchangeAdapter', () => {
const [owner, protocolFeeRecipient, matrixTokenMock] = getSigners();
const systemFixture = new SystemFixture(owner, protocolFeeRecipient);
const uniswapFixture = new UniswapFixture(owner);

Expand All @@ -35,14 +35,14 @@ describe('contract UniswapV2ExchangeAdapter', async () => {
await revertBlockchain(snapshotId);
});

describe('getSpender', async () => {
describe('getSpender', () => {
it('should have the correct router address', async () => {
const actualRouterAddress = await uniswapV2ExchangeAdapter.getSpender();
expect(actualRouterAddress).eq(uniswapFixture.router.address);
});
});

describe('getTradeCalldata', async () => {
describe('getTradeCalldata', () => {
const srcQuantity = btcToWei(1); // Trade 1 WBTC
const minDestQuantity = ethToWei(30000); // Receive at least 30k DAI

Expand Down
Loading