Skip to content

Can anyone help in writing test for receive and fallback Function #6404

Answered by hemant933
nraj07054 asked this question in Q&A
Discussion options

You must be logged in to vote

test script using the popular testing framework in Ethereum development, Truffle.

// Import necessary modules from Truffle and Chai
const { expect } = require('chai');
const FundMe = artifacts.require('FundMe');
const PriceConverter = artifacts.require('PriceConverter'); // Assuming you have a PriceConverter contract

contract('FundMe', (accounts) => {
let fundMeInstance;

before(async () => {
// Deploy the FundMe contract
fundMeInstance = await FundMe.new( /* pass your PriceFeedAddress here */ );
});

it('should receive funds via receive function', async () => {
const initialBalance = await web3.eth.getBalance(fundMeInstance.address);

// Send funds to the contract using the receive function…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nraj07054
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants