Skip to content

Commit

Permalink
fix fork-test: update amounts and balances.js
Browse files Browse the repository at this point in the history
  • Loading branch information
barrasso committed Apr 11, 2024
1 parent 739ff7e commit f6866d6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test/integration/behaviors/redeem.dynamic.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function itCanRedeem({ ctx }) {
ctx,
symbol: synth1,
user: someUser,
balance: parseEther('100'),
balance: parseEther('1'),
});
});

Expand All @@ -56,7 +56,7 @@ function itCanRedeem({ ctx }) {
ctx,
symbol: synth2,
user: someUser,
balance: parseEther('500'),
balance: parseEther('100'),
});
});

Expand Down
35 changes: 34 additions & 1 deletion test/integration/utils/balances.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ async function _getSNX({ ctx, user, amount }) {

async function _getSNXForOwner({ ctx, amount }) {
if (!ctx.useOvm) {
throw new Error('There is no more SNX!');
if (ctx.fork) {
await _getSNXForOwnerOnL1ByHackTransfer({ ctx, amount });
} else {
throw new Error('There is no more SNX!');
}
} else {
if (ctx.l1) {
await _getSNXForOwnerOnL2ByDepositing({ ctx: ctx.l1, amount });
Expand All @@ -121,6 +125,35 @@ async function _getSNXForOwnerOnL2ByDepositing({ ctx, amount }) {
await deposit({ ctx, from: ctx.users.owner, to: ctx.users.owner, amount });
}

async function _getSNXForOwnerOnL1ByHackTransfer({ ctx, amount }) {
const owner = ctx.users.owner;

let { Synthetix, AddressResolver } = ctx.contracts;

const bridgeName = toBytes32('SynthetixBridgeToOptimism');
const bridgeAddress = await AddressResolver.getAddress(bridgeName);

const bridgeEscrowName = toBytes32('SynthetixBridgeEscrow');
const bridgeEscrowAddress = await AddressResolver.getAddress(bridgeEscrowName);

let tx;

AddressResolver = AddressResolver.connect(owner);
tx = await AddressResolver.importAddresses([bridgeName], [owner.address]);
await tx.wait();
tx = await AddressResolver.rebuildCaches([Synthetix.address]);
await tx.wait();

Synthetix = Synthetix.connect(owner);
tx = await Synthetix.transferFrom(bridgeEscrowAddress, owner.address, amount);
await tx.wait();

tx = await AddressResolver.importAddresses([bridgeName], [bridgeAddress]);
await tx.wait();
tx = await AddressResolver.rebuildCaches([Synthetix.address]);
await tx.wait();
}

async function _getSNXForOwnerOnL2ByHackMinting({ ctx, amount }) {
const owner = ctx.users.owner;

Expand Down

0 comments on commit f6866d6

Please sign in to comment.