D:\Truffle Projects\payable>truffle test
Compiling your contracts...
===========================
> Compiling .\contracts\First.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\First.sol
> Compiling .\test\TestFirst.sol
TypeError: Using ".value(...)" is deprecated. Use "{value: ...}" instead.
--> /D/Truffle Projects/payable/test/TestFirst.sol:15:9:
|
15 | meta.receivePayment.value(2 ether)();
| ^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation failed. See above.
Truffle v5.2.4 (core: 5.2.4)
Node v14.16.0
This is my code: First.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
contract First {
function receivePayment() public payable {
}
function checkBalance() public view returns (uint) {
return address(this).balance;
}
}
TestFirst.sol:
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/First.sol";
contract TestFirst {
uint public initialBalance = 10 ether;
function testAge() public {
First meta = First(DeployedAddresses.First());
meta.receivePayment.value(2 ether)();
Assert.equal(meta.checkBalance(), 2 ether, "Value should be equal to 2 ether");
}
}