Variable in Smart contract in ganache is not updated
Truffle Ticket #702341 [Pending] Support Ticket sent from [email protected] in HubSpot - Truffle
All you need to reproduce the Issue is contained in the repo:
https://github.com/pstrotmann/SimpleStorage
I would expect storedData = 17 in my smart contract after running simple_storage.js because the assert after calling
// set simpleStorage
await simpleStorageInstance.set.sendTransaction(17, { from: accounts[0] });
simpleStorageInstance.set.sendTransaction(17, {from:accounts[0]});
// Get stored data
const storedData = await simpleStorageInstance.get();
assert.equal(storedData, 17, "The value 17 was not stored.");indicates that 17 is stored in storedData.
Therefore I would expect that the 17 is stored persistent in SimpleStorage contract. But as You see in ganache there is 0.
The 3 steps I performed (see hardcopies in obove repo) were:
truffle deploy (to deploy the contract SimpleStorage, as you see in ganacheTest/console/truffleDeploy.png)
truffle test ./test/simple_storage.js (to test setting storedData = 17 in contract SimpleStorage, as you see in ganacheTest/console/truffleTestSimpleStorageJs.png)
truffle test ./test/simple_storage.sol (to test setting storedData = 18 in contract SimpleStorage, as you see in ganacheTest/console/truffleTestSimpleStorageSol.png)
As you see from the hardcopies deploy and the tests succeeded either.
You also see from the harcopies named worspace... what happened due to deploying and testing on the ganache blockchain on the account, the blocks, transactions and the contract after each of the above steps.
Without the update facility of smart contracts in truffle/ganache testing contracts does not make real sense making truffle/ganache quite worthless.
Source: ConsenSys-archive/truffle