为什么我的合同状态没有改变

why is the state of my contract not changing

我正在用 solidity 创建一个学习项目,它是一个基本的智能合约。

我有以下智能合约:

contract SmartContract {
    uint256 public contractProperty = 10;

    function changeProperty(int256 newVal) external {
        contractProperty = uint256(newVal);
    }
}

我是运行下面的测试:

const SmartContract = artifacts.require("SmartContract");

contract('SmartContract', function(accounts) {
    var testInstance;

    it('returns correctly', () => {
        return SmartContract.deployed().then((instance) => {
            testInstance = instance;
        })
        .then(() => {
            testInstance.changeProperty(10000);
        })
        .then(() => {
            return testInstance.contractProperty();
        })
        .then((val) => {
            assert.equal(val.toString(), '10000'.toString());
        });
    });
});

我得到一个错误,预期 10 等于 10000,这意味着合同 属性 没有改变。

我做错了什么?为什么我的智能合约的状态没有改变? (我正在使用坚固的松露和甘纳许 ^0.8)

const SmartContract = artifacts.require('./SmartContract.sol');

require('chai').use(require('chai-as-promised')).should();

contract('SmartContract', function (accounts) {
    var testInstance;

    it('returns correctly', () => {
        return SmartContract.deployed()
            .then((instance) => {
                testInstance = instance;
            })
            .then(() => {
                return testInstance.changeProperty(10000); // return is required
            })
            .then(() => {
                return testInstance.contractProperty(); // return is required
            })
            .then((val) => {
                assert.equal(val.toString(), '10000'.toString());
            });
    });
});

没有{, ..., },我们不需要要求return

contract('SmartContract', function (accounts) {
    var testInstance;

    it('returns correctly', () => {
        return SmartContract.deployed()
            .then((instance) => {
                testInstance = instance;
            })
            .then(() => testInstance.changeProperty(10000))
            .then(() => testInstance.contractProperty())
            .then((val) => {
                assert.equal(val.toString(), '10000'.toString());
            });
    });
});