Skip to content

Commit

Permalink
add btc deposit data helper func
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlinaric committed Jul 8, 2024
1 parent 2210e68 commit 45b4d31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 1 addition & 4 deletions test/adapters/native/decimalConversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ contract("Bridge - [decimal conversion - native token]", async (accounts) => {
const convertedTransferAmount = Ethers.utils.parseEther("0.9");

const AbiCoder = new Ethers.utils.AbiCoder();
const expectedDepositData = Ethers.utils.solidityPack(
["uint256", "uint256", "string"],
[transferredAmount, btcRecipientAddress.length, btcRecipientAddress]
);
const expectedDepositData = Helpers.createBtcDepositData(transferredAmount, btcRecipientAddress);
const expectedHandlerResponse = AbiCoder.encode(
["uint256"],
[convertedTransferAmount]
Expand Down
5 changes: 1 addition & 4 deletions test/adapters/native/deposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ contract("Bridge - [deposit - native token]", async (accounts) => {
depositTx.tx
);

const depositData = Ethers.utils.solidityPack(
["uint256", "uint256", "string"],
[transferredAmount, btcRecipientAddress.length, btcRecipientAddress]
);
const depositData = Helpers.createBtcDepositData(transferredAmount, btcRecipientAddress);

TruffleAssert.eventEmitted(internalTx, "Deposit", (event) => {
return (
Expand Down
11 changes: 11 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ const createERC721DepositProposalData = (
); // metaData (?? bytes)
};

const createBtcDepositData = (
transferAmount,
btcRecipientAddress
) => {
return Ethers.utils.solidityPack(
["uint256", "uint256", "string"],
[transferAmount, btcRecipientAddress.length, btcRecipientAddress]
)
}

const advanceBlock = () => {
const provider = new Ethers.providers.JsonRpcProvider();
const time = Math.floor(Date.now() / 1000);
Expand Down Expand Up @@ -401,6 +411,7 @@ module.exports = {
createERC1155DepositProposalData,
createERC1155WithdrawData,
createGmpDepositData,
createBtcDepositData,
constructGenericHandlerSetResourceData,
createERC721DepositProposalData,
createResourceID,
Expand Down

0 comments on commit 45b4d31

Please sign in to comment.