From 45b4d314923dced0f01cc19be90fed2b2da79797 Mon Sep 17 00:00:00 2001 From: nmlinaric Date: Mon, 8 Jul 2024 16:50:12 +0200 Subject: [PATCH] add btc deposit data helper func --- test/adapters/native/decimalConversion.js | 5 +---- test/adapters/native/deposit.js | 5 +---- test/helpers.js | 11 +++++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/adapters/native/decimalConversion.js b/test/adapters/native/decimalConversion.js index 1af17d18..ba8d2bd9 100644 --- a/test/adapters/native/decimalConversion.js +++ b/test/adapters/native/decimalConversion.js @@ -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] diff --git a/test/adapters/native/deposit.js b/test/adapters/native/deposit.js index aac43778..76bc8f32 100644 --- a/test/adapters/native/deposit.js +++ b/test/adapters/native/deposit.js @@ -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 ( diff --git a/test/helpers.js b/test/helpers.js index fb8e5202..a55a9720 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -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); @@ -401,6 +411,7 @@ module.exports = { createERC1155DepositProposalData, createERC1155WithdrawData, createGmpDepositData, + createBtcDepositData, constructGenericHandlerSetResourceData, createERC721DepositProposalData, createResourceID,