Skip to content

Commit 75964f6

Browse files
committed
feat: new e2e packets
1 parent 7ceceaf commit 75964f6

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

src/e2e/main.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ async fn test_sender(esp_id: u32, senders: SharedSenders, tests: TestsRoot) -> R
157157
let unix_tx = UNIX_SENDER.get().expect("UNIX_SENDER not set!");
158158
let mut rx = spawn_new_sender(&senders, esp_id).await?;
159159

160-
send_test_packet(&unix_tx, &mut rx, esp_id, TestPacketData::Start).await?;
161160
send_test_packet(&unix_tx, &mut rx, esp_id, TestPacketData::ResetState).await?;
162161

163162
let mut prev_idx: Option<usize> = None;
@@ -251,11 +250,21 @@ async fn run_step(
251250
}
252251
TestStep::SolveTime(time) => {
253252
*last_time = *time;
254-
send_test_packet(&unix_tx, rx, esp_id, TestPacketData::SolveTime(*time)).await?;
253+
send_test_packet(&unix_tx, rx, esp_id, TestPacketData::StackmatTime(*time)).await?;
254+
255+
tokio::time::sleep(Duration::from_millis(*time + 100)).await;
255256
}
256257
TestStep::SolveTimeRng => {
257258
*last_time = random_time;
258-
send_test_packet(&unix_tx, rx, esp_id, TestPacketData::SolveTime(random_time)).await?;
259+
send_test_packet(
260+
&unix_tx,
261+
rx,
262+
esp_id,
263+
TestPacketData::StackmatTime(random_time),
264+
)
265+
.await?;
266+
267+
tokio::time::sleep(Duration::from_millis(random_time + 100)).await;
259268
}
260269
TestStep::Snapshot => {
261270
send_test_packet(&unix_tx, rx, esp_id, TestPacketData::Snapshot).await?;
@@ -267,14 +276,14 @@ async fn run_step(
267276
send_test_packet(&unix_tx, rx, esp_id, TestPacketData::ScanCard(*card_id)).await?;
268277
}
269278
TestStep::Button { ref name, time } => {
270-
let pins = tests.buttons.get(name);
271-
if let Some(pins) = pins {
279+
let pin = tests.buttons.get(name);
280+
if let Some(&pin) = pin {
272281
send_test_packet(
273282
&unix_tx,
274283
rx,
275284
esp_id,
276285
TestPacketData::ButtonPress {
277-
pins: pins.to_owned(),
286+
pin,
278287
press_time: *time,
279288
},
280289
)

src/e2e/structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct CompetitorInfo {
2424
pub struct TestsRoot {
2525
pub dump_state_after_test: bool,
2626
pub cards: HashMap<u64, CompetitorInfo>,
27-
pub buttons: HashMap<String, Vec<u8>>,
27+
pub buttons: HashMap<String, u8>,
2828
pub tests: Vec<TestData>,
2929
}
3030

tests.json

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"dumpStateAfterTest": true,
2+
"dumpStateAfterTest": false,
33
"cards": {
44
"69420": {
55
"registrantId": 1,
@@ -21,18 +21,10 @@
2121
}
2222
},
2323
"buttons": {
24-
"penalty": [
25-
32
26-
],
27-
"inspect": [
28-
27
29-
],
30-
"delegate": [
31-
26
32-
],
33-
"submit": [
34-
33
35-
]
24+
"penalty": 3,
25+
"inspect": 0,
26+
"delegate": 1,
27+
"submit": 2
3628
},
3729
"tests": [
3830
{
@@ -54,21 +46,21 @@
5446
"type": "Button",
5547
"data": {
5648
"name": "penalty",
57-
"time": 50
49+
"time": 100
5850
}
5951
},
6052
{
6153
"type": "Button",
6254
"data": {
6355
"name": "penalty",
64-
"time": 50
56+
"time": 100
6557
}
6658
},
6759
{
6860
"type": "Button",
6961
"data": {
7062
"name": "submit",
71-
"time": 50
63+
"time": 100
7264
}
7365
},
7466
{
@@ -107,14 +99,14 @@
10799
"type": "Button",
108100
"data": {
109101
"name": "penalty",
110-
"time": 50
102+
"time": 100
111103
}
112104
},
113105
{
114106
"type": "Button",
115107
"data": {
116108
"name": "submit",
117-
"time": 50
109+
"time": 100
118110
}
119111
},
120112
{
@@ -193,28 +185,28 @@
193185
"type": "Button",
194186
"data": {
195187
"name": "penalty",
196-
"time": 50
188+
"time": 100
197189
}
198190
},
199191
{
200192
"type": "Button",
201193
"data": {
202194
"name": "penalty",
203-
"time": 50
195+
"time": 100
204196
}
205197
},
206198
{
207199
"type": "Button",
208200
"data": {
209201
"name": "penalty",
210-
"time": 50
202+
"time": 100
211203
}
212204
},
213205
{
214206
"type": "Button",
215207
"data": {
216208
"name": "submit",
217-
"time": 50
209+
"time": 100
218210
}
219211
},
220212
{

unix-utils/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ pub struct UnixError {
1212
#[derive(Debug, Clone, Serialize, Deserialize)]
1313
#[serde(tag = "type", content = "data")]
1414
pub enum TestPacketData {
15-
Start,
16-
End,
1715
ResetState,
1816
ScanCard(u64),
19-
ButtonPress { pins: Vec<u8>, press_time: u64 },
20-
SolveTime(u64),
17+
ButtonPress { pin: u8, press_time: u64 },
18+
StackmatTime(u64),
19+
StackmatReset,
2120
Snapshot,
2221
}
2322

0 commit comments

Comments
 (0)