help me to solve this error "EvmError: OutOfFund" in foundry #5575
Unanswered
vishwa7dcap786
asked this question in
Help
Replies: 1 comment
-
Actually we need some initial USER balance as we need an USER for transactions to sign & send... Cheatcode:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
**this is the contract **
// SPDX-Lisence-Identifier: MIT
pragma solidity 0.8.20;
import {ReentrancyGuard} from "@openzeppelin-contracts/security/ReentrancyGuard.sol";
contract sampleContract is ReentrancyGuard {
//Errors
}
this is the unit test
// SPDX-Lisence-Identifier
pragma solidity 0.8.20;
import {Test, console} from "forge-std/Test.sol";
import {DeploySample} from "./../script/DeploySample.s.sol";
import {sampleContract} from "./../src/sampleContract.sol";
contract sampleTest is Test {
DeploySample Deployer;
sampleContract sample;
address public constant USER = address(3);
}
error
Running 1 test for test/sampleTest.sol:sampleTest
[FAIL. Reason: Assertion failed.] testdeposit() (gas: 80402)
Logs:
0
Error: a == b not satisfied [uint]
Left: 0
Right: 1
Traces:
[1208181] sampleTest::setUp()
├─ [610263] → new DeploySample@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
│ └─ ← 2827 bytes of code
├─ [520373] DeploySample::run()
│ ├─ [0] VM::startBroadcast()
│ │ └─ ← ()
│ ├─ [484405] → new sampleContract@0x90193C961A926261B756D1E5bb255e67ff9498A1
│ │ └─ ← 2309 bytes of code
│ ├─ [0] VM::stopBroadcast()
│ │ └─ ← ()
│ └─ ← sampleContract: [0x90193C961A926261B756D1E5bb255e67ff9498A1]
└─ ← ()
[80402] sampleTest::testdeposit()
├─ [0] VM::startPrank(0x0000000000000000000000000000000000000003)
│ └─ ← ()
├─ [0] console::f5b1bba9(0000000000000000000000000000000000000000000000000000000000000000) [staticcall]
│ └─ ← ()
├─ [46057] sampleContract::storeYourSecretKey(secret, abcd)
│ └─ ← ()
├─ [0] sampleContract::depositAmount{value: 1}(secret)
│ └─ ← "EvmError: OutOfFund"
├─ [0] VM::stopPrank()
│ └─ ← ()
├─ [2569] sampleContract::getUserBalance(0x0000000000000000000000000000000000000003) [staticcall]
│ └─ ← 0
├─ emit log(: Error: a == b not satisfied [uint])
├─ emit log_named_uint(key: Left, val: 0)
├─ emit log_named_uint(key: Right, val: 1)
├─ [0] VM::store(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 0x6661696c65640000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000001)
│ └─ ← ()
└─ ← ()
Test result: FAILED. 0 passed; 1 failed; finished in 5.28ms
Failing tests:
Encountered 1 failing test in test/sampleTest.sol:sampleTest
[FAIL. Reason: Assertion failed.] testdeposit() (gas: 80402)
Encountered a total of 1 failing tests, 0 tests succeeded
i have tried to log the balance of the USER address . it logs out as zero amount.
how to solve this issue
Beta Was this translation helpful? Give feedback.
All reactions