Skip to content

Commit

Permalink
fix chain id in testool (#1236)
Browse files Browse the repository at this point in the history
### Description

1. fix chain id and block number in testool.
2. upgrade "prettytable-rs". The current version will [break in future
nightly rust](phsym/prettytable-rs#145).

### Issue Link

[_link issue here_]

### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Contents

- [_item_]

### Rationale

[_design decisions and extended information_]

### How Has This Been Tested?

[_explanation_]

<hr>

## How to fill a PR description 

Please give a concise description of your PR.

The target readers could be future developers, reviewers, and auditors.
By reading your description, they should easily understand the changes
proposed in this pull request.

MUST: Reference the issue to resolve

### Single responsability

Is RECOMMENDED to create single responsibility commits, but not
mandatory.

Anyway, you MUST enumerate the changes in a unitary way, e.g.

```
This PR contains:
- Cleanup of xxxx, yyyy
- Changed xxxx to yyyy in order to bla bla
- Added xxxx function to ...
- Refactored ....
```

### Design choices

RECOMMENDED to:
- What types of design choices did you face?
- What decisions you have made?
- Any valuable information that could help reviewers to think critically
  • Loading branch information
lispc committed Feb 23, 2023
1 parent b7a618a commit d6826a4
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 6 deletions.
75 changes: 72 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion testool/Cargo.toml
Expand Up @@ -20,7 +20,7 @@ keccak256 = { path = "../keccak256" }
log = "0.4"
mock = { path = "../mock" }
once_cell = "1.10"
prettytable-rs = "0.9"
prettytable-rs = "0.10"
rayon = "1.5"
regex = "1"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -38,4 +38,5 @@ urlencoding = "2.1.2"


[features]
default = []
ignore-test-docker = []
11 changes: 9 additions & 2 deletions testool/src/statetest/executor.rs
Expand Up @@ -4,6 +4,7 @@ use bus_mapping::circuit_input_builder::{CircuitInputBuilder, CircuitsParams};
use bus_mapping::mock::BlockData;
use eth_types::{geth_types, Address, Bytes, GethExecTrace, U256, U64};
use ethers_core::k256::ecdsa::SigningKey;
use ethers_core::types::transaction::eip2718::TypedTransaction;
use ethers_core::types::TransactionRequest;
use ethers_signers::{LocalWallet, Signer};
use external_tracer::TraceConfig;
Expand Down Expand Up @@ -119,8 +120,9 @@ fn into_traceconfig(st: StateTest) -> (String, TraceConfig, StateTestResult) {
if let Some(to) = st.to {
tx = tx.to(to);
}
let tx: TypedTransaction = tx.into();

let sig = wallet.sign_transaction_sync(&tx.into());
let sig = wallet.sign_transaction_sync(&tx);

(
st.id,
Expand Down Expand Up @@ -222,6 +224,8 @@ pub fn run_test(
r: tx.r,
s: tx.s,
v: U64::from(tx.v),
block_number: Some(U64::from(trace_config.block_constants.number.as_u64())),
chain_id: Some(trace_config.chain_id),
..eth_types::Transaction::default()
})
.collect();
Expand All @@ -239,7 +243,10 @@ pub fn run_test(

let wallet: LocalWallet = SigningKey::from_bytes(&st.secret_key).unwrap().into();
let mut wallets = HashMap::new();
wallets.insert(wallet.address(), wallet.with_chain_id(1u64));
wallets.insert(
wallet.address(),
wallet.with_chain_id(trace_config.chain_id.as_u64()),
);

// process the transaction
let mut geth_data = eth_types::geth_types::GethData {
Expand Down

0 comments on commit d6826a4

Please sign in to comment.