From 3a6d85ae4500a04adf4f2ed732b957930a9b6ca5 Mon Sep 17 00:00:00 2001 From: DrPing Date: Fri, 16 Jun 2023 17:21:39 +0800 Subject: [PATCH] Fix evm tx hash and add test case (#2078) --- src/masternodes/mn_checks.cpp | 2 +- test/functional/feature_evm_rpc.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/masternodes/mn_checks.cpp b/src/masternodes/mn_checks.cpp index cbb2302377..997c5ff186 100644 --- a/src/masternodes/mn_checks.cpp +++ b/src/masternodes/mn_checks.cpp @@ -3878,7 +3878,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor { std::vector evmTxHashBytes; sha3(obj.evmTx, evmTxHashBytes); auto txHash = tx.GetHash(); - auto evmTxHash = uint256(evmTxHashBytes); + auto evmTxHash = uint256S(HexStr(evmTxHashBytes)); mnview.SetVMDomainMapTxHash(VMDomainMapType::DVMToEVM, txHash, evmTxHash); mnview.SetVMDomainMapTxHash(VMDomainMapType::EVMToDVM, evmTxHash, txHash); return Res::Ok(); diff --git a/test/functional/feature_evm_rpc.py b/test/functional/feature_evm_rpc.py index 90a2505fee..5bc5988d9f 100755 --- a/test/functional/feature_evm_rpc.py +++ b/test/functional/feature_evm_rpc.py @@ -167,11 +167,12 @@ def test_vmmap(self): assert_raises_rpc_error(-5, "0x0000000000000000000000000000000000000000 does not refer to a key", self.nodes[0].vmmap, eth_address, 2) assert_raises_rpc_error(-5, "Invalid address: test", self.nodes[0].vmmap, 'test', 1) - #Check if xvmmap is working for Txs + # Check if xvmmap is working for Txs list_tx = self.nodes[0].logvmmaps(1) dvm_tx = list(list_tx['indexes'].keys())[0] evm_tx = self.nodes[0].vmmap(dvm_tx, 3) assert_equal(dvm_tx, self.nodes[0].vmmap(evm_tx, 4)) + assert_equal("0x" + evm_tx, self.nodes[0].eth_getBlockByNumber("latest", False)['transactions'][0]) # Check vmmap fail on wrong tx evm_tx = '0x0000000000000000000000000000000000000000000000000000000000000000'