Hi whenever I test in truffle and I call a function that should change a variables value inside the contract and then try and access this value, the value does not change. Below I have code to try and debug this issue for another project. The function works perfectly in remix
On my end I call increaseIterator() and then console.log the value and it is still 0. In remix the value would increase to 1. Please help
Test:
const Test = artifacts.require("testing");
const { expectRevert } = require("@openzeppelin/test-helpers");
const { web3 } = require("@openzeppelin/test-helpers/src/setup");
contract('testing', (accounts) => {
let testing
beforeEach (async() => {
testing = await Test.new();
await web3.eth.sendTransaction({from: accounts[0], to: accounts[1], value: 1000})
})
it('should increase', async() => {
const beforeIncrease = await testing.returnIterator();
console.log("before increase: " + beforeIncrease);
testing.send.increaseIterator();
const afterIncrease = await testing.returnIterator();
console.log("after increase: " + afterIncrease);
})
})
Smart contract:
pragma solidity 0.8.14;
contract testing {
uint iterator;
constructor () {
iterator = 0;
}
function increaseIterator() public {
iterator++;
}
function returnIterator() public view returns (uint) {
return iterator;
}
}