Skip to content

Commit

Permalink
Fix some more instances of LUSD in JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bingen committed Jan 31, 2024
1 parent c5d3d99 commit ac1e4d0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 46 deletions.
12 changes: 6 additions & 6 deletions contracts/test/AccessControlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract(

for (account of accounts.slice(0, 10)) {
await th.openTrove(coreContracts, {
extraLUSDAmount: toBN(dec(20000, 18)),
extraBoldAmount: toBN(dec(20000, 18)),
ICR: toBN(dec(2, 18)),
extraParams: { from: account },
});
Expand Down Expand Up @@ -235,7 +235,7 @@ contract(
}
});

// increaseLUSD
// increaseBold
it("increaseBoldDebt(): reverts when called by an account that is not BO nor TroveM", async () => {
// Attempt call from alice
try {
Expand All @@ -251,7 +251,7 @@ contract(
}
});

// decreaseLUSD
// decreaseBold
it("decreaseBoldDebt(): reverts when called by an account that is not BO nor TroveM nor SP", async () => {
// Attempt call from alice
try {
Expand Down Expand Up @@ -300,7 +300,7 @@ contract(
}
});

// increaseLUSD
// increaseBold
it("increaseBoldDebt(): reverts when called by an account that is not TroveManager", async () => {
// Attempt call from alice
try {
Expand All @@ -313,8 +313,8 @@ contract(
}
});

// decreaseLUSD
it("decreaseLUSD(): reverts when called by an account that is not TroveManager", async () => {
// decreaseBold
it("decreaseBold(): reverts when called by an account that is not TroveManager", async () => {
// Attempt call from alice
try {
const txAlice = await defaultPool.decreaseBoldDebt(100, {
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/CollSurplusPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ contract("CollSurplusPool", async (accounts) => {

// open trove from NonPayable proxy contract
const B_coll = toBN(dec(60, 18));
const B_lusdAmount = toBN(dec(3000, 18));
const B_boldAmount = toBN(dec(3000, 18));
const B_netDebt = await th.getAmountWithBorrowingFee(
contracts,
B_lusdAmount
B_boldAmount
);
const openTroveData = th.getTransactionData(
"openTrove(uint256,uint256,address,address)",
["0xde0b6b3a7640000", web3.utils.toHex(B_lusdAmount), B, B]
["0xde0b6b3a7640000", web3.utils.toHex(B_boldAmount), B, B]
);
await nonPayable.forward(borrowerOperations.address, openTroveData, {
value: B_coll,
Expand Down
18 changes: 9 additions & 9 deletions contracts/test/HintHelpers_getApproxHintTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ contract("HintHelpers", async (accounts) => {
const getNetBorrowingAmount = async (debtWithFee) =>
th.getNetBorrowingAmount(contracts, debtWithFee);

/* Open a Trove for each account. LUSD debt is 200 LUSD each, with collateral beginning at
/* Open a Trove for each account. BOLD debt is 200 BOLD each, with collateral beginning at
1.5 ether, and rising by 0.01 ether per Trove. Hence, the ICR of account (i + 1) is always 1% greater than the ICR of account i.
*/

// Open Troves in parallel, then withdraw LUSD in parallel
// Open Troves in parallel, then withdraw BOLD in parallel
const makeTrovesInParallel = async (accounts, n) => {
activeAccounts = accounts.slice(0, n);
// console.log(`number of accounts used is: ${activeAccounts.length}`)
Expand All @@ -41,10 +41,10 @@ contract("HintHelpers", async (accounts) => {
openTrove(account, index)
);
await Promise.all(openTrovepromises);
const withdrawLUSDpromises = activeAccounts.map((account) =>
withdrawLUSDfromTrove(account)
const withdrawBoldpromises = activeAccounts.map((account) =>
withdrawBoldfromTrove(account)
);
await Promise.all(withdrawLUSDpromises);
await Promise.all(withdrawBoldpromises);
// console.timeEnd("makeTrovesInParallel")
};

Expand All @@ -57,8 +57,8 @@ contract("HintHelpers", async (accounts) => {
});
};

const withdrawLUSDfromTrove = async (account) => {
await borrowerOperations.withdrawLUSD(
const withdrawBoldfromTrove = async (account) => {
await borrowerOperations.withdrawBold(
th._100pct,
"100000000000000000000",
account,
Expand All @@ -67,7 +67,7 @@ contract("HintHelpers", async (accounts) => {
);
};

// Sequentially add coll and withdraw LUSD, 1 account at a time
// Sequentially add coll and withdraw BOLD, 1 account at a time
const makeTrovesInSequence = async (accounts, n) => {
activeAccounts = accounts.slice(0, n);
// console.log(`number of accounts used is: ${activeAccounts.length}`)
Expand All @@ -78,7 +78,7 @@ contract("HintHelpers", async (accounts) => {
for (const account of activeAccounts) {
const ICR_BN = toBN(ICR.toString().concat("0".repeat(16)));
await th.openTrove(contracts, {
extraLUSDAmount: toBN(dec(10000, 18)),
extraBoldAmount: toBN(dec(10000, 18)),
ICR: ICR_BN,
extraParams: { from: account },
});
Expand Down
48 changes: 24 additions & 24 deletions contracts/test/PoolsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract('StabilityPool', async accounts => {
assert.equal(recordedETHBalance, 0)
})

it('getTotalBoldDeposits(): gets the recorded LUSD balance', async () => {
it('getTotalBoldDeposits(): gets the recorded BOLD balance', async () => {
const recordedETHBalance = await stabilityPool.getTotalBoldDeposits()
assert.equal(recordedETHBalance, 0)
})
Expand All @@ -53,39 +53,39 @@ contract('ActivePool', async accounts => {
assert.equal(recordedETHBalance, 0)
})

it('getBoldDebt(): gets the recorded LUSD balance', async () => {
it('getBoldDebt(): gets the recorded BOLD balance', async () => {
const recordedETHBalance = await activePool.getBoldDebt()
assert.equal(recordedETHBalance, 0)
})

it('increaseBoldDebt(): increases the recorded LUSD balance by the correct amount', async () => {
const recordedLUSD_balanceBefore = await activePool.getBoldDebt()
assert.equal(recordedLUSD_balanceBefore, 0)
it('increaseBoldDebt(): increases the recorded BOLD balance by the correct amount', async () => {
const recordedBold_balanceBefore = await activePool.getBoldDebt()
assert.equal(recordedBold_balanceBefore, 0)

// await activePool.increaseBoldDebt(100, { from: mockBorrowerOperationsAddress })
const increaseBoldDebtData = th.getTransactionData('increaseBoldDebt(uint256)', ['0x64'])
const tx = await mockBorrowerOperations.forward(activePool.address, increaseBoldDebtData)
assert.isTrue(tx.receipt.status)
const recordedLUSD_balanceAfter = await activePool.getBoldDebt()
assert.equal(recordedLUSD_balanceAfter, 100)
const recordedBold_balanceAfter = await activePool.getBoldDebt()
assert.equal(recordedBold_balanceAfter, 100)
})
// Decrease
it('decreaseBoldDebt(): decreases the recorded LUSD balance by the correct amount', async () => {
it('decreaseBoldDebt(): decreases the recorded BOLD balance by the correct amount', async () => {
// start the pool on 100 wei
//await activePool.increaseBoldDebt(100, { from: mockBorrowerOperationsAddress })
const increaseBoldDebtData = th.getTransactionData('increaseBoldDebt(uint256)', ['0x64'])
const tx1 = await mockBorrowerOperations.forward(activePool.address, increaseBoldDebtData)
assert.isTrue(tx1.receipt.status)

const recordedLUSD_balanceBefore = await activePool.getBoldDebt()
assert.equal(recordedLUSD_balanceBefore, 100)
const recordedBold_balanceBefore = await activePool.getBoldDebt()
assert.equal(recordedBold_balanceBefore, 100)

//await activePool.decreaseBoldDebt(100, { from: mockBorrowerOperationsAddress })
const decreaseBoldDebtData = th.getTransactionData('decreaseBoldDebt(uint256)', ['0x64'])
const tx2 = await mockBorrowerOperations.forward(activePool.address, decreaseBoldDebtData)
assert.isTrue(tx2.receipt.status)
const recordedLUSD_balanceAfter = await activePool.getBoldDebt()
assert.equal(recordedLUSD_balanceAfter, 0)
const recordedBold_balanceAfter = await activePool.getBoldDebt()
assert.equal(recordedBold_balanceAfter, 0)
})

// send raw ether
Expand Down Expand Up @@ -131,46 +131,46 @@ contract('DefaultPool', async accounts => {
await defaultPool.setAddresses(mockTroveManager.address, mockActivePool.address)
})

it('getETH(): gets the recorded LUSD balance', async () => {
it('getETH(): gets the recorded BOLD balance', async () => {
const recordedETHBalance = await defaultPool.getETH()
assert.equal(recordedETHBalance, 0)
})

it('getBoldDebt(): gets the recorded LUSD balance', async () => {
it('getBoldDebt(): gets the recorded BOLD balance', async () => {
const recordedETHBalance = await defaultPool.getBoldDebt()
assert.equal(recordedETHBalance, 0)
})

it('increaseBold(): increases the recorded LUSD balance by the correct amount', async () => {
const recordedLUSD_balanceBefore = await defaultPool.getBoldDebt()
assert.equal(recordedLUSD_balanceBefore, 0)
it('increaseBold(): increases the recorded BOLD balance by the correct amount', async () => {
const recordedBold_balanceBefore = await defaultPool.getBoldDebt()
assert.equal(recordedBold_balanceBefore, 0)

// await defaultPool.increaseBoldDebt(100, { from: mockTroveManagerAddress })
const increaseBoldDebtData = th.getTransactionData('increaseBoldDebt(uint256)', ['0x64'])
const tx = await mockTroveManager.forward(defaultPool.address, increaseBoldDebtData)
assert.isTrue(tx.receipt.status)

const recordedLUSD_balanceAfter = await defaultPool.getBoldDebt()
assert.equal(recordedLUSD_balanceAfter, 100)
const recordedBold_balanceAfter = await defaultPool.getBoldDebt()
assert.equal(recordedBold_balanceAfter, 100)
})

it('decreaseBold(): decreases the recorded LUSD balance by the correct amount', async () => {
it('decreaseBold(): decreases the recorded BOLD balance by the correct amount', async () => {
// start the pool on 100 wei
//await defaultPool.increaseBoldDebt(100, { from: mockTroveManagerAddress })
const increaseBoldDebtData = th.getTransactionData('increaseBoldDebt(uint256)', ['0x64'])
const tx1 = await mockTroveManager.forward(defaultPool.address, increaseBoldDebtData)
assert.isTrue(tx1.receipt.status)

const recordedLUSD_balanceBefore = await defaultPool.getBoldDebt()
assert.equal(recordedLUSD_balanceBefore, 100)
const recordedBold_balanceBefore = await defaultPool.getBoldDebt()
assert.equal(recordedBold_balanceBefore, 100)

// await defaultPool.decreaseBoldDebt(100, { from: mockTroveManagerAddress })
const decreaseBoldDebtData = th.getTransactionData('decreaseBoldDebt(uint256)', ['0x64'])
const tx2 = await mockTroveManager.forward(defaultPool.address, decreaseBoldDebtData)
assert.isTrue(tx2.receipt.status)

const recordedLUSD_balanceAfter = await defaultPool.getBoldDebt()
assert.equal(recordedLUSD_balanceAfter, 0)
const recordedBold_balanceAfter = await defaultPool.getBoldDebt()
assert.equal(recordedBold_balanceAfter, 0)
})

// send raw ether
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ contract(
} = await setup();

const spEthBefore = await stabilityPool.getETH();
const spLusdBefore = await stabilityPool.getTotalBoldDeposits();
const spBoldBefore = await stabilityPool.getTotalBoldDeposits();

const tx = await troveManager.batchLiquidateTroves([alice, carol]);

Expand All @@ -170,7 +170,7 @@ contract(
assert.equal((await troveManager.Troves(carol))[3], "3");

const spEthAfter = await stabilityPool.getETH();
const spLusdAfter = await stabilityPool.getTotalBoldDeposits();
const spBoldAfter = await stabilityPool.getTotalBoldDeposits();

// liquidate collaterals with the gas compensation fee subtracted
const expectedCollateralLiquidatedA = th.applyLiquidationFee(
Expand All @@ -186,15 +186,15 @@ contract(
.sub(spEthBefore)
.mul(price)
.div(mv._1e18BN)
.sub(spLusdBefore.sub(spLusdAfter));
.sub(spBoldBefore.sub(spBoldAfter));

assert.equal(
spEthAfter.sub(spEthBefore).toString(),
expectedCollateralLiquidatedA.toString(),
"Stability Pool ETH doesn’t match"
);
assert.equal(
spLusdBefore.sub(spLusdAfter).toString(),
spBoldBefore.sub(spBoldAfter).toString(),
A_totalDebt.toString(),
"Stability Pool Bold doesn’t match"
);
Expand Down

0 comments on commit ac1e4d0

Please sign in to comment.