Skip to content
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
17 changes: 8 additions & 9 deletions test/integration/dual/deposit.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ describe('deposit() integration tests (L1, L2)', () => {
const amountToDeposit = ethers.utils.parseEther('10');

let owner;
let Synthetix, SynthetixBridgeToOptimism, SynthetixBridgeEscrow;
let Synthetix, SynthetixL2, SynthetixBridgeToOptimism, SynthetixBridgeEscrow;

let ownerBalance, escrowBalance;
let ownerBalance, ownerL2Balance, escrowBalance;

let depositReceipt;

describe('when the owner deposits SNX', () => {
before('target contracts and users', () => {
({ Synthetix, SynthetixBridgeToOptimism, SynthetixBridgeEscrow } = ctx.l1.contracts);
({ Synthetix: SynthetixL2 } = ctx.l2.contracts);

owner = ctx.l1.users.owner;
});

before('record balances', async () => {
ownerBalance = await Synthetix.balanceOf(owner.address);
ownerL2Balance = await SynthetixL2.balanceOf(owner.address);
escrowBalance = await Synthetix.balanceOf(SynthetixBridgeEscrow.address);
});

Expand Down Expand Up @@ -59,21 +61,18 @@ describe('deposit() integration tests (L1, L2)', () => {

describe('when the deposit gets picked up in L2', () => {
before('target contracts and users', () => {
({ Synthetix } = ctx.l2.contracts);

owner = ctx.l2.users.owner;
});

before('record balances', async () => {
ownerBalance = await Synthetix.balanceOf(owner.address);
});

before('wait for deposit finalization', async () => {
await finalizationOnL2({ ctx, transactionHash: depositReceipt.transactionHash });
});

it('increases the owner balance', async () => {
assert.bnEqual(await Synthetix.balanceOf(owner.address), ownerBalance.add(amountToDeposit));
assert.bnEqual(
await SynthetixL2.balanceOf(owner.address),
ownerL2Balance.add(amountToDeposit)
);
});
});
});
Expand Down
31 changes: 17 additions & 14 deletions test/integration/dual/depositReward.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ describe('depositReward() integration tests (L1, L2)', () => {
const rewardsToDeposit = ethers.utils.parseEther('10');

let owner;
let FeePool, Synthetix, SynthetixBridgeEscrow, SynthetixBridgeToOptimism, RewardEscrowV2;
let FeePoolL2,
Synthetix,
SynthetixL2,
SynthetixBridgeEscrow,
SynthetixBridgeToOptimism,
RewardEscrowV2L2;

let depositReceipt, escrowBalance;
let currentFeePeriodRewards, rewardEscrowBalanceL2;

describe('when the owner deposits SNX for rewards', () => {
before('target contracts and users', () => {
({ Synthetix, SynthetixBridgeEscrow, SynthetixBridgeToOptimism } = ctx.l1.contracts);
({
FeePool: FeePoolL2,
RewardEscrowV2: RewardEscrowV2L2,
Synthetix: SynthetixL2,
} = ctx.l2.contracts);

owner = ctx.l1.users.owner;
});
Expand All @@ -33,6 +44,9 @@ describe('depositReward() integration tests (L1, L2)', () => {

before('record values', async () => {
escrowBalance = await Synthetix.balanceOf(SynthetixBridgeEscrow.address);

rewardEscrowBalanceL2 = await SynthetixL2.balanceOf(RewardEscrowV2L2.address);
currentFeePeriodRewards = (await FeePoolL2.recentFeePeriods(0)).rewardsToDistribute;
});

before('deposit rewards', async () => {
Expand All @@ -49,31 +63,20 @@ describe('depositReward() integration tests (L1, L2)', () => {
});

describe('when the deposit gets picked up in L2', () => {
let currentFeePeriodRewards, rewardEscrowBalanceL2;

before('target contracts', () => {
({ FeePool, RewardEscrowV2, Synthetix } = ctx.l2.contracts);
});

before('record current fee period rewards', async () => {
rewardEscrowBalanceL2 = await Synthetix.balanceOf(RewardEscrowV2.address);
currentFeePeriodRewards = (await FeePool.recentFeePeriods(0)).rewardsToDistribute;
});

before('wait for deposit finalization', async () => {
await finalizationOnL2({ ctx, transactionHash: depositReceipt.transactionHash });
});

it('increases the RewardEscrowV2 balance on L2', async () => {
assert.bnEqual(
await Synthetix.balanceOf(RewardEscrowV2.address),
await SynthetixL2.balanceOf(RewardEscrowV2L2.address),
rewardEscrowBalanceL2.add(rewardsToDeposit)
);
});

it('increases the current fee periods rewards to distribute', async () => {
assert.bnEqual(
(await FeePool.recentFeePeriods(0)).rewardsToDistribute,
(await FeePoolL2.recentFeePeriods(0)).rewardsToDistribute,
currentFeePeriodRewards.add(rewardsToDeposit)
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('depositTo() integration tests (L1, L2)', () => {
const amountToDeposit = ethers.utils.parseEther('10');

let owner, user;
let Synthetix, SynthetixBridgeToOptimism, SynthetixBridgeEscrow;
let Synthetix, SynthetixL2, SynthetixBridgeToOptimism, SynthetixBridgeEscrow;

let ownerBalance, beneficiaryBalance, escrowBalance;

Expand All @@ -20,6 +20,7 @@ describe('depositTo() integration tests (L1, L2)', () => {
describe('when the owner deposits SNX for a user', () => {
before('target contracts and users', () => {
({ Synthetix, SynthetixBridgeToOptimism, SynthetixBridgeEscrow } = ctx.l1.contracts);
({ Synthetix: SynthetixL2 } = ctx.l2.contracts);

owner = ctx.l1.users.owner;
user = ctx.l1.users.someUser;
Expand All @@ -28,6 +29,7 @@ describe('depositTo() integration tests (L1, L2)', () => {
before('record balances', async () => {
ownerBalance = await Synthetix.balanceOf(owner.address);
escrowBalance = await Synthetix.balanceOf(SynthetixBridgeEscrow.address);
beneficiaryBalance = await SynthetixL2.balanceOf(user.address);
});

before('approve if needed', async () => {
Expand Down Expand Up @@ -65,17 +67,13 @@ describe('depositTo() integration tests (L1, L2)', () => {
owner = ctx.l2.users.owner;
});

before('record balances', async () => {
beneficiaryBalance = await Synthetix.balanceOf(user.address);
});

before('wait for deposit finalization', async () => {
await finalizationOnL2({ ctx, transactionHash: depositReceipt.transactionHash });
});

it('increases the beneficiary balance', async () => {
assert.bnEqual(
await Synthetix.balanceOf(user.address),
await SynthetixL2.balanceOf(user.address),
beneficiaryBalance.add(amountToDeposit)
);
});
Expand Down
42 changes: 21 additions & 21 deletions test/integration/dual/inflationDiversion.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,38 @@ describe('inflationDiversion() integration tests (L1, L2)', () => {

let ownerL1, ownerL2;

let FeePool,
let FeePoolL2,
RewardsDistributionL1,
RewardsDistributionL2,
RewardEscrowV2,
RewardEscrowV2L2,
Synthetix,
SynthetixL2,
SynthetixBridgeToOptimism,
SynthetixBridgeEscrow,
TradingRewards;

let depositReceipt;

let currentFeePeriodRewards;
let rewardEscrowBalanceL2, tradingRewardsBalanceL2;
const rewardsToDistribute = rewardsToDeposit.sub(tradingRewards);

describe('when the owner diverts part of the inflation to L2', () => {
before('target contracts and users', () => {
({
FeePool,
RewardsDistribution: RewardsDistributionL1,
Synthetix,
SynthetixBridgeEscrow,
SynthetixBridgeToOptimism,
} = ctx.l1.contracts);

({ RewardsDistribution: RewardsDistributionL2, TradingRewards } = ctx.l2.contracts);
({
RewardsDistribution: RewardsDistributionL2,
TradingRewards,
FeePool: FeePoolL2,
RewardEscrowV2: RewardEscrowV2L2,
Synthetix: SynthetixL2,
} = ctx.l2.contracts);

ownerL1 = ctx.l1.users.owner;
ownerL2 = ctx.l2.users.owner;
Expand All @@ -44,6 +54,10 @@ describe('inflationDiversion() integration tests (L1, L2)', () => {

before('record values', async () => {
escrowBalance = await Synthetix.balanceOf(SynthetixBridgeEscrow.address);

rewardEscrowBalanceL2 = await SynthetixL2.balanceOf(RewardEscrowV2L2.address);
tradingRewardsBalanceL2 = await SynthetixL2.balanceOf(TradingRewards.address);
currentFeePeriodRewards = (await FeePoolL2.recentFeePeriods(0)).rewardsToDistribute;
});

before('add new distributions', async () => {
Expand Down Expand Up @@ -89,41 +103,27 @@ describe('inflationDiversion() integration tests (L1, L2)', () => {
});

describe('when the rewards deposit gets picked up in L2', () => {
let currentFeePeriodRewards;
let rewardEscrowBalanceL2, tradingRewardsBalanceL2;
const rewardsToDistribute = rewardsToDeposit.sub(tradingRewards);

before('target contracts', () => {
({ FeePool, RewardEscrowV2, Synthetix } = ctx.l2.contracts);
});

before('record current values', async () => {
rewardEscrowBalanceL2 = await Synthetix.balanceOf(RewardEscrowV2.address);
tradingRewardsBalanceL2 = await Synthetix.balanceOf(TradingRewards.address);
currentFeePeriodRewards = (await FeePool.recentFeePeriods(0)).rewardsToDistribute;
});

before('wait for deposit finalization', async () => {
await finalizationOnL2({ ctx, transactionHash: depositReceipt.transactionHash });
});

it('increases the current fee periods rewards to distribute', async () => {
assert.bnEqual(
(await FeePool.recentFeePeriods(0)).rewardsToDistribute,
(await FeePoolL2.recentFeePeriods(0)).rewardsToDistribute,
currentFeePeriodRewards.add(rewardsToDistribute)
);
});

it('increases the TradingRewards balance on L2', async () => {
assert.bnEqual(
await Synthetix.balanceOf(TradingRewards.address),
await SynthetixL2.balanceOf(TradingRewards.address),
tradingRewardsBalanceL2.add(tradingRewards)
);
});

it('increases the RewardEscrowV2 balance on L2', async () => {
assert.bnEqual(
await Synthetix.balanceOf(RewardEscrowV2.address),
await SynthetixL2.balanceOf(RewardEscrowV2L2.address),
rewardEscrowBalanceL2.add(rewardsToDistribute)
);
});
Expand Down
20 changes: 6 additions & 14 deletions test/integration/dual/withdraw.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@ describe('withdraw() integration tests (L1, L2)', () => {
const amountToWithdraw = ethers.utils.parseEther('10');

let owner;
let Synthetix, SynthetixBridgeToBase;
let Synthetix, SynthetixL1, SynthetixBridgeToBase;

let ownerBalance;
let ownerBalance, ownerL1Balance;

let withdrawalReceipt;

describe('when the owner withdraws SNX', () => {
before('target contracts and users', () => {
({ Synthetix, SynthetixBridgeToBase } = ctx.l2.contracts);
({ Synthetix: SynthetixL1 } = ctx.l1.contracts);

owner = ctx.l2.users.owner;
});

before('record balances', async () => {
ownerBalance = await Synthetix.balanceOf(owner.address);
ownerL1Balance = await SynthetixL1.balanceOf(owner.address);
});

before('make the withdrawal', async () => {
Expand Down Expand Up @@ -55,24 +57,14 @@ describe('withdraw() integration tests (L1, L2)', () => {
}
});

before('target contracts and users', () => {
({ Synthetix } = ctx.l1.contracts);

owner = ctx.l1.users.owner;
});

before('record balances', async () => {
ownerBalance = await Synthetix.balanceOf(owner.address);
});

before('wait for withdrawal finalization', async () => {
await finalizationOnL1({ ctx, transactionHash: withdrawalReceipt.transactionHash });
});

it('increases the owner balance', async () => {
assert.bnEqual(
await Synthetix.balanceOf(owner.address),
ownerBalance.add(amountToWithdraw)
await SynthetixL1.balanceOf(owner.address),
ownerL1Balance.add(amountToWithdraw)
);
});
});
Expand Down
12 changes: 4 additions & 8 deletions test/integration/dual/withdrawTo.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('withdrawTo() integration tests (L1, L2)', () => {
const amountToWithdraw = ethers.utils.parseEther('10');

let owner, user;
let Synthetix, SynthetixBridgeToBase;
let Synthetix, SynthetixL1, SynthetixBridgeToBase;

let ownerBalance, beneficiaryBalance;

Expand All @@ -21,13 +21,15 @@ describe('withdrawTo() integration tests (L1, L2)', () => {
describe('when the owner withdraws SNX for a user', () => {
before('target contracts and users', () => {
({ Synthetix, SynthetixBridgeToBase } = ctx.l2.contracts);
({ Synthetix: SynthetixL1 } = ctx.l1.contracts);

owner = ctx.l2.users.owner;
user = ctx.l2.users.someUser;
});

before('record balances', async () => {
ownerBalance = await Synthetix.balanceOf(owner.address);
beneficiaryBalance = await SynthetixL1.balanceOf(user.address);
});

before('make the withdrawal', async () => {
Expand Down Expand Up @@ -56,23 +58,17 @@ describe('withdrawTo() integration tests (L1, L2)', () => {
});

before('target contracts and users', () => {
({ Synthetix } = ctx.l1.contracts);

owner = ctx.l1.users.owner;
user = ctx.l1.users.someUser;
});

before('record balances', async () => {
beneficiaryBalance = await Synthetix.balanceOf(user.address);
});

before('wait for withdrawal finalization', async () => {
await finalizationOnL1({ ctx, transactionHash: withdrawalReceipt.transactionHash });
});

it('increases the user balance', async () => {
assert.bnEqual(
await Synthetix.balanceOf(user.address),
await SynthetixL1.balanceOf(user.address),
beneficiaryBalance.add(amountToWithdraw)
);
});
Expand Down
Loading