From eb00700c002cf9d5ccff54ae3f47b81d37de9709 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 14 Dec 2021 15:25:25 +0800 Subject: [PATCH] Problem: empty topics in rpc response is not tested Closes: #841 Solution: - merge empty topics fix - add integration tests to verify --- .../contracts/contracts/TestERC20Utility.sol | 5 +++++ integration_tests/test_basic.py | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/integration_tests/contracts/contracts/TestERC20Utility.sol b/integration_tests/contracts/contracts/TestERC20Utility.sol index 29e9f436dc..e81fcca8ae 100644 --- a/integration_tests/contracts/contracts/TestERC20Utility.sol +++ b/integration_tests/contracts/contracts/TestERC20Utility.sol @@ -27,4 +27,9 @@ contract TestERC20Utility is ERC20 { _burn(msg.sender, total); emit __CronosSendToEthereum(recipient, amount, bridge_fee); } + + function test_log0() public { + bytes32 data = "hello world"; + log0(bytes32(data)); + } } diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 1f430e35c8..7c2f35e7a4 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -454,3 +454,23 @@ def test_suicide(cluster): assert receipt.status == 1 assert len(w3.eth.get_code(destroyee.address)) == 0 + + +def test_log0(cluster): + """ + test compliance of empty topics behavior + """ + w3 = cluster.w3 + contract = deploy_contract( + w3, + Path(__file__).parent + / "contracts/artifacts/contracts/TestERC20Utility.sol/TestERC20Utility.json", + ) + tx = contract.functions.test_log0().buildTransaction({"from": ADDRS["validator"]}) + receipt = send_transaction(w3, tx, KEYS["validator"]) + assert len(receipt.logs) == 1 + log = receipt.logs[0] + assert log.topics == [] + assert ( + log.data == "0x68656c6c6f20776f726c64000000000000000000000000000000000000000000" + )