Skip to content

Commit

Permalink
Fix evm test (#2352)
Browse files Browse the repository at this point in the history
* Fix dump priv key

* Fix feature evm test
  • Loading branch information
sieniven authored Aug 18, 2023
1 parent 28044c6 commit f68af9b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2932,7 +2932,6 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
}

// Finalize items

if (isEvmEnabledForBlock) {
XResultThrowOnErr(evm_unsafe_try_commit_queue(result, evmQueueId));
}
Expand Down
8 changes: 7 additions & 1 deletion src/wallet/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ UniValue importprivkey(const JSONRPCRequest& request)
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
}

CKey key = DecodeSecret(strSecret);
CKey key;
if (const auto ethKey{IsHex(strSecret)}; ethKey) {
const auto vch = ParseHex(strSecret);
key.Set(vch.begin(), vch.end(), true);
} else {
key = DecodeSecret(strSecret);
}
if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key encoding");

CPubKey pubkey = key.GetPubKey();
Expand Down
42 changes: 12 additions & 30 deletions test/functional/feature_evm.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,44 +961,26 @@ def validate_xvm_coinbase(self):
eth_block = self.nodes[0].eth_getBlockByNumber("latest")
eth_hash = eth_block["hash"][2:]
block = self.nodes[0].getblock(
self.nodes[0].getblockhash(self.nodes[0].getblockcount())
self.nodes[0].getblockhash(self.nodes[0].getblockcount()), 3
)
raw_tx = self.nodes[0].getrawtransaction(block["tx"][0], 1)
block_hash = raw_tx["vout"][1]["scriptPubKey"]["hex"][22:86]
coinbase_xvm = block["tx"][0]["vm"]
assert_equal(coinbase_xvm["vmtype"], "coinbase")
assert_equal(coinbase_xvm["txtype"], "coinbase")
block_hash = coinbase_xvm["msg"]["evm"]["blockHash"][2:]
assert_equal(block_hash, eth_hash)

# Check EVM burnt fee
opreturn_burnt_fee_amount = raw_tx["vout"][1]["scriptPubKey"]["hex"][86:]
opreturn_burnt_fee_sats = (
Decimal(
int(
opreturn_burnt_fee_amount[4:6]
+ opreturn_burnt_fee_amount[2:4]
+ opreturn_burnt_fee_amount[0:2],
16,
)
)
/ 100000000
)
assert_equal(opreturn_burnt_fee_sats, self.burn)
opreturn_burnt_fee_sats = coinbase_xvm["msg"]["evm"]["burntFee"]
opreturn_burnt_fee_amount = Decimal(opreturn_burnt_fee_sats) / 100000000
assert_equal(opreturn_burnt_fee_amount, self.burn)

# Check EVM miner fee
opreturn_priority_fee_amount = raw_tx["vout"][1]["scriptPubKey"]["hex"][102:]
opreturn_priority_fee_sats = (
Decimal(
int(
opreturn_priority_fee_amount[4:6]
+ opreturn_priority_fee_amount[2:4]
+ opreturn_priority_fee_amount[0:2],
16,
)
)
/ 100000000
)
assert_equal(opreturn_priority_fee_sats, self.miner_fee)
opreturn_priority_fee_sats = coinbase_xvm["msg"]["evm"]["priorityFee"]
opreturn_priority_fee_amount = Decimal(opreturn_priority_fee_sats) / 100000000
assert_equal(opreturn_priority_fee_amount, self.miner_fee)

# Check EVM beneficiary address
opreturn_miner_keyid = raw_tx["vout"][1]["scriptPubKey"]["hex"][120:]
opreturn_miner_keyid = coinbase_xvm["msg"]["evm"]["beneficiary"][2:]
miner_eth_address = self.nodes[0].addressmap(
self.nodes[0].get_genesis_keys().operatorAuthAddress, 1
)
Expand Down

0 comments on commit f68af9b

Please sign in to comment.