Skip to content

Commit

Permalink
chore: apply the review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Apr 26, 2022
1 parent d939d02 commit 16b380b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 47 deletions.
2 changes: 1 addition & 1 deletion crates/generator/src/typed_transaction/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl PolyjuiceTx {
let args: Bytes = self.0.raw().args().unpack();
if args.len() < 52 {
log::error!(
"[gw-generator] parse PolyjuiceTx error, wrong args.len expected: 52, actual: {}",
"[gw-generator] parse PolyjuiceTx error, wrong args.len expected: >= 52, actual: {}",
args.len()
);
return None;
Expand Down
66 changes: 20 additions & 46 deletions crates/tests/src/testing_tool/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use lazy_static::lazy_static;
use tokio::sync::Mutex;

use std::{collections::HashSet, time::Duration};
use std::{fs, io::Read, path::PathBuf, sync::Arc};
use std::{fs, path::PathBuf, sync::Arc};

use super::mem_pool_provider::DummyMemPoolProvider;

Expand All @@ -46,13 +46,10 @@ const ETH_ACCOUNT_LOCK_PATH: &str = "eth-account-lock";

lazy_static! {
pub static ref ALWAYS_SUCCESS_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&SCRIPT_DIR);
path.push(&ALWAYS_SUCCESS_PATH);
let mut f = fs::File::open(&path).expect("load program");
f.read_to_end(&mut buf).expect("read program");
Bytes::from(buf.to_vec())
fs::read(&path).expect("read program").into()
};
pub static ref ALWAYS_SUCCESS_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
Expand All @@ -62,14 +59,12 @@ lazy_static! {
buf
};
pub static ref WITHDRAWAL_LOCK_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&SCRIPT_DIR);
path.push(&WITHDRAWAL_LOCK_PATH);
let mut f = fs::File::open(&path).expect("load withdrawal lock program");
f.read_to_end(&mut buf)
.expect("read withdrawal lock program");
Bytes::from(buf.to_vec())
fs::read(&path)
.expect("read withdrawal lock program")
.into()
};
pub static ref WITHDRAWAL_LOCK_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
Expand All @@ -79,14 +74,12 @@ lazy_static! {
buf
};
pub static ref STATE_VALIDATOR_TYPE_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&SCRIPT_DIR);
path.push(&STATE_VALIDATOR_TYPE_PATH);
let mut f = fs::File::open(&path).expect("load state validator type program");
f.read_to_end(&mut buf)
.expect("read state validator type program");
Bytes::from(buf.to_vec())
fs::read(&path)
.expect("read state validator type program")
.into()
};
pub static ref STATE_VALIDATOR_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
Expand All @@ -96,13 +89,10 @@ lazy_static! {
buf
};
pub static ref STAKE_LOCK_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&SCRIPT_DIR);
path.push(&STAKE_LOCK_PATH);
let mut f = fs::File::open(&path).expect("load stake lock program");
f.read_to_end(&mut buf).expect("read stake lock program");
Bytes::from(buf.to_vec())
fs::read(&path).expect("read stake lock program").into()
};
pub static ref STAKE_LOCK_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
Expand All @@ -112,14 +102,10 @@ lazy_static! {
buf
};
pub static ref CUSTODIAN_LOCK_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&SCRIPT_DIR);
path.push(&CUSTODIAN_LOCK_PATH);
let mut f = fs::File::open(&path).expect("load custodian lock program");
f.read_to_end(&mut buf)
.expect("read custodian lock program");
Bytes::from(buf.to_vec())
fs::read(&path).expect("read custodian lock program").into()
};
pub static ref CUSTODIAN_LOCK_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
Expand All @@ -129,14 +115,12 @@ lazy_static! {
buf
};
pub static ref ETH_ACCOUNT_LOCK_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&SCRIPT_DIR);
path.push(&ETH_ACCOUNT_LOCK_PATH);
let mut f = fs::File::open(&path).expect("load eth account lock program");
f.read_to_end(&mut buf)
.expect("read eth account lock program");
Bytes::from(buf.to_vec())
fs::read(&path)
.expect("read eth account lock program")
.into()
};
pub static ref ETH_ACCOUNT_LOCK_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
Expand All @@ -145,30 +129,20 @@ lazy_static! {
hasher.finalize(&mut buf);
buf
};
pub static ref SUDT_VALIDATOR_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&SUDT_VALIDATOR_PATH);
let mut f = fs::File::open(&path).expect("load SUDT program");
f.read_to_end(&mut buf).expect("read SUDT program");
Bytes::from(buf.to_vec())
};
pub static ref SUDT_VALIDATOR_PROGRAM: Bytes = fs::read(&SUDT_VALIDATOR_PATH)
.expect("read SUDT program")
.into();
pub static ref SUDT_VALIDATOR_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
let mut hasher = new_blake2b();
hasher.update(&SUDT_VALIDATOR_PROGRAM);
hasher.finalize(&mut buf);
buf
};
pub static ref ETH_EOA_MAPPING_REGISTRY_VALIDATOR_PROGRAM: Bytes = {
let mut buf = Vec::new();
let mut path = PathBuf::new();
path.push(&ETH_REGISTRY_VALIDATOR_PATH);
let mut f = fs::File::open(&path).expect("load eth eoa mapping registry program");
f.read_to_end(&mut buf)
.expect("read eth eoa mapping registry program");
Bytes::from(buf.to_vec())
};
pub static ref ETH_EOA_MAPPING_REGISTRY_VALIDATOR_PROGRAM: Bytes =
fs::read(&ETH_REGISTRY_VALIDATOR_PATH)
.expect("read eth eoa mapping registry program")
.into();
pub static ref ETH_EOA_MAPPING_REGISTRY_VALIDATOR_CODE_HASH: [u8; 32] = {
let mut buf = [0u8; 32];
let mut hasher = new_blake2b();
Expand Down

0 comments on commit 16b380b

Please sign in to comment.