Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brock/pr30 mods #39

Merged
merged 21 commits into from
Oct 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add kind to FunctionCallDef
jinmel committed Sep 30, 2024
commit f90fdb53012b9266156a8a5ce53b38bab9473c3c
4 changes: 3 additions & 1 deletion cli/univ2ConfigTest.toml
Original file line number Diff line number Diff line change
@@ -141,6 +141,7 @@ args = [

### the spam step will be repeated
[[spam]]
kind = "uniswap_v2"
to = "{uniRouterV2}"
from = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
signature = "swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) external returns (uint256[] memory)"
@@ -158,6 +159,7 @@ min = "1"
max = "100000000000000000"

[[spam]]
kind = "uniswap_v2"
to = "{uniRouterV2}"
from = "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
signature = "swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) external returns (uint256[] memory)"
@@ -172,4 +174,4 @@ args = [
[[spam.fuzz]]
param = "amountIn"
min = "100000"
max = "10000000000"
max = "10000000000"
5 changes: 5 additions & 0 deletions src/generator/types.rs
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@ pub struct FunctionCallDefinition {
pub value: Option<String>,
/// Parameters to fuzz during the test.
pub fuzz: Option<Vec<FuzzParam>>,
/// Optional type of the spam transaction for categorization.
pub kind: Option<String>
}

#[derive(Clone, Deserialize, Debug, Serialize)]
@@ -125,6 +127,7 @@ pub mod tests {
args: Some(vec!["0x8765".to_string(), "100".to_string()]),
value: Some("100".to_string()),
fuzz: None,
kind: None,
};
assert_eq!(fn_def_with_args.name(), "transfer(address to=[0x8765], uint256 amount=[100])");

@@ -135,6 +138,7 @@ pub mod tests {
args: None,
value: Some("100".to_string()),
fuzz: None,
kind: None,
};
assert_eq!(fn_def_no_args.name(), "transfer()");

@@ -146,6 +150,7 @@ pub mod tests {
args: Some(vec!["0x8765".to_string(), "100".to_string()]),
value: Some("100".to_string()),
fuzz: None,
kind: None,
};
assert_eq!(fn_def_invalid_sig.name(), "transfer(uint256 amount=[100])");
}
3 changes: 3 additions & 0 deletions src/test_scenario.rs
Original file line number Diff line number Diff line change
@@ -263,6 +263,7 @@ pub mod tests {
]
.into(),
fuzz: None,
kind: None,
},
FunctionCallDefinition {
to: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D".to_owned(),
@@ -277,6 +278,7 @@ pub mod tests {
]
.into(),
fuzz: None,
kind: None,
},
])
}
@@ -300,6 +302,7 @@ pub mod tests {
max: None,
}]
.into(),
kind: None,
};
Ok(vec![
fn_call("0xbeef", "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"),
5 changes: 5 additions & 0 deletions testfile/src/lib.rs
Original file line number Diff line number Diff line change
@@ -154,6 +154,7 @@ pub mod tests {
.into(),
fuzz: None,
value: None,
kind: None,
}]
.into(),
}
@@ -172,6 +173,7 @@ pub mod tests {
data.to_owned(),
]
.into(),
kind: None,
fuzz: vec![FuzzParam {
param: "x".to_string(),
min: None,
@@ -210,6 +212,7 @@ pub mod tests {
"0xdead".to_owned(),
]
.into(),
kind: None,
fuzz: None,
},
FunctionCallDefinition {
@@ -224,6 +227,7 @@ pub mod tests {
"0xbeef".to_owned(),
]
.into(),
kind: None,
fuzz: None,
},
]
@@ -284,6 +288,7 @@ pub mod tests {
spam[1].fuzz.as_ref().unwrap()[0].min,
Some(U256::from(100000))
);
assert_eq!(spam[0].kind, Some("uniswap_v2".to_owned()));
}

fn print_testconfig(cfg: &str) {
177 changes: 177 additions & 0 deletions testfile/univ2ConfigTest.toml

Large diffs are not rendered by default.