Skip to content

Commit

Permalink
test: create autotest for Accounts tc1854
Browse files Browse the repository at this point in the history
Moved writeFile for multiTransfer down to other writeFile calls
  • Loading branch information
amelnytskyi committed Mar 11, 2024
1 parent 64323ef commit 4e86100
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/integration-tests/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum Buffer {
paymasterTx = "paymasterTx.txt",
addressMultiTransferETH = "multiTransferETH.txt",
txMultiTransferETH = "txMultiTransferETH.txt",
txMultiTransferCall = "txMultiTransferCall.txt",
txMultiTransferCustomTokenI = "txMultiTransferCustomTokenI.txt",
txMultiTransferCustomTokenII = "txMultiTransferCustomTokenII.txt",
addressMultiCallMiddle = "multiCallMiddle.txt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen
const ethTransfer = await makeTransfer(etherAddress, ethers.utils.parseEther("0.101"));
const customToken1Transfer = await makeTransfer(customTokenI, ethers.utils.parseUnits("1", 18));
const customToken2Transfer = await makeTransfer(customTokenII, ethers.utils.parseUnits("1", 18));
const multiTransferResult = await makeMultiTransfer();

async function makeTransfer(token: string, amount: ethers.BigNumber) {
const transfer = await wallet.transfer({
Expand All @@ -54,18 +55,20 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen
}

//call the deployed contract.
const transferFromContract = await attachedContract.multiTransfer(
[richWalletAddress, mainWalletAddress, secondaryWalletAddress],
[etherAddress, customTokenI, customTokenII],
[ethAmount, customTokenIAmount, customTokenIIAmount]
);
if (transferFromContract) {
console.log(`Contract transfer to us!`);
const transferReceipt = await transferFromContract.wait(1);
console.log(`Contract transfer transaction hash: ${transferReceipt.transactionHash}`);
await fs.writeFile(Buffer.txMultiTransferCall, transferReceipt.transactionHash);
} else {
console.error(`Contract said something unexpected: ${transferFromContract}`);
async function makeMultiTransfer() {
const transferFromContract = await attachedContract.multiTransfer(
[richWalletAddress, mainWalletAddress, secondaryWalletAddress],
[etherAddress, customTokenI, customTokenII],
[ethAmount, customTokenIAmount, customTokenIIAmount]
);
if (transferFromContract) {
console.log(`Contract transfer to us!`);
const transferReceipt = await transferFromContract.wait(1);
console.log(`Contract transfer transaction hash: ${transferReceipt.transactionHash}`);
return transferReceipt.transactionHash;
} else {
console.error(`Contract said something unexpected: ${transferFromContract}`);
}
}

// Show the contract balance
Expand Down Expand Up @@ -93,6 +96,7 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen
)}" Custom token II`
);

await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCall, multiTransferResult);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferETH, ethTransfer);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenI, customToken1Transfer);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiTransferCustomTokenII, customToken2Transfer);
Expand Down

0 comments on commit 4e86100

Please sign in to comment.