[ethereum] solidityでtax計算

Practice.sol

contract Practice {

	function hello() external pure returns(string memory) {
		return "Hello, World!";
	}

	function tax(uint256 price) public pure returns(uint256 newPrice){
		 newPrice = price * 11 / 10;
		 return newPrice;
	}
}

practice_test.js

	describe("practice()", () => {
		it("returns tax in price", async() => {
			const practice = await PracticeContract.deployed();
			const expected = "110";
			const actual = await practice.tax(100);
			assert.equal(actual, expected, "should be 110");
		})
	})

$ truffle test

Compiling your contracts…
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Practice.sol
> Artifacts written to /tmp/test-202209-108928-12xhvrv.xr0d
> Compiled successfully using:
– solc: 0.5.16+commit.9c3226ce.Emscripten.clang

Contract: Practice
✓ has been deployed successfully
practice()
✓ returns ‘Hello, World!’
practice()
✓ returns tax in price

3 passing (123ms)

taxのmultiplyは price * 1.1; とするとエラーになるので、price * 11 / 10;としないといけない。
なるほど、中々激しい。