-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fdb0f5
commit a980f08
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
path_instrumented_contract_test_instrument_contains_instrumented_code/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "dummy" | ||
version = "0.1.0" | ||
authors = ["[your_name] <[your_email]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ink = { version = "5.0.0", default-features = false } | ||
ink_prelude = { version = "5.0.0", default-features = false } | ||
|
||
[dev-dependencies] | ||
ink_e2e = { version = "5.0.0" } | ||
hex = { version = "0.4.3" } | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"ink/std", | ||
] | ||
|
||
phink = [] | ||
|
||
ink-as-dependency = [] | ||
e2e-tests = [] |
9 changes: 9 additions & 0 deletions
9
test_assert_output_created_when_fuzzing_instrumented/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Ignore build artifacts from the local tests sub-crate. | ||
/target/ | ||
|
||
# Ignore backup files creates by cargo fmt. | ||
**/*.rs.bk | ||
|
||
# Remove Cargo.lock when creating an executable, leave it for libraries | ||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock | ||
Cargo.lock |
27 changes: 27 additions & 0 deletions
27
test_assert_output_created_when_fuzzing_instrumented/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "dummy" | ||
version = "0.1.0" | ||
authors = ["[your_name] <[your_email]>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
ink = { version = "5.0.0", default-features = false } | ||
ink_prelude = { version = "5.0.0", default-features = false } | ||
|
||
[dev-dependencies] | ||
ink_e2e = { version = "5.0.0" } | ||
hex = { version = "0.4.3" } | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [ | ||
"ink/std", | ||
] | ||
|
||
phink = [] | ||
|
||
ink-as-dependency = [] | ||
e2e-tests = [] |
72 changes: 72 additions & 0 deletions
72
test_assert_output_created_when_fuzzing_instrumented/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#![cfg_attr(not(feature = "std"), no_std, no_main)] | ||
#[ink::contract] | ||
mod dummy { | ||
use ink::{ | ||
prelude::vec::Vec, | ||
storage::{ | ||
Mapping, | ||
StorageVec, | ||
}, | ||
}; | ||
use ink_prelude::string::String; | ||
#[ink(storage)] | ||
pub struct MyBuggedContract { | ||
forbidden_number: u32, | ||
} | ||
impl Default for MyBuggedContract { | ||
fn default() -> Self { | ||
ink::env::debug_println!("COV={}", 0); | ||
Self { | ||
forbidden_number: 0, | ||
} | ||
} | ||
} | ||
#[derive(Debug, PartialEq, Eq)] | ||
#[ink::scale_derive(Encode, Decode, TypeInfo)] | ||
pub enum Error {} | ||
pub type Result<T> = core::result::Result<T, Error>; | ||
impl MyBuggedContract { | ||
/// Creates a new domain name service contract. | ||
#[ink(constructor)] | ||
pub fn new() -> Self { | ||
ink::env::debug_println!("COV={}", 1); | ||
Default::default() | ||
} | ||
#[ink(message)] | ||
pub fn crash_with_invariant(&mut self, data: String) -> Result<()> { | ||
ink::env::debug_println!("COV={}", 2); | ||
if data.len() == 4 { | ||
ink::env::debug_println!("COV={}", 3); | ||
if data.chars().nth(0).unwrap() == 'f' { | ||
ink::env::debug_println!("COV={}", 4); | ||
if data.chars().nth(1).unwrap() == 'u' { | ||
ink::env::debug_println!("COV={}", 5); | ||
if data.chars().nth(2).unwrap() == 'z' { | ||
ink::env::debug_println!("COV={}", 6); | ||
if data.chars().nth(3).unwrap() == 'z' { | ||
ink::env::debug_println!("COV={}", 7); | ||
self.forbidden_number = 69; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
ink::env::debug_println!("COV={}", 8); | ||
Ok(()) | ||
} | ||
} | ||
#[cfg(feature = "phink")] | ||
#[ink(impl)] | ||
impl MyBuggedContract { | ||
#[cfg(feature = "phink")] | ||
#[ink(message)] | ||
pub fn phink_assert_dangerous_number(&self) { | ||
ink::env::debug_println!("COV={}", 9); | ||
let forbidden_number = 69; | ||
ink::env::debug_println!("COV={}", 10); | ||
ink::env::debug_println!("xx"); | ||
ink::env::debug_println!("COV={}", 11); | ||
assert_ne!(self.forbidden_number, forbidden_number); | ||
} | ||
} | ||
} |