Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
Truffle test not changing/saving smart contract variables

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;
}
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!