PatrickAlphaC / hardhat-fund-me-fcc

82 stars 184 forks source link

Staging test fails when running yarn hardhat test --network rinkeby #43

Closed Vesloo closed 2 years ago

Vesloo commented 2 years ago

I copied the code from this repo (test/staging/FundMe.staging.test.js) but it doesn't work, this is the error I get:

AssertionError: expected '60000000000000000' to equal '0'

It looks like there is an issue with the endingFundMeBalance variable but I don't know what. Did someone has the same issue ?

mehedi-iitdu commented 2 years ago

Yes I faced the similar issue. Don't worry about it. There are some mistakes in staging tests. I already fixed that and created a pull request for typescript branch. You can check https://github.com/mehedi-iitdu/hardhat-fund-me-fcc

JIC1816 commented 2 years ago

Yes I faced the similar issue. Don't worry about it. There are some mistakes in staging tests. I already fixed that and created a pull request for typescript branch. You can check https://github.com/mehedi-iitdu/hardhat-fund-me-fcc

I've made both changes that you proposed: added Gas Limit parameter in the withdraw call and added the gas key in hardhat.config.

It worked! Thanks!

byte14 commented 2 years ago

I copied the code from this repo (test/staging/FundMe.staging.test.js) but it doesn't work, this is the error I get:

AssertionError: expected '60000000000000000' to equal '0'

It looks like there is an issue with the endingFundMeBalance variable but I don't know what. Did someone has the same issue ?

It's likely because your fund transaction gets executed but withdraw transaction failed, so you end up having some ether in your fundMe contract, which is not equal to 0.

I fixed this issue by waiting for one block confirmation after executing the transaction

const fundTxResponse = await fundMe.fund({ value: sendValue });
await fundTxResponse.wait(1);
const withdrawTxResponse = await fundMe.withdraw();
await withdrawTxResponse.wait(1);