Skip to content

Commit

Permalink
[Common] update fixtures in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov committed Feb 6, 2024
1 parent cb9b516 commit eea3a9b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/farming/test/shared/externalFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const v3CoreFactoryFixture: () => Promise<IAlgebraFactory> = async () => {
const _factory = (await v3FactoryFactory.deploy(poolDeployerAddress)) as any as IAlgebraFactory;

const poolDeployerFactory = await ethers.getContractFactory(POOL_DEPLOYER_ABI, POOL_DEPLOYER_BYTECODE);
const poolDeployer = await poolDeployerFactory.deploy(_factory, vaultAddress);
const poolDeployer = await poolDeployerFactory.deploy(_factory);

const pluginContractFactory = await ethers.getContractFactory(PLUGIN_FACTORY_ABI, PLUGIN_FACTORY_BYTECODE);
const pluginFactory = await pluginContractFactory.deploy(_factory);
Expand Down
2 changes: 1 addition & 1 deletion src/farming/test/shared/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const v3CoreFactoryFixture: () => Promise<[IAlgebraFactory, IAlgebraPoolDeployer
const _factory = (await v3FactoryFactory.deploy(poolDeployerAddress)) as any as IAlgebraFactory;

const poolDeployerFactory = await ethers.getContractFactory(AlgebraPoolDeployerJson.abi, AlgebraPoolDeployerJson.bytecode);
const _deployer = (await poolDeployerFactory.deploy(_factory, vaultAddress)) as any as IAlgebraPoolDeployer;
const _deployer = (await poolDeployerFactory.deploy(_factory)) as any as IAlgebraPoolDeployer;

const pluginContractFactory = await ethers.getContractFactory(PLUGIN_FACTORY_ABI, PLUGIN_FACTORY_BYTECODE);
const pluginFactory = (await pluginContractFactory.deploy(_factory)) as any as IBasePluginV1Factory;
Expand Down
2 changes: 1 addition & 1 deletion src/periphery/test/shared/externalFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const v3CoreFactoryFixture: () => Promise<IAlgebraFactory> = async () => {
const _factory = (await v3FactoryFactory.deploy(poolDeployerAddress)) as any as IAlgebraFactory;

const poolDeployerFactory = await ethers.getContractFactory(POOL_DEPLOYER_ABI, POOL_DEPLOYER_BYTECODE);
const poolDeployer = await poolDeployerFactory.deploy(_factory, vaultAddress);
const poolDeployer = await poolDeployerFactory.deploy(_factory);

return _factory;
};
Expand Down
4 changes: 3 additions & 1 deletion src/plugin/test/AlgebraPool.gas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
MaxUint128,
SwapToPriceFunction,
} from '../../core/test/shared/utilities';
import { ZERO_ADDRESS } from './shared/fixtures';

describe('AlgebraPool gas tests [ @skip-on-coverage ]', () => {
let wallet: Wallet, other: Wallet;
Expand All @@ -44,7 +45,7 @@ describe('AlgebraPool gas tests [ @skip-on-coverage ]', () => {
const mockPluginFactoryFactory = await ethers.getContractFactory('MockTimeDSFactory');
const mockPluginFactory = (await mockPluginFactoryFactory.deploy(fix.factory)) as any as MockTimeDSFactory;

await mockPluginFactory.createPlugin(pool);
await mockPluginFactory.createPlugin(pool, ZERO_ADDRESS, ZERO_ADDRESS);
const pluginAddress = await mockPluginFactory.pluginByPool(pool);

const mockDSOperatorFactory = await ethers.getContractFactory('MockTimeAlgebraBasePluginV1');
Expand All @@ -68,6 +69,7 @@ describe('AlgebraPool gas tests [ @skip-on-coverage ]', () => {
const virtualPoolMock = (await virtualPoolMockFactory.deploy()) as any as MockTimeVirtualPool;

await pool.initialize(encodePriceSqrt(1, 1));
await pool.setCommunityVault(wallet.address);

await advanceTime(1);
await mint(wallet.address, minTick, maxTick, expandTo18Decimals(2));
Expand Down
6 changes: 3 additions & 3 deletions src/plugin/test/BasePluginV1Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ describe('BasePluginV1Factory', () => {

describe('#Create plugin', () => {
it('only factory', async () => {
expect(pluginFactory.createPlugin(wallet.address)).to.be.revertedWithoutReason;
expect(pluginFactory.createPlugin(wallet.address, ZERO_ADDRESS, ZERO_ADDRESS)).to.be.revertedWithoutReason;
});

it('factory can create plugin', async () => {
const pluginFactoryFactory = await ethers.getContractFactory('BasePluginV1Factory');
const pluginFactoryMock = (await pluginFactoryFactory.deploy(wallet.address)) as any as BasePluginV1Factory;

const pluginAddress = await pluginFactoryMock.createPlugin.staticCall(wallet.address);
await pluginFactoryMock.createPlugin(wallet.address);
const pluginAddress = await pluginFactoryMock.createPlugin.staticCall(wallet.address, ZERO_ADDRESS, ZERO_ADDRESS);
await pluginFactoryMock.createPlugin(wallet.address, ZERO_ADDRESS, ZERO_ADDRESS);

const pluginMock = (await ethers.getContractFactory('AlgebraBasePluginV1')).attach(pluginAddress) as any as AlgebraBasePluginV1;
const feeConfig = await pluginMock.feeConfig();
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/test/shared/externalFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const algebraPoolDeployerMockFixture: () => Promise<MockPoolDeployerFixtu
token1,
factory,
createPool: async (firstToken = token0, secondToken = token1) => {
await poolDeployer.deployMock(factory, ZERO_ADDRESS, firstToken, secondToken);
await poolDeployer.deployMock(factory, firstToken, secondToken);

const sortedTokens =
BigInt(await firstToken.getAddress()) < BigInt(await secondToken.getAddress())
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/test/shared/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const pluginFixture: Fixture<PluginFixture> = async function (): Promise<
const mockPoolFactory = await ethers.getContractFactory('MockPool');
const mockPool = (await mockPoolFactory.deploy()) as any as MockPool;

await mockPluginFactory.createPlugin(mockPool);
await mockPluginFactory.createPlugin(mockPool, ZERO_ADDRESS, ZERO_ADDRESS);
const pluginAddress = await mockPluginFactory.pluginByPool(mockPool);

const mockDSOperatorFactory = await ethers.getContractFactory('MockTimeAlgebraBasePluginV1');
Expand Down

0 comments on commit eea3a9b

Please sign in to comment.