Day 127
Debugging my previously created DAO was super satisfying and is a skill I want to refine even further. So Iβve decided to revisit previous projects with the intention to further refine them and build a more comprehensive testing suite (in between audits ofc!).
The first project I will be starting with is my Defi Stablecoin. The failed testing results are as follows (you can see that of my 6 tests, 4 fail):
Ran 6 tests for test/unit/DSCEngineTest.t.sol:DSCEngineTest
[FAIL. Reason: assertion failed] testCanDepositCollateralAndGetAccountInfo() (gas: 133857)
Logs:
Error: a == b not satisfied [uint]
Left: 2000000000000000000000000000000
Right: 0
Traces:
[10556084] DSCEngineTest::setUp()
ββ [4763996] β new DeployDSC@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
β ββ β [Return] 23571 bytes of code
ββ [5591843] DeployDSC::run()
β ββ [3752859] β new HelperConfig@0x104fBc016F4bb334D775a19E8A6510109AC63E00
β β ββ [0] VM::startBroadcast()
β β β ββ β [Return]
β β ββ [372255] β new MockV3Aggregator@0x90193C961A926261B756D1E5bb255e67ff9498A1
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [372255] β new MockV3Aggregator@0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [0] VM::stopBroadcast()
β β β ββ β [Return]
β β ββ β [Return] 6893 bytes of code
β ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
β ββ [0] VM::startBroadcast(<pk>)
β β ββ β [Return]
β ββ [749823] β new DecentralisedStableCoin@0x5FbDB2315678afecb367f032d93F642f64180aa3
β β ββ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
β β ββ β [Return] 3401 bytes of code
β ββ [848361] β new DSCEngine@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
β β ββ β [Return] 3559 bytes of code
β ββ [2446] DecentralisedStableCoin::transferOwnership(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ emit OwnershipTransferred(previousOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, newOwner: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ β [Stop]
β ββ [0] VM::stopBroadcast()
β β ββ β [Return]
β ββ β [Return] DecentralisedStableCoin: [0x5FbDB2315678afecb367f032d93F642f64180aa3], DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], HelperConfig: [0x104fBc016F4bb334D775a19E8A6510109AC63E00]
ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
ββ [24728] ERC20Mock::mint(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], 10000000000000000000 [1e19])
β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 10000000000000000000 [1e19])
β ββ β [Stop]
ββ β [Stop]
[133857] DSCEngineTest::testCanDepositCollateralAndGetAccountInfo()
ββ [0] VM::startPrank(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
β ββ β [Return]
ββ [24651] ERC20Mock::approve(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], 10000000000000000000 [1e19])
β ββ emit Approval(owner: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], spender: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], value: 10000000000000000000 [1e19])
β ββ β [Return] true
ββ [65083] DSCEngine::depositCollateral(ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 10000000000000000000 [1e19])
β ββ emit CollateralDeposited(user: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], token: ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], amount: 10000000000000000000 [1e19])
β ββ [32489] ERC20Mock::transferFrom(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], 10000000000000000000 [1e19])
β β ββ emit Approval(owner: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], spender: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], value: 0)
β β ββ emit Transfer(from: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], to: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], value: 10000000000000000000 [1e19])
β β ββ β [Return] true
β ββ β [Stop]
ββ [0] VM::stopPrank()
β ββ β [Return]
ββ [39797] DSCEngine::getAccountInformation(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D]) [staticcall]
β ββ [8993] MockV3Aggregator::latestRoundData() [staticcall]
β β ββ β [Return] 1, 200000000000 [2e11], 1, 1, 1
β ββ [8993] MockV3Aggregator::latestRoundData() [staticcall]
β β ββ β [Return] 1, 100000000000 [1e11], 1, 1, 1
β ββ β [Return] 0, 2000000000000000000000000000000 [2e30]
ββ [2457] DSCEngine::getTokenAmountFromUsd(ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 2000000000000000000000000000000 [2e30]) [staticcall]
β ββ [993] MockV3Aggregator::latestRoundData() [staticcall]
β β ββ β [Return] 1, 200000000000 [2e11], 1, 1, 1
β ββ β [Return] 0
ββ emit log(val: "Error: a == b not satisfied [uint]")
ββ emit log_named_uint(key: " Left", val: 2000000000000000000000000000000 [2e30])
ββ emit log_named_uint(key: " Right", val: 0)
ββ [0] VM::store(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 0x6661696c65640000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000001)
β ββ β [Return]
ββ β [Stop]
[FAIL. Reason: assertion failed] testGetTokenAmountFromUsd() (gas: 36910)
Logs:
Error: a == b not satisfied [uint]
Left: 0
Right: 50000000000000000
Traces:
[10556084] DSCEngineTest::setUp()
ββ [4763996] β new DeployDSC@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
β ββ β [Return] 23571 bytes of code
ββ [5591843] DeployDSC::run()
β ββ [3752859] β new HelperConfig@0x104fBc016F4bb334D775a19E8A6510109AC63E00
β β ββ [0] VM::startBroadcast()
β β β ββ β [Return]
β β ββ [372255] β new MockV3Aggregator@0x90193C961A926261B756D1E5bb255e67ff9498A1
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [372255] β new MockV3Aggregator@0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [0] VM::stopBroadcast()
β β β ββ β [Return]
β β ββ β [Return] 6893 bytes of code
β ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
β ββ [0] VM::startBroadcast(<pk>)
β β ββ β [Return]
β ββ [749823] β new DecentralisedStableCoin@0x5FbDB2315678afecb367f032d93F642f64180aa3
β β ββ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
β β ββ β [Return] 3401 bytes of code
β ββ [848361] β new DSCEngine@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
β β ββ β [Return] 3559 bytes of code
β ββ [2446] DecentralisedStableCoin::transferOwnership(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ emit OwnershipTransferred(previousOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, newOwner: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ β [Stop]
β ββ [0] VM::stopBroadcast()
β β ββ β [Return]
β ββ β [Return] DecentralisedStableCoin: [0x5FbDB2315678afecb367f032d93F642f64180aa3], DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], HelperConfig: [0x104fBc016F4bb334D775a19E8A6510109AC63E00]
ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
ββ [24728] ERC20Mock::mint(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], 10000000000000000000 [1e19])
β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 10000000000000000000 [1e19])
β ββ β [Stop]
ββ β [Stop]
[36910] DSCEngineTest::testGetTokenAmountFromUsd()
ββ [14957] DSCEngine::getTokenAmountFromUsd(ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 100000000000000000000 [1e20]) [staticcall]
β ββ [8993] MockV3Aggregator::latestRoundData() [staticcall]
β β ββ β [Return] 1, 200000000000 [2e11], 1, 1, 1
β ββ β [Return] 0
ββ emit log(val: "Error: a == b not satisfied [uint]")
ββ emit log_named_uint(key: " Left", val: 0)
ββ emit log_named_uint(key: " Right", val: 50000000000000000 [5e16])
ββ [0] VM::store(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 0x6661696c65640000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000001)
β ββ β [Return]
ββ β [Stop]
[FAIL. Reason: assertion failed] testGetUsdValue() (gas: 36998)
Logs:
Error: a == b not satisfied [uint]
Left: 30000000000000000000000
Right: 3000000000000000000000000000000
Traces:
[10556084] DSCEngineTest::setUp()
ββ [4763996] β new DeployDSC@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
β ββ β [Return] 23571 bytes of code
ββ [5591843] DeployDSC::run()
β ββ [3752859] β new HelperConfig@0x104fBc016F4bb334D775a19E8A6510109AC63E00
β β ββ [0] VM::startBroadcast()
β β β ββ β [Return]
β β ββ [372255] β new MockV3Aggregator@0x90193C961A926261B756D1E5bb255e67ff9498A1
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [372255] β new MockV3Aggregator@0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [0] VM::stopBroadcast()
β β β ββ β [Return]
β β ββ β [Return] 6893 bytes of code
β ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
β ββ [0] VM::startBroadcast(<pk>)
β β ββ β [Return]
β ββ [749823] β new DecentralisedStableCoin@0x5FbDB2315678afecb367f032d93F642f64180aa3
β β ββ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
β β ββ β [Return] 3401 bytes of code
β ββ [848361] β new DSCEngine@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
β β ββ β [Return] 3559 bytes of code
β ββ [2446] DecentralisedStableCoin::transferOwnership(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ emit OwnershipTransferred(previousOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, newOwner: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ β [Stop]
β ββ [0] VM::stopBroadcast()
β β ββ β [Return]
β ββ β [Return] DecentralisedStableCoin: [0x5FbDB2315678afecb367f032d93F642f64180aa3], DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], HelperConfig: [0x104fBc016F4bb334D775a19E8A6510109AC63E00]
ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
ββ [24728] ERC20Mock::mint(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], 10000000000000000000 [1e19])
β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 10000000000000000000 [1e19])
β ββ β [Stop]
ββ β [Stop]
[36998] DSCEngineTest::testGetUsdValue()
ββ [15011] DSCEngine::getUsdValue(ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 15000000000000000000 [1.5e19]) [staticcall]
β ββ [8993] MockV3Aggregator::latestRoundData() [staticcall]
β β ββ β [Return] 1, 200000000000 [2e11], 1, 1, 1
β ββ β [Return] 3000000000000000000000000000000 [3e30]
ββ emit log(val: "Error: a == b not satisfied [uint]")
ββ emit log_named_uint(key: " Left", val: 30000000000000000000000 [3e22])
ββ emit log_named_uint(key: " Right", val: 3000000000000000000000000000000 [3e30])
ββ [0] VM::store(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 0x6661696c65640000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000001)
β ββ β [Return]
ββ β [Stop]
[PASS] testRevertsIfCollateralZero() (gas: 41386)
Traces:
[10556084] DSCEngineTest::setUp()
ββ [4763996] β new DeployDSC@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
β ββ β [Return] 23571 bytes of code
ββ [5591843] DeployDSC::run()
β ββ [3752859] β new HelperConfig@0x104fBc016F4bb334D775a19E8A6510109AC63E00
β β ββ [0] VM::startBroadcast()
β β β ββ β [Return]
β β ββ [372255] β new MockV3Aggregator@0x90193C961A926261B756D1E5bb255e67ff9498A1
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [372255] β new MockV3Aggregator@0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [0] VM::stopBroadcast()
β β β ββ β [Return]
β β ββ β [Return] 6893 bytes of code
β ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
β ββ [0] VM::startBroadcast(<pk>)
β β ββ β [Return]
β ββ [749823] β new DecentralisedStableCoin@0x5FbDB2315678afecb367f032d93F642f64180aa3
β β ββ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
β β ββ β [Return] 3401 bytes of code
β ββ [848361] β new DSCEngine@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
β β ββ β [Return] 3559 bytes of code
β ββ [2446] DecentralisedStableCoin::transferOwnership(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ emit OwnershipTransferred(previousOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, newOwner: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ β [Stop]
β ββ [0] VM::stopBroadcast()
β β ββ β [Return]
β ββ β [Return] DecentralisedStableCoin: [0x5FbDB2315678afecb367f032d93F642f64180aa3], DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], HelperConfig: [0x104fBc016F4bb334D775a19E8A6510109AC63E00]
ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
ββ [24728] ERC20Mock::mint(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], 10000000000000000000 [1e19])
β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 10000000000000000000 [1e19])
β ββ β [Stop]
ββ β [Stop]
[41386] DSCEngineTest::testRevertsIfCollateralZero()
ββ [0] VM::startPrank(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
β ββ β [Return]
ββ [24651] ERC20Mock::approve(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], 10000000000000000000 [1e19])
β ββ emit Approval(owner: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], spender: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], value: 10000000000000000000 [1e19])
β ββ β [Return] true
ββ [0] VM::expectRevert(DSCEngine__MustBeMoreThanZero())
β ββ β [Return]
ββ [479] DSCEngine::depositCollateral(ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], 0)
β ββ β [Revert] DSCEngine__MustBeMoreThanZero()
ββ [0] VM::stopPrank()
β ββ β [Return]
ββ β [Stop]
[PASS] testRevertsIfTokenLengthDoesntMatchPriceFeeds() (gas: 180444)
Traces:
[10556084] DSCEngineTest::setUp()
ββ [4763996] β new DeployDSC@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
β ββ β [Return] 23571 bytes of code
ββ [5591843] DeployDSC::run()
β ββ [3752859] β new HelperConfig@0x104fBc016F4bb334D775a19E8A6510109AC63E00
β β ββ [0] VM::startBroadcast()
β β β ββ β [Return]
β β ββ [372255] β new MockV3Aggregator@0x90193C961A926261B756D1E5bb255e67ff9498A1
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [372255] β new MockV3Aggregator@0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [0] VM::stopBroadcast()
β β β ββ β [Return]
β β ββ β [Return] 6893 bytes of code
β ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
β ββ [0] VM::startBroadcast(<pk>)
β β ββ β [Return]
β ββ [749823] β new DecentralisedStableCoin@0x5FbDB2315678afecb367f032d93F642f64180aa3
β β ββ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
β β ββ β [Return] 3401 bytes of code
β ββ [848361] β new DSCEngine@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
β β ββ β [Return] 3559 bytes of code
β ββ [2446] DecentralisedStableCoin::transferOwnership(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ emit OwnershipTransferred(previousOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, newOwner: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ β [Stop]
β ββ [0] VM::stopBroadcast()
β β ββ β [Return]
β ββ β [Return] DecentralisedStableCoin: [0x5FbDB2315678afecb367f032d93F642f64180aa3], DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], HelperConfig: [0x104fBc016F4bb334D775a19E8A6510109AC63E00]
ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
ββ [24728] ERC20Mock::mint(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], 10000000000000000000 [1e19])
β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 10000000000000000000 [1e19])
β ββ β [Stop]
ββ β [Stop]
[180444] DSCEngineTest::testRevertsIfTokenLengthDoesntMatchPriceFeeds()
ββ [0] VM::expectRevert(DSCEngine__TokenAddressesAndPriceFeedAddressesMustBeSameLength())
β ββ β [Return]
ββ [23720] β new <unknown>@0x2e234DAe75C793f67A35089C9d99245E1C58470b
β ββ β [Revert] 4 bytes of code
ββ β [Stop]
[FAIL. Reason: Error != expected error: 0xa802cfbe != 0xa802cfbe0000000000000000000000002e234dae75c793f67a35089c9d99245e1c58470b] testRevertsWithUnapprovedCollateral() (gas: 705829)
Traces:
[10556084] DSCEngineTest::setUp()
ββ [4763996] β new DeployDSC@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
β ββ β [Return] 23571 bytes of code
ββ [5591843] DeployDSC::run()
β ββ [3752859] β new HelperConfig@0x104fBc016F4bb334D775a19E8A6510109AC63E00
β β ββ [0] VM::startBroadcast()
β β β ββ β [Return]
β β ββ [372255] β new MockV3Aggregator@0x90193C961A926261B756D1E5bb255e67ff9498A1
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [372255] β new MockV3Aggregator@0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3
β β β ββ β [Return] 1082 bytes of code
β β ββ [658696] β new ERC20Mock@0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76
β β β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: DeployDSC: [0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f], value: 100000000000 [1e11])
β β β ββ β [Return] 2828 bytes of code
β β ββ [0] VM::stopBroadcast()
β β β ββ β [Return]
β β ββ β [Return] 6893 bytes of code
β ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
β ββ [0] VM::startBroadcast(<pk>)
β β ββ β [Return]
β ββ [749823] β new DecentralisedStableCoin@0x5FbDB2315678afecb367f032d93F642f64180aa3
β β ββ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)
β β ββ β [Return] 3401 bytes of code
β ββ [848361] β new DSCEngine@0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
β β ββ β [Return] 3559 bytes of code
β ββ [2446] DecentralisedStableCoin::transferOwnership(DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ emit OwnershipTransferred(previousOwner: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266, newOwner: DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512])
β β ββ β [Stop]
β ββ [0] VM::stopBroadcast()
β β ββ β [Return]
β ββ β [Return] DecentralisedStableCoin: [0x5FbDB2315678afecb367f032d93F642f64180aa3], DSCEngine: [0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512], HelperConfig: [0x104fBc016F4bb334D775a19E8A6510109AC63E00]
ββ [934] HelperConfig::activeNetworkConfig() [staticcall]
β ββ β [Return] MockV3Aggregator: [0x90193C961A926261B756D1E5bb255e67ff9498A1], MockV3Aggregator: [0xBb2180ebd78ce97360503434eD37fcf4a1Df61c3], ERC20Mock: [0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496], ERC20Mock: [0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76], 77814517325470205911140941194401928579557062014761831930645393041380819009408 [7.781e76]
ββ [24728] ERC20Mock::mint(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], 10000000000000000000 [1e19])
β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 10000000000000000000 [1e19])
β ββ β [Stop]
ββ β [Stop]
[705829] DSCEngineTest::testRevertsWithUnapprovedCollateral()
ββ [658696] β new ERC20Mock@0x2e234DAe75C793f67A35089C9d99245E1C58470b
β ββ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D], value: 10000000000000000000 [1e19])
β ββ β [Return] 2828 bytes of code
ββ [0] VM::startPrank(user: [0x6CA6d1e2D5347Bfab1d91e883F1915560e09129D])
β ββ β [Return]
ββ [0] VM::expectRevert(DSCEngine__NotAllowedToken())
β ββ β [Return]
ββ [2695] DSCEngine::depositCollateral(ERC20Mock: [0x2e234DAe75C793f67A35089C9d99245E1C58470b], 10000000000000000000 [1e19])
β ββ β [Revert] DSCEngine__NotAllowedToken()
ββ β [Revert] Error != expected error: 0xa802cfbe != 0xa802cfbe0000000000000000000000002e234dae75c793f67a35089c9d99245e1c58470b
Suite result: FAILED. 2 passed; 4 failed; 0 skipped; finished in 1.80ms (1.16ms CPU time)
I donβt want to spoil the fun so I am going to be spending my Sunday debugging and informing others of the results. If people want to call out issues they can see, do feel free.
The issues that are immediately obvious to me are:
- In
testGetTokenAmountFromUsd
there is a mismatch between the amountWeth
variable and the expectedWeth
variable, likely attributable to the logic contained in setup
;
- In
testRevertsWithUnapprovedCollateral
it would appear that those with unapproved collateral can actually interact with the contract. I suspect this is an issue inherent from the core logic relating to depositCollateral
; and
- my fuzz test that tests the invariants of the contract, does not appear to have the required amount of Eth to execute the transaction.