Skip to content

Commit

Permalink
Fix evm tx hash and add test case (#2078)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPing authored Jun 16, 2023
1 parent 432fd00 commit 3a6d85a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3878,7 +3878,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor {
std::vector<unsigned char> 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();
Expand Down
3 changes: 2 additions & 1 deletion test/functional/feature_evm_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 3a6d85a

Please sign in to comment.