Skip to content

Commit e3155fd

Browse files
committed
cleaned test_data file, removed explicit function inlining
1 parent 9233120 commit e3155fd

File tree

2 files changed

+0
-296
lines changed

2 files changed

+0
-296
lines changed

target_chains/stylus/contracts/pyth-receiver/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ impl PythReceiver {
352352
Vec::new()
353353
}
354354

355-
#[inline]
356355
fn is_no_older_than(&self, publish_time: U64, max_age: u64) -> bool {
357356
self.get_current_timestamp()
358357
.saturating_sub(publish_time.to::<u64>())
Lines changed: 0 additions & 295 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
1-
use alloy_primitives::U256;
21
use hex::FromHex;
32

4-
fn from_cairo_byte_array_data(data: &[U256], num_last_bytes: usize) -> Vec<u8> {
5-
let mut result = Vec::new();
6-
7-
if data.is_empty() {
8-
return result;
9-
}
10-
11-
for (i, &item) in data.iter().enumerate() {
12-
let buf = item.to_be_bytes::<32>();
13-
14-
if i == data.len() - 1 {
15-
if num_last_bytes > 0 {
16-
let start_idx = 32 - num_last_bytes;
17-
result.extend_from_slice(&buf[start_idx..]);
18-
}
19-
} else {
20-
result.extend_from_slice(&buf[1..]);
21-
}
22-
}
23-
24-
result
25-
}
26-
273
pub fn good_update1() -> Vec<u8> {
284
let hex_str = "504e41550100000003b801000000040d0216f3809b6396fdb0708bc94515ddb96a3bc8fb1993916e74f522ab4c34a268836a0bb38786303b55cc40ecb50d18c92bf9fd61688a143f3d24a73a3f468e4ab0000365be4f3a330fe96bab246922d9fa4816a865dec40d7c522e37f7e3605673b8f52eb30a4dad7aee3e1ac4b21337b8831c6147ef6e359e843b307872e83b5c7fe80004b6f12766eb395d04bdb146b1b69a4b9a8831a9c9ea20ee841d55efe72c629aef17038b925584493af7882981260b09587d73b6463415f4e1f8fb0a2a2c959c8301065c18a776cf558e43494bf31dd26ac0e3aed07a01ca0063abcfca3736b892368e4bf8b957f2d2e83ff9eb3fa8f667ef97a5f48c286103f70fda4a72e077719a0200085896c930febfb864a8c292bde679092e386e53389cb2d26bd12ceed64d22c0cd27676dc5c46d3e3c5949abbce89d4cc5ec378cfbf9ab1b0c24cfeb3371df4864000a1c67e67adea9f8a71eee76765f1fe4c7d9539d21b62d0336513692897cc6acbe1c827599a1f8c73b7478e8d788443b4cfd4e373344ab1ac9f771c9c494124863000b7e08e1cc1291340e6ec7d1b04c6a9c63f74077a074ee68edf4f95cf24c9743620f8abc8213884c8e4848fb76ec319d365e0cdc746a6e534a4cb828e51719be79010c61a2fedeedf34e4c80624d80cb93e24bafe9f6d23339173004d84e61c2395bfb5f552e87b901beb192ba6f4fc905eae30317c52b8614071e08a265592f24e8de000de38d08612edc5ebc863ea5a96325cb991750a94ff0e50f86bc322cce81db7cd17cb4ed3703f7477eb111a9d881e1345f5b79d618814f31b46034196563ee6a18000e5b11510d585a2decaba0be9e71386865b6069061478f7254d7852d55116569eb426c385267e40264d16db08e0f1a9e2c44b7d1c926d3c3ba662b212572386483010fa1ad0278402104b146b6f4d1cf85ac4df961d24eea0c7948b700f9973596cad130abfff25feef37125ba38507f34308d967455651e7014e40264a0c6510d3af001101f2e4e70868d6c327c92229537f1ffa33e488da3140ccc086f8210b437b162190742bd01ad1cb495a93f20045b4bb47e1562fdd82a8a1548d87d788a492b17190111847f5095df3edefc58be0956aee19876e850516e132506fd67504afee3c8cf240f07fb607b3c8282a2e56dcad23959e6759bdf8ad345ba8150448da56ff34fcc016866baf800000000001ae101faedac5851e32b9b23b5f9411a8c2bac4aae3ed4dd7b811dd1a72ea4aa71000000000880cea9014155575600000000000d8e5c8d0000271085e6ab1bb044f57c4cd6c1d32aa0a82a5032198301005500e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43000009f9828e420300000001284f2da6fffffff8000000006866baf8000000006866baf8000009f3b955a26000000001062cb8780c1283a49180b4986f0dec3c746d3daeb597887747b8f66a09876e1253a1ebb8a6bc4a5793daaa343db6057b82ec29715d7e1db0ffd6db523f7b80b03e3866ef5f5c80728801b92f5acecc28d8517e5615335d89c553f94b4370f3a20be0bc23e0fd401c4e5bd8bd32948a26233fc48f116428a490f087030ccfc442753e3074e2b9bbc1c61a009d86aaa200645c627a6b7f2f6597e34c60b14a58ef2583bcbb1d0e21b71a264fad2648ecc545031c7ed598772ffe875bf94a488389a49e6025e1b2a1f07ec598d0d9aa8ef7dd2733c8502c49d1d1323f1ae664e82e8a5e14978d52ab448ba9b1afc78f06c8cd17415a17";
295
let bytes = Vec::from_hex(hex_str).expect("Invalid hex string");
@@ -41,274 +17,3 @@ pub fn multiple_updates() -> Vec<u8> {
4117
let bytes = Vec::from_hex(hex_str).expect("Invalid hex string");
4218
bytes
4319
}
44-
45-
pub fn good_vm1() -> Vec<u8> {
46-
let bytes = [
47-
U256::from_str_radix(
48-
"1766847066033410293701000231337210964058791470455465385734308943533652138",
49-
10,
50-
)
51-
.unwrap(),
52-
U256::from_str_radix(
53-
"250126301534699068413432844632573953364878937343368310395142095034982913232",
54-
10,
55-
)
56-
.unwrap(),
57-
U256::from_str_radix(
58-
"374780571002258088211231890250917843593951765403462661483498298003400611238",
59-
10,
60-
)
61-
.unwrap(),
62-
U256::from_str_radix(
63-
"23190137343211334092589308306056431640588154666326612124726174150537328574",
64-
10,
65-
)
66-
.unwrap(),
67-
U256::from_str_radix(
68-
"238750269065878649216923353030193912502813798896051725498208457553032584635",
69-
10,
70-
)
71-
.unwrap(),
72-
U256::from_str_radix(
73-
"29844190303057534696518006438077948796328243878877072296680853158289181326",
74-
10,
75-
)
76-
.unwrap(),
77-
U256::from_str_radix(
78-
"106329507856770018708432343978518079724691760719405501795955774399597471533",
79-
10,
80-
)
81-
.unwrap(),
82-
U256::from_str_radix(
83-
"50779865592261858016477142415230454208001695486195806892438697217059319645",
84-
10,
85-
)
86-
.unwrap(),
87-
U256::from_str_radix(
88-
"448669871976126446102256476358498380455807705600424321390063431836375575318",
89-
10,
90-
)
91-
.unwrap(),
92-
U256::from_str_radix(
93-
"115682669871397824853706713833773246708114483862317474710603223566297521279",
94-
10,
95-
)
96-
.unwrap(),
97-
U256::from_str_radix(
98-
"301634766618012930739391408723909107532790832406455099966028276947414082504",
99-
10,
100-
)
101-
.unwrap(),
102-
U256::from_str_radix(
103-
"104473166230846104217366042152018649207811514257244625711402436055500423094",
104-
10,
105-
)
106-
.unwrap(),
107-
U256::from_str_radix(
108-
"64445621634231668761998815864645440965239569561546522651415024970517905416",
109-
10,
110-
)
111-
.unwrap(),
112-
U256::from_str_radix(
113-
"192317190225976528694195501079591384434869624408066864018183189813956862386",
114-
10,
115-
)
116-
.unwrap(),
117-
U256::from_str_radix(
118-
"289982656017597431343118552054719821766658675456661448685110903889153449006",
119-
10,
120-
)
121-
.unwrap(),
122-
U256::from_str_radix(
123-
"218840601196095059731241556733624112758673153548932709011933806481899680620",
124-
10,
125-
)
126-
.unwrap(),
127-
U256::from_str_radix(
128-
"430933799927481265070475198137531816946660368757134588278434352703899277070",
129-
10,
130-
)
131-
.unwrap(),
132-
U256::from_str_radix(
133-
"69322998883710289192076494057541346430050879299268159627180404869988632073",
134-
10,
135-
)
136-
.unwrap(),
137-
U256::from_str_radix(
138-
"23862615839737051269352321086490452186237833007444069999578906611768140646",
139-
10,
140-
)
141-
.unwrap(),
142-
U256::from_str_radix(
143-
"444634264607471510688862284107804392707600799506487897206707262445172121289",
144-
10,
145-
)
146-
.unwrap(),
147-
U256::from_str_radix(
148-
"438038196736233160320436150616293672539386464061037100698335568417587662951",
149-
10,
150-
)
151-
.unwrap(),
152-
U256::from_str_radix(
153-
"4682255185797880874381673193118803274635247527626050223938224759013169366",
154-
10,
155-
)
156-
.unwrap(),
157-
U256::from_str_radix(
158-
"337620725992972686809095065321563509600769533202700218393281926304544120094",
159-
10,
160-
)
161-
.unwrap(),
162-
U256::from_str_radix(
163-
"106657917096532484607371891267699639824731774168349872862335217581425289654",
164-
10,
165-
)
166-
.unwrap(),
167-
U256::from_str_radix(
168-
"71240348385993236445536577509595968468284689483611375124653855125285401592",
169-
10,
170-
)
171-
.unwrap(),
172-
U256::from_str_radix(
173-
"347603391821038175842934311068097986460257977131947418186118379296987051086",
174-
10,
175-
)
176-
.unwrap(),
177-
U256::from_str_radix(
178-
"414263571545410645948841360836383289766662078574048514890988877286444618669",
179-
10,
180-
)
181-
.unwrap(),
182-
U256::from_str_radix(
183-
"250301638008739107522011802538487063969565433276260914336890309092111026583",
184-
10,
185-
)
186-
.unwrap(),
187-
U256::from_str_radix(
188-
"43192785595291340058788190601908070333310658291317702311902081",
189-
10,
190-
)
191-
.unwrap(),
192-
U256::from_str_radix(
193-
"52685537088250779930155363779405986390839624071318818148325576008719597568",
194-
10,
195-
)
196-
.unwrap(),
197-
U256::from_str_radix("14615204155786886573933667335033405822686404253588533", 10).unwrap(),
198-
];
199-
from_cairo_byte_array_data(&bytes, 22)
200-
}
201-
202-
pub fn test_price_update1() -> Vec<u8> {
203-
let bytes = [
204-
U256::from_str_radix(
205-
"141887862745809943100421399774809552050876420277163116849842965275903806689",
206-
10,
207-
)
208-
.unwrap(),
209-
U256::from_str_radix(
210-
"210740906737592158039211995620336526131859667363627655742687286503264782608",
211-
10,
212-
)
213-
.unwrap(),
214-
U256::from_str_radix(
215-
"437230063624699337579360546580839669896712252828825008570863758867641146081",
216-
10,
217-
)
218-
.unwrap(),
219-
U256::from_str_radix(
220-
"3498691308882995183871222184377409432186747119716981166996399082193594993",
221-
10,
222-
)
223-
.unwrap(),
224-
U256::from_str_radix(
225-
"1390200166945919815453709407753165121175395927094647129599868236",
226-
10,
227-
)
228-
.unwrap(),
229-
U256::from_str_radix(
230-
"222819573728193325268644030206737371345667885599602384508424089704440116301",
231-
10,
232-
)
233-
.unwrap(),
234-
U256::from_str_radix(
235-
"341318259000017461738706238280879290398059773267212529438772847337449455616",
236-
10,
237-
)
238-
.unwrap(),
239-
U256::from_str_radix(
240-
"1275126645346645395843037504005879519843596923369759718556759844520336145",
241-
10,
242-
)
243-
.unwrap(),
244-
U256::from_str_radix(
245-
"363528783578153760894082184744116718493621815898909809604883433584616420886",
246-
10,
247-
)
248-
.unwrap(),
249-
U256::from_str_radix(
250-
"301537311768214106147206781423041990995720118715322906821301413003463484347",
251-
10,
252-
)
253-
.unwrap(),
254-
U256::from_str_radix(
255-
"83150006264761451992768264969047148434524798781124754530141755679159432208",
256-
10,
257-
)
258-
.unwrap(),
259-
U256::from_str_radix(
260-
"96387772316726941183358990094337324283641753573556594738287498821253761827",
261-
10,
262-
)
263-
.unwrap(),
264-
U256::from_str_radix(
265-
"395908154570808692326126405856049827157095768069251211022053821585519235652",
266-
10,
267-
)
268-
.unwrap(),
269-
U256::from_str_radix(
270-
"87135893730137265929093180553063146337041045646221968026289709394440932141",
271-
10,
272-
)
273-
.unwrap(),
274-
U256::from_str_radix(
275-
"245333243912241114598596888050489286502591033459250287888834",
276-
10,
277-
)
278-
.unwrap(),
279-
];
280-
from_cairo_byte_array_data(&bytes, 25)
281-
}
282-
283-
#[cfg(test)]
284-
mod tests {
285-
use super::*;
286-
287-
#[test]
288-
fn test_conversion_logic() {
289-
let test_data = [U256::from(0x010203u32)];
290-
let result = from_cairo_byte_array_data(&test_data, 3);
291-
assert_eq!(result, vec![0x01, 0x02, 0x03]);
292-
}
293-
294-
#[test]
295-
fn test_good_update1_not_empty() {
296-
let data = good_update1();
297-
assert!(!data.is_empty());
298-
assert!(data.len() > 100);
299-
}
300-
301-
#[test]
302-
fn test_test_price_update1_not_empty() {
303-
let data = test_price_update1();
304-
assert!(!data.is_empty());
305-
assert!(data.len() > 100);
306-
}
307-
308-
#[test]
309-
fn test_good_vm1_not_empty() {
310-
let data = good_vm1();
311-
assert!(!data.is_empty());
312-
assert!(data.len() > 50);
313-
}
314-
}

0 commit comments

Comments
 (0)