I have 2 functions
function startBuilding ()
public
{
uint[8] memory _buildingInfo;
_buildingInfo[1] = uint32(block.timestamp) + 2 minutes;
addBuilding(_buildingInfo);
}
function finishBuilding ()
public
{
uint[8] memory _buildingInfo;
require (buildingInfo[1] <= block.timestamp);
buildingInfo[6] = STATUS_NEW;
}
Truffle Test
it("Function 'Building' work", async function() {
await buildingContract.startBuilding();
// Here you need to rewind time ahead by 2 minutes
await buildingContract.finishBuilding();
});
How to rewind time ahead by 2 minutes
to get tested require (buildingInfo [1] <= block.timestamp)
???
sleep()
- will not work, because the test will be done for a very long time, because there are a lot of smart contracts likerequire