diff --git a/libs/remix-tests/sol/tests.sol.ts b/libs/remix-tests/sol/tests.sol.ts index 2b73000d82..a5158481b2 100644 --- a/libs/remix-tests/sol/tests.sol.ts +++ b/libs/remix-tests/sol/tests.sol.ts @@ -36,6 +36,13 @@ library Assert { address expected ); + event AssertionEventBytes32( + bool passed, + string message, + bytes32 returned, + bytes32 expected + ); + function ok(bool a, string memory message) public returns (bool result) { result = a; emit AssertionEvent(result, message); @@ -75,7 +82,7 @@ library Assert { function equal(bytes32 a, bytes32 b, string memory message) public returns (bool result) { result = (a == b); - emit AssertionEvent(result, message); + emit AssertionEventBytes32(result, message, a, b); } function equal(string memory a, string memory b, string memory message) public returns (bool result) { @@ -117,7 +124,7 @@ library Assert { function notEqual(bytes32 a, bytes32 b, string memory message) public returns (bool result) { result = (a != b); - emit AssertionEvent(result, message); + emit AssertionEventBytes32(result, message, a, b); } function notEqual(string memory a, string memory b, string memory message) public returns (bool result) { diff --git a/libs/remix-tests/src/assertionEvents.ts b/libs/remix-tests/src/assertionEvents.ts index 2da4bb8d76..9b3deb70dc 100644 --- a/libs/remix-tests/src/assertionEvents.ts +++ b/libs/remix-tests/src/assertionEvents.ts @@ -18,6 +18,10 @@ const assertionEvents = [ { name: 'AssertionEventAddress', params: ['bool', 'string', 'address', 'address'] + }, + { + name: 'AssertionEventBytes32', + params: ['bool', 'string', 'bytes32', 'bytes32'] } ] diff --git a/libs/remix-tests/tests/examples_0/assert_equal_test.sol b/libs/remix-tests/tests/examples_0/assert_equal_test.sol index caa7f7ed91..87589cae4c 100644 --- a/libs/remix-tests/tests/examples_0/assert_equal_test.sol +++ b/libs/remix-tests/tests/examples_0/assert_equal_test.sol @@ -33,4 +33,16 @@ contract AssertEqualTest { function equalAddressFailTest() public { Assert.equal(0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9, 0x1c6637567229159d1eFD45f95A6675e77727E013, "equalAddressFailTest fails"); } + + function equalBytes32PassTest() public { + bytes32 e = 0x72656d6978000000000000000000000000000000000000000000000000000000; + bytes32 r = 0x72656d6978000000000000000000000000000000000000000000000000000000; + Assert.equal(r, e, "equalBytes32PassTest passes"); + } + + function equalBytes32FailTest() public { + bytes32 e = 0x72656d6978000000000000000000000000000000000000000000000000000000; + bytes32 r = 0x72656d6979000000000000000000000000000000000000000000000000000000; + Assert.equal(r, e, "equalBytes32FailTest fails"); + } } \ No newline at end of file diff --git a/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol b/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol index 06a73da279..d399d20ae3 100644 --- a/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol +++ b/libs/remix-tests/tests/examples_0/assert_notEqual_test.sol @@ -33,4 +33,16 @@ contract AssertNotEqualTest { function notEqualAddressFailTest() public { Assert.notEqual(0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9, 0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9, "notEqualAddressFailTest fails"); } + + function notEqualBytes32PassTest() public { + bytes32 e = 0x72656d6978000000000000000000000000000000000000000000000000000000; + bytes32 r = 0x72656d6979000000000000000000000000000000000000000000000000000000; + Assert.notEqual(r, e, "notEqualBytes32PassTest fails"); + } + + function notEqualBytes32FailTest() public { + bytes32 e = 0x72656d6978000000000000000000000000000000000000000000000000000000; + bytes32 r = 0x72656d6978000000000000000000000000000000000000000000000000000000; + Assert.notEqual(r, e, "notEqualBytes32FailTest fails"); + } } diff --git a/libs/remix-tests/tests/testRunner.spec.ts b/libs/remix-tests/tests/testRunner.spec.ts index 69bc6c8cd4..e27e9be835 100644 --- a/libs/remix-tests/tests/testRunner.spec.ts +++ b/libs/remix-tests/tests/testRunner.spec.ts @@ -143,12 +143,12 @@ describe('testRunner', () => { afterAll(() => { tests = [] }) - it('should have 4 passing test', () => { - assert.equal(results.passingNum, 4) + it('should have 5 passing test', () => { + assert.equal(results.passingNum, 5) }) - it('should have 4 failing test', () => { - assert.equal(results.failureNum, 4) + it('should have 5 failing test', () => { + assert.equal(results.failureNum, 5) }) it('should return', () => { @@ -162,7 +162,9 @@ describe('testRunner', () => { { type: 'testPass', value: 'Equal bool pass test', context: 'AssertEqualTest' }, { type: 'testFailure', value: 'Equal bool fail test', errMsg: 'equalBoolFailTest fails', context: 'AssertEqualTest', expected: false, returned: true}, { type: 'testPass', value: 'Equal address pass test', context: 'AssertEqualTest' }, - { type: 'testFailure', value: 'Equal address fail test', errMsg: 'equalAddressFailTest fails', context: 'AssertEqualTest', expected: '0x1c6637567229159d1eFD45f95A6675e77727E013', returned: '0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9'} + { type: 'testFailure', value: 'Equal address fail test', errMsg: 'equalAddressFailTest fails', context: 'AssertEqualTest', expected: '0x1c6637567229159d1eFD45f95A6675e77727E013', returned: '0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9'}, + { type: 'testPass', value: 'Equal bytes32 pass test', context: 'AssertEqualTest' }, + { type: 'testFailure', value: 'Equal bytes32 fail test', errMsg: 'equalBytes32FailTest fails', context: 'AssertEqualTest', expected: '0x72656d6978000000000000000000000000000000000000000000000000000000', returned: '0x72656d6979000000000000000000000000000000000000000000000000000000'} ], ['time']) }) }) @@ -178,12 +180,12 @@ describe('testRunner', () => { afterAll(() => { tests = [] }) - it('should have 4 passing test', () => { - assert.equal(results.passingNum, 4) + it('should have 5 passing test', () => { + assert.equal(results.passingNum, 5) }) - it('should have 4 failing test', () => { - assert.equal(results.failureNum, 4) + it('should have 5 failing test', () => { + assert.equal(results.failureNum, 5) }) it('should return', () => { @@ -197,7 +199,9 @@ describe('testRunner', () => { { type: 'testPass', value: 'Not equal bool pass test', context: 'AssertNotEqualTest' }, { type: 'testFailure', value: 'Not equal bool fail test', errMsg: 'notEqualBoolFailTest fails', context: 'AssertNotEqualTest', expected: true, returned: true}, { type: 'testPass', value: 'Not equal address pass test', context: 'AssertNotEqualTest' }, - { type: 'testFailure', value: 'Not equal address fail test', errMsg: 'notEqualAddressFailTest fails', context: 'AssertNotEqualTest', expected: 0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9, returned: 0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9} + { type: 'testFailure', value: 'Not equal address fail test', errMsg: 'notEqualAddressFailTest fails', context: 'AssertNotEqualTest', expected: 0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9, returned: 0x7994f14563F39875a2F934Ce42cAbF48a93FdDA9}, + { type: 'testPass', value: 'Not equal bytes32 pass test', context: 'AssertNotEqualTest' }, + { type: 'testFailure', value: 'Not equal bytes32 fail test', errMsg: 'notEqualBytes32FailTest fails', context: 'AssertNotEqualTest', expected: '0x72656d6978000000000000000000000000000000000000000000000000000000', returned: '0x72656d6978000000000000000000000000000000000000000000000000000000'} ], ['time']) }) })