Skip to content

Commit

Permalink
add CI (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
  • Loading branch information
cppcoffee authored Jan 3, 2024
1 parent 52d6ead commit 1859d56
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Check
run: cargo check --verbose
- name: Run tests
run: cargo test --verbose
7 changes: 4 additions & 3 deletions server/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub fn set_process_priority(n: i32) {
mod tests {
use super::*;
use pnet::packet::udp::UdpPacket;
use std::net::{IpAddr, Ipv4Addr};

#[test]
fn test_build_icmpv4_unreachable() {
Expand Down Expand Up @@ -136,15 +137,15 @@ mod tests {
let mut buffer = vec![0u8; 128];
let tcp_reset = build_tcp_reset(
&mut buffer[..tcp_min_size],
&IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)),
&IpAddr::V4(Ipv4Addr::new(2, 2, 2, 2)),
&incoming,
&IpAddr(Ipv4Addr::new(1, 1, 1, 1)),
&IpAddr(Ipv4Addr::new(2, 2, 2, 2)),
)
.unwrap();

assert_eq!(tcp_reset.get_source(), incoming.get_destination());
assert_eq!(tcp_reset.get_destination(), incoming.get_source());
assert_eq!(tcp_reset.get_acknowledgement(), incoming.get_sequence());
assert_eq!(tcp_reset.get_acknowledgement(), incoming.get_sequence() + 1);
assert_eq!(tcp_reset.get_sequence(), 0);
assert_eq!(tcp_reset.get_flags(), TcpFlags::RST);
assert_eq!(tcp_reset.get_window(), 0);
Expand Down

0 comments on commit 1859d56

Please sign in to comment.