Skip to content

Commit d5a2370

Browse files
committed
Fix CI pipeline errors
Rust fixes: - Rename UnitType::from_str to parse_unit_type (avoid std trait confusion) - Fix unwrap after is_some check with proper if-let pattern - Replace vec! with array for static data (clippy suggestion) Solidity fixes: - Remove problematic OpenZeppelin certora files in CI workflow - Fix PipeEscrow test to use new initialize(consumer, provider) signature - All 8 contract tests now pass CI should now pass completely for both Rust and Solidity.
1 parent 04891db commit d5a2370

File tree

5 files changed

+37
-16
lines changed

5 files changed

+37
-16
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,24 @@ jobs:
5454

5555
- name: Build contracts
5656
working-directory: contracts
57-
run: forge build
57+
run: |
58+
# Remove problematic certora files that reference missing patched files
59+
rm -rf lib/openzeppelin-contracts/certora
60+
forge build
5861
5962
- name: Run tests
6063
working-directory: contracts
61-
run: forge test -vv
64+
run: |
65+
# Remove problematic certora files that reference missing patched files
66+
rm -rf lib/openzeppelin-contracts/certora
67+
forge test -vv
6268
6369
- name: Coverage
6470
working-directory: contracts
65-
run: forge coverage
71+
run: |
72+
# Remove problematic certora files that reference missing patched files
73+
rm -rf lib/openzeppelin-contracts/certora
74+
forge coverage
6675
6776
6877

contracts/PipeEscrow.t.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ contract PipeEscrowTest is Test {
2121

2222
pipe = new PipeEscrow();
2323

24-
vm.prank(consumer);
25-
pipe.initialize(provider);
24+
pipe.initialize(consumer, provider);
2625
}
2726

2827
function testInitialize() public {

contracts/foundry.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ optimizer = true
77
optimizer_runs = 200
88
via_ir = false
99

10-
# Exclude OpenZeppelin's test/mock/certora files
10+
# Only compile our contracts and core OpenZeppelin contracts
11+
include = [
12+
"*.sol",
13+
"lib/openzeppelin-contracts/contracts/**/*.sol",
14+
"lib/forge-std/src/**/*.sol",
15+
"lib/ds-test/src/**/*.sol",
16+
]
17+
18+
# Exclude problematic OpenZeppelin files
1119
exclude = [
1220
"lib/openzeppelin-contracts/certora/**",
1321
"lib/openzeppelin-contracts/test/**",
1422
"lib/openzeppelin-contracts/mocks/**",
23+
"lib/openzeppelin-contracts/lib/**",
1524
"node_modules/**",
1625
]
1726

src/daemon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ async fn serve_stream(
223223

224224
// For streaming, we'll simulate sending data in chunks
225225
// In a real implementation, this would stream actual data
226-
let chunks = vec![
226+
let chunks = [
227227
"Chunk 1: Starting data stream...\n",
228228
"Chunk 2: Processing your request...\n",
229229
"Chunk 3: Generating response...\n",

src/units.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl fmt::Display for UnitType {
3737

3838
impl UnitType {
3939
/// Parse unit type from string (case insensitive)
40-
pub fn from_str(s: &str) -> Self {
40+
pub fn parse_unit_type(s: &str) -> Self {
4141
match s.to_lowercase().as_str() {
4242
"bytes" | "byte" => UnitType::Bytes,
4343
"tokens" | "token" => UnitType::Tokens,
@@ -122,7 +122,7 @@ impl X402Headers {
122122
// Parse unit type
123123
if let Some(unit_type) = headers.get("x402-unit-type") {
124124
if let Ok(unit_str) = unit_type.to_str() {
125-
x402.unit_type = Some(UnitType::from_str(unit_str));
125+
x402.unit_type = Some(UnitType::parse_unit_type(unit_str));
126126
}
127127
}
128128

@@ -189,10 +189,14 @@ impl ConsumptionTracker {
189189

190190
/// Update consumption based on x402 headers or data size
191191
pub fn update_consumption(&mut self, headers: &X402Headers, data_size: usize) -> f64 {
192-
if self.provider_pricing && headers.units_consumed.is_some() {
193-
// Use provider-specified consumption
194-
let units = headers.units_consumed.unwrap();
195-
self.unit.consume(units)
192+
if self.provider_pricing {
193+
if let Some(units) = headers.units_consumed {
194+
// Use provider-specified consumption
195+
self.unit.consume(units)
196+
} else {
197+
// Fallback to byte-based consumption
198+
self.unit.consume(data_size as u64)
199+
}
196200
} else {
197201
// Fallback to byte-based consumption
198202
self.unit.consume(data_size as u64)
@@ -403,10 +407,10 @@ mod tests {
403407

404408
#[test]
405409
fn test_unit_type_parsing() {
406-
assert_eq!(UnitType::from_str("bytes"), UnitType::Bytes);
407-
assert_eq!(UnitType::from_str("TOKENS"), UnitType::Tokens);
410+
assert_eq!(UnitType::parse_unit_type("bytes"), UnitType::Bytes);
411+
assert_eq!(UnitType::parse_unit_type("TOKENS"), UnitType::Tokens);
408412
assert_eq!(
409-
UnitType::from_str("custom-unit"),
413+
UnitType::parse_unit_type("custom-unit"),
410414
UnitType::Custom("custom-unit".to_string())
411415
);
412416
}

0 commit comments

Comments
 (0)