Hi,
STFB5.sol
pragma solidity ^0.5.3;
contract STFB5 {
function transferToFallback(address payable _to) public payable {
_to.transfer(msg.value); }
function getBalance() public view returns (uint) {
return address(this).balance;
}
constructor () payable public{ }
}
pragma solidity ^0.5.3;
contract F5 {
constructor () payable public {}
function getBalance() public view returns (uint) {
return address(this).balance;
}
}
STFB5_test.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
// This import is automatically injected by Remix
import "remix_tests.sol";
// This import is required to use custom transaction context
// Although it may fail compilation in 'Solidity Compiler' plugin
// But it will work fine in 'Solidity Unit Testing' plugin
import "remix_accounts.sol";
import "./STFB5.sol";
import "./F5.sol"; // File name has to end with '_test.sol',
this file can contain more than one testSuite contracts
contract testSuite {
/// 'beforeAll' runs before all other tests
/// More special functions are: 'beforeEach', 'beforeAll', 'afterEach' & 'afterAll'
F5 obj1;
STFB5 obj2;
function beforeAll() public payable {
uint a = 100;
obj1 = new F5.value(a)();
obj2 = new STFB5.value(a)();
}
function initialValueofObj1ShouldBe100() public returns (bool) {
return Assert.equal(obj1.getBalance(), 100, "initial value is not correct");
}
function initialValueofObj2ShouldBe100() public returns (bool) {
return Assert.equal(obj2.getBalance(), 100, "initial value is not correct"); }
}
I am getting the error:
Gives error:
contracts/STFB5_test.sol:32:19: DeclarationError: Identifier not found or not unique.
obj1 = new F5.value(a)();
^------^
Somebody please guide me how to solve this problem.
Zulfi.