Skip to content

Commit

Permalink
Merge branch 'QA-Test' into pegin-refunds
Browse files Browse the repository at this point in the history
  • Loading branch information
Luisfc68 authored Nov 13, 2024
2 parents 43764e7 + a680ffa commit 5b02f5a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion contracts/LiquidityBridgeContractV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ contract LiquidityBridgeContractV2 is Initializable, OwnableUpgradeable, Reentra
}

(bool sent,) = quote.lpRskAddress.call{
value: quote.value + quote.callFee
value: quote.value + quote.callFee + quote.gasFee
}("");
require(sent, "LBC050");

Expand Down
20 changes: 10 additions & 10 deletions test/basic.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ contract("LiquidityBridgeContractV2.sol", async (accounts) => {
web3.eth.getBalance(instance.address),
]);

const [userPegInBalanceBefore, contractBalanceBefore] = await getBalances();
const [lpBalanceBeforeDeposit, contractBalanceBefore] = await getBalances();

let quote = utils.getTestPegOutQuote(
instance.address, //lbc address
Expand Down Expand Up @@ -1022,14 +1022,14 @@ contract("LiquidityBridgeContractV2.sol", async (accounts) => {
await truffleAssertions.eventEmitted(pegOut, "PegOutDeposit");

const btcTx = await utils.generateRawTx(instance, quote, scriptType);
const [userPegInBalanceAfter, contractBalanceAfter] = await getBalances();
const [lpBalanceAfterDeposit, contractBalanceAfter] = await getBalances();

expect(userPegInBalanceBefore.toString()).to.be.eq(
userPegInBalanceAfter.toString()
expect(lpBalanceBeforeDeposit.toString()).to.be.eq(
lpBalanceAfterDeposit.toString()
);
expect(+contractBalanceAfter).to.be.eq(+contractBalanceBefore + msgValue.toNumber());

const lpBalanceBefore = await web3.eth.getBalance(
const lpBalanceBeforeRefund = await web3.eth.getBalance(
liquidityProviderRskAddress
);
const refund = await instance.refundPegOut(
Expand All @@ -1039,19 +1039,19 @@ contract("LiquidityBridgeContractV2.sol", async (accounts) => {
partialMerkleTree,
merkleBranchHashes
);
const lpBalanceAfter = await web3.eth.getBalance(
const lpBalanceAfterRefund = await web3.eth.getBalance(
liquidityProviderRskAddress
);
const usedInGas = refund.receipt.gasUsed * refund.receipt.effectiveGasPrice;
const refundedAmount = quote.value.add(quote.callFee);
const refundedAmount = quote.value.add(quote.callFee).add(quote.gasFee);
truffleAssertions.eventEmitted(refund, "DaoFeeSent", {
quoteHash: quoteHash,
amount: quote.productFeeAmount
});
expect(lpBalanceAfter).to.be.a.bignumber.eq(
web3.utils.toBN(lpBalanceBefore).add(refundedAmount).sub(web3.utils.toBN(usedInGas))
expect(lpBalanceAfterRefund).to.be.a.bignumber.eq(
web3.utils.toBN(lpBalanceBeforeRefund).add(refundedAmount).sub(web3.utils.toBN(usedInGas))
);
truffleAssertions.eventEmitted(refund, "PegOutRefunded");
truffleAssertions.eventEmitted(refund, "PegOutRefunded", { quoteHash });
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function getTestPegOutQuote(lbcAddress, lpRskAddress, rskRefundAddress, value, b
}

let valueToTransfer = value || web3.utils.toBN(0);
let callFee = web3.utils.toBN(1);
const callFee = web3.utils.toBN(2);
let nonce = 0;
let agreementTimestamp = 1661788988;
let expireDate = Math.round(new Date().getTime() / 1000) + 3600;
Expand All @@ -86,7 +86,7 @@ function getTestPegOutQuote(lbcAddress, lpRskAddress, rskRefundAddress, value, b
let transferConfirmations = 10;
let penaltyFee = web3.utils.toBN(0);
let productFeeAmount = web3.utils.toBN(1);
const gasFee = web3.utils.toBN(1);
const gasFee = web3.utils.toBN(42);

let quote = {
lbcAddress,
Expand Down

0 comments on commit 5b02f5a

Please sign in to comment.