How can I test sending Ether to a contract with a `payable` function?

Viewed 1391

I am writing Hardhat tests for a Solidity contract I've written. The contract contains a receive() external payable { ... } function. How can I call this from a test with an Ether amount?

1 Answers
const params = [{
        from: sender,
        to: contractAddress,
        value: ethers.utils.parseEther("1") // 1 ether
}];

const transactionHash = await provider.send('eth_sendTransaction', params)
Related