[ethereum] solidityで配列に格納して、値を返却する

Practice.sol
L 構造体Clientのclientsという配列に格納して、excesise関数でweightを-2として返却するコントラクトです。

pragma solidity >= 0.4.0 < 0.7.0;

contract Practice {

	struct Client {
		string name;
		string gender;
		uint256 weight;
		uint256 height;
	}
	Client[] public clients;

	function register(string memory _name, string memory _gender, uint256 _weight, uint256 _height) public returns(uint256 id) {
		id = clients.push(Client(_name, _gender, _weight, _height)) - 1;
		return id;
	}

	function excesise() public returns (uint256 newWeight){
		newWeight = clients[0].weight - 2;
		return newWeight;
	}

}

practice_test.js

	describe("practice()", () => {
		it("returns excesized weight", async() => {
			const practice = await PracticeContract.deployed();
			const expected = 63;
			await practice.register("yamada", "male", 65, 175);
			const actual = await practice.excesise.call();
			
			assert.equal(actual, expected, "Weight should be 63");
		})
	})

Contract: Practice
✓ has been deployed successfully
practice()
✓ returns weight (124ms)

2 passing (184ms)