Skip to content

Commit 7167641

Browse files
committed
migrate test contracts to use skribe-rs
1 parent f4ad0a9 commit 7167641

11 files changed

Lines changed: 74 additions & 286 deletions

File tree

src/tests/integration/data/contracts/test-foundry-from-stylus/Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests/integration/data/contracts/test-foundry-from-stylus/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mini-alloc = "0.8.4"
1313
stylus-sdk = "0.8.4"
1414
hex = "0.4.3"
1515
dotenv = "0.15.0"
16+
skribe = { version = "0.1.0", path = "../../../../../../lib/skribe-rs" }
1617

1718
[dev-dependencies]
1819
tokio = { version = "1.12.0", features = ["full"] }

src/tests/integration/data/contracts/test-foundry-from-stylus/src/lib.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ extern crate alloc;
33

44
use stylus_sdk::{alloy_primitives::U256, prelude::*};
55

6-
use crate::skribe::{build_init_code, new_cheatcodes};
7-
8-
mod skribe;
6+
use skribe::{build_init_code, cheat};
97

108
sol_interface! {
119
interface ICounter {
@@ -23,16 +21,13 @@ sol_storage! {
2321
}
2422
}
2523

26-
const COUNTER_BYTECODE_PATH: &str =
27-
"bin/Counter.bin";
24+
const COUNTER_BYTECODE_PATH: &str = "bin/Counter.bin";
2825

2926
#[public]
3027
impl TestCounter {
31-
pub fn setUp(&mut self) {
32-
33-
let cheatcodes = new_cheatcodes();
28+
pub fn set_up(&mut self) {
3429

35-
let hex_bytecode = cheatcodes
30+
let hex_bytecode = cheat()
3631
.read_file(&mut *self, COUNTER_BYTECODE_PATH.to_string())
3732
.unwrap();
3833
let bytecode = hex::decode(hex_bytecode).unwrap();

src/tests/integration/data/contracts/test-foundry-from-stylus/src/skribe.rs

Lines changed: 0 additions & 120 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"../stylus-hello-world": {
3+
"rev": "38692451478deb14e41473bc569aae84091fe5d1"
4+
},
5+
"../test-foundry-simple/lib/forge-std": {
6+
"rev": "8bbcf6e3f8f62f419e5429a0bd89331c85c37824"
7+
},
8+
"../test-foundry-simple/lib/kontrol-cheatcodes": {
9+
"rev": "187b89ad863226afe494caa9f58320997a543bff"
10+
},
11+
"../test-stylus-from-foundry/lib/forge-std": {
12+
"rev": "0768d9c08c085c79bb31d88683a78770764fec49"
13+
},
14+
"lib/forge-std": {
15+
"rev": "77041d2ce690e692d6e03cc812b57d1ddaa4d505"
16+
}
17+
}

src/tests/integration/data/contracts/test-foundry-simple/foundry.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
"../test-foundry-hello/lib/forge-std": {
66
"rev": "77041d2ce690e692d6e03cc812b57d1ddaa4d505"
77
},
8+
"../test-stylus-from-foundry/lib/forge-std": {
9+
"rev": "0768d9c08c085c79bb31d88683a78770764fec49"
10+
},
811
"lib/forge-std": {
912
"tag": {
1013
"name": "v1.10.0",
1114
"rev": "8bbcf6e3f8f62f419e5429a0bd89331c85c37824"
1215
}
16+
},
17+
"lib/kontrol-cheatcodes": {
18+
"rev": "187b89ad863226afe494caa9f58320997a543bff"
1319
}
1420
}

src/tests/integration/data/contracts/test-hello-world/Cargo.lock

Lines changed: 16 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests/integration/data/contracts/test-hello-world/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mini-alloc = "0.8.4"
1515
stylus-sdk = "0.8.4"
1616
hex = "0.4.3"
1717
dotenv = "0.15.0"
18+
skribe = { version = "0.1.0", path = "../../../../../../lib/skribe-rs" }
1819

1920
[dev-dependencies]
2021
tokio = { version = "1.12.0", features = ["full"] }

src/tests/integration/data/contracts/test-hello-world/src/lib.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ extern crate alloc;
33

44
use stylus_sdk::{alloy_primitives::U256, prelude::*};
55

6-
use crate::skribe::{build_init_code, new_cheatcodes};
7-
8-
mod skribe;
6+
use skribe::{build_init_code, cheat};
97

108
sol_interface! {
119
interface ICounter {
@@ -29,12 +27,10 @@ const COUNTER_BYTECODE_PATH: &str =
2927

3028
#[public]
3129
impl TestCounter {
32-
pub fn setUp(&mut self) {
30+
pub fn set_up(&mut self) {
3331
self.number.set(U256::from(123));
3432

35-
let cheatcodes = new_cheatcodes();
36-
37-
let bytecode = cheatcodes
33+
let bytecode = cheat()
3834
.read_file_binary(&mut *self, COUNTER_BYTECODE_PATH.to_string())
3935
.unwrap();
4036
let counter_address = unsafe {
@@ -58,9 +54,7 @@ impl TestCounter {
5854
}
5955

6056
pub fn test_call_increment(&mut self, x: U256) {
61-
if x >= U256::MAX {
62-
return;
63-
}
57+
cheat().assume(&mut *self, x < U256::MAX).unwrap();
6458

6559
let counter = ICounter::new(self.counter.get());
6660
counter.set_number(&mut *self, x).unwrap();

0 commit comments

Comments
 (0)