Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
fix: set wrong used gas to system log (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
magicalne authored Sep 14, 2022
1 parent 5626a05 commit 1d05a58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion c/polyjuice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ int run_polyjuice() {
return ret;
}
/* emit POLYJUICE_SYSTEM log to Godwoken */
ret = emit_evm_result_log(&context, min_gas, transfer_ret);
ret = emit_evm_result_log(&context, gas_used, transfer_ret);
if (ret != 0) {
ckb_debug("emit_evm_result_log failed");
return ret;
Expand Down
7 changes: 6 additions & 1 deletion polyjuice-tests/src/test_cases/native_token_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use gw_types::{

use crate::{
ctx::MockChain,
helper::{MockContractInfo, PolyjuiceArgsBuilder, CREATOR_ACCOUNT_ID},
helper::{parse_log, Log, MockContractInfo, PolyjuiceArgsBuilder, CREATOR_ACCOUNT_ID},
};

#[test]
Expand Down Expand Up @@ -66,6 +66,11 @@ fn native_token_transfer_unregistered_address_test() -> anyhow::Result<()> {
let run_result = chain.execute_raw(raw_tx)?;
assert_eq!(run_result.exit_code, 0);

let system_log = run_result.write.logs.last().map(parse_log);
if let Some(Log::PolyjuiceSystem { gas_used, .. }) = system_log {
assert_eq!(gas_used, 21000 + 25000);
}

let account_id = chain.get_account_id_by_eth_address(&to_addr)?;
assert_eq!(Some(6), account_id);
let from_balance = chain.get_balance(&from_addr)?;
Expand Down

0 comments on commit 1d05a58

Please sign in to comment.