From 339f3ad54c9e3dba36ae208cb8642d521b40f810 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 15 Nov 2018 08:49:15 +0100 Subject: [PATCH] constant -> view --- remix-tests/examples/simple_storage2_test.sol | 4 ++-- remix-tests/sol/tests.sol.js | 16 ++++++++-------- .../tests/examples_1/simple_storage_test.sol | 4 ++-- .../tests/examples_2/simple_storage_test.sol | 4 ++-- .../tests/examples_3/simple_string_test.sol | 6 +++--- remix-tests/tests/examples_4/SafeMath_test.sol | 8 ++++---- remix-tests/tests/number/number_test.sol | 16 ++++++++-------- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/remix-tests/examples/simple_storage2_test.sol b/remix-tests/examples/simple_storage2_test.sol index 6c7f953738..d07fa73cfa 100644 --- a/remix-tests/examples/simple_storage2_test.sol +++ b/remix-tests/examples/simple_storage2_test.sol @@ -17,11 +17,11 @@ contract MyTest2 { i += 1; } - function initialValueShouldBe100() public constant returns (bool) { + function initialValueShouldBe100() public view returns (bool) { return Assert.equal(foo.get(), 100, "initial value is not correct"); } - function initialValueShouldBe200() public constant returns (bool) { + function initialValueShouldBe200() public view returns (bool) { return Assert.equal(foo.get(), 200, "initial value is not correct"); } diff --git a/remix-tests/sol/tests.sol.js b/remix-tests/sol/tests.sol.js index ac0c98978a..4a7d2428a1 100644 --- a/remix-tests/sol/tests.sol.js +++ b/remix-tests/sol/tests.sol.js @@ -98,17 +98,17 @@ library Assert { } /*----------------- Greater than --------------------*/ - function greaterThan(uint a, uint b, string message) public constant returns (bool result) { + function greaterThan(uint a, uint b, string message) public view returns (bool result) { result = (a > b); emit AssertionEvent(result, message); } - function greaterThan(int a, int b, string message) public constant returns (bool result) { + function greaterThan(int a, int b, string message) public view returns (bool result) { result = (a > b); emit AssertionEvent(result, message); } // TODO: safely compare between uint and int - function greaterThan(uint a, int b, string message) public constant returns (bool result) { + function greaterThan(uint a, int b, string message) public view returns (bool result) { if(b < int(0)) { // int is negative uint "a" always greater result = true; @@ -117,7 +117,7 @@ library Assert { } emit AssertionEvent(result, message); } - function greaterThan(int a, uint b, string message) public constant returns (bool result) { + function greaterThan(int a, uint b, string message) public view returns (bool result) { if(a < int(0)) { // int is negative uint "b" always greater result = false; @@ -127,17 +127,17 @@ library Assert { emit AssertionEvent(result, message); } /*----------------- Lesser than --------------------*/ - function lesserThan(uint a, uint b, string message) public constant returns (bool result) { + function lesserThan(uint a, uint b, string message) public view returns (bool result) { result = (a < b); emit AssertionEvent(result, message); } - function lesserThan(int a, int b, string message) public constant returns (bool result) { + function lesserThan(int a, int b, string message) public view returns (bool result) { result = (a < b); emit AssertionEvent(result, message); } // TODO: safely compare between uint and int - function lesserThan(uint a, int b, string message) public constant returns (bool result) { + function lesserThan(uint a, int b, string message) public view returns (bool result) { if(b < int(0)) { // int is negative int "b" always lesser result = false; @@ -147,7 +147,7 @@ library Assert { emit AssertionEvent(result, message); } - function lesserThan(int a, uint b, string message) public constant returns (bool result) { + function lesserThan(int a, uint b, string message) public view returns (bool result) { if(a < int(0)) { // int is negative int "a" always lesser result = true; diff --git a/remix-tests/tests/examples_1/simple_storage_test.sol b/remix-tests/tests/examples_1/simple_storage_test.sol index 6c4b35942f..f5f6da99d2 100644 --- a/remix-tests/tests/examples_1/simple_storage_test.sol +++ b/remix-tests/tests/examples_1/simple_storage_test.sol @@ -8,12 +8,12 @@ contract MyTest { foo = new SimpleStorage(); } - function initialValueShouldBe100() public constant returns (bool) { + function initialValueShouldBe100() public view returns (bool) { //return Assert.equal(foo.get(), 100, "initial value is not correct"); return foo.get() == 100; } - function initialValueShouldBe200() public constant returns (bool) { + function initialValueShouldBe200() public view returns (bool) { //return Assert.equal(foo.get(), 200, "initial value is not correct"); return foo.get() == 200; } diff --git a/remix-tests/tests/examples_2/simple_storage_test.sol b/remix-tests/tests/examples_2/simple_storage_test.sol index b794095f5c..ca7d348f11 100644 --- a/remix-tests/tests/examples_2/simple_storage_test.sol +++ b/remix-tests/tests/examples_2/simple_storage_test.sol @@ -13,12 +13,12 @@ contract MyTest { i += 1; } - function initialValueShouldBe100() public constant returns (bool) { + function initialValueShouldBe100() public view returns (bool) { //return Assert.equal(foo.get(), 100, "initial value is not correct"); return foo.get() == 100; } - function initialValueShouldBe200() public constant returns (bool) { + function initialValueShouldBe200() public view returns (bool) { //return Assert.equal(foo.get(), 200, "initial value is not correct"); return foo.get() == 200; } diff --git a/remix-tests/tests/examples_3/simple_string_test.sol b/remix-tests/tests/examples_3/simple_string_test.sol index 918c97c88e..a24ebb2599 100644 --- a/remix-tests/tests/examples_3/simple_string_test.sol +++ b/remix-tests/tests/examples_3/simple_string_test.sol @@ -8,15 +8,15 @@ contract StringTest { foo = new SimpleString(); } - function initialValueShouldBeHello() public constant returns (bool) { + function initialValueShouldBeHello() public view returns (bool) { return Assert.equal(foo.get(), "Hello world!", "initial value is not correct"); } - function valueShouldNotBeHelloWorld() public constant returns (bool) { + function valueShouldNotBeHelloWorld() public viewview returns (bool) { return Assert.notEqual(foo.get(), "Hello wordl!", "initial value is not correct"); } - function valueShouldBeHelloWorld() public constant returns (bool) { + function valueShouldBeHelloWorld() public view returns (bool) { return Assert.equal(foo.get(), "Hello wordl!", "initial value is not correct"); } } diff --git a/remix-tests/tests/examples_4/SafeMath_test.sol b/remix-tests/tests/examples_4/SafeMath_test.sol index 4259e847a3..bf4534c913 100644 --- a/remix-tests/tests/examples_4/SafeMath_test.sol +++ b/remix-tests/tests/examples_4/SafeMath_test.sol @@ -10,7 +10,7 @@ contract SafeMathTest { safemathproxy = new SafeMathProxy(); } - function unsafeMultiplicationShouldOverflow() public constant returns (bool) { + function unsafeMultiplicationShouldOverflow() public view returns (bool) { uint256 a = 4; uint256 b = 2 ** 256 - 1; return Assert.equal( @@ -20,7 +20,7 @@ contract SafeMathTest { ); } - function safeMultiplicationShouldRevert() public constant returns (bool) { + function safeMultiplicationShouldRevert() public view returns (bool) { uint256 a = 4; uint256 b = 2 ** 256 - 1; return Assert.equal( @@ -30,7 +30,7 @@ contract SafeMathTest { ); } - function safeDivisionByZeroShouldRevert() public constant returns (bool) { + function safeDivisionByZeroShouldRevert() public view returns (bool) { uint256 a = 4; uint256 b = 0; return Assert.equal( @@ -40,7 +40,7 @@ contract SafeMathTest { ); } - function unsafeSubtractShouldUnderflow() public constant returns (bool) { + function unsafeSubtractShouldUnderflow() public view returns (bool) { uint256 a = 0; uint256 b = a - 1; return Assert.equal( diff --git a/remix-tests/tests/number/number_test.sol b/remix-tests/tests/number/number_test.sol index 9098490215..cc097d2436 100644 --- a/remix-tests/tests/number/number_test.sol +++ b/remix-tests/tests/number/number_test.sol @@ -3,36 +3,36 @@ pragma solidity ^0.4.24; contract IntegerTest { // GREATER THAN [>] tests - function _2_shouldBeGreaterThan_1() public constant returns (bool) { + function _2_shouldBeGreaterThan_1() public view returns (bool) { return Assert.greaterThan(uint(2), uint(1), "2 is greater than 1"); } - function _0_shouldBeGreaterThan_neg_1() public constant returns (bool) { + function _0_shouldBeGreaterThan_neg_1() public view returns (bool) { return Assert.greaterThan(uint(0), int(-1), "0 is greater than -1"); } - function _neg_1_shouldNotBeGreaterThan_1() public constant returns (bool) { + function _neg_1_shouldNotBeGreaterThan_1() public view returns (bool) { return Assert.greaterThan(int(-1), uint(1), "-1 is not greater than 1"); } - function _1_shouldBeGreaterThan_neg_1() public constant returns (bool) { + function _1_shouldBeGreaterThan_neg_1() public view returns (bool) { return Assert.greaterThan(uint(1), int(-1), "1 is greater than -1"); } // LESSER THAN [<] tests - function _1_shouldBeLesserThan_2() public constant returns (bool) { + function _1_shouldBeLesserThan_2() public view returns (bool) { return Assert.lesserThan(uint(1), uint(2), "1 is lesser than 2"); } - function _neg_1_shouldBeLesserThan_0() public constant returns (bool) { + function _neg_1_shouldBeLesserThan_0() public view returns (bool) { return Assert.lesserThan(int(-1), uint(0), "-1 is lesser than 0"); } - function _neg_2_shouldBeLesserThan_neg_1() public constant returns (bool) { + function _neg_2_shouldBeLesserThan_neg_1() public view returns (bool) { return Assert.lesserThan(int(-2), int(-1), "-2 is lesser than -1"); } - function _0_shouldNotBeLesserThan_neg_1() public constant returns (bool) { + function _0_shouldNotBeLesserThan_neg_1() public view returns (bool) { return Assert.lesserThan(uint(0), int(-1), "0 is not lesser than -1"); } }