Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka committed Nov 18, 2024
1 parent b3e442c commit e99c3a3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM scratch
COPY docker-compose.yaml /docker-compose.yaml
COPY docker-compose.yml /docker-compose.yml
#ADD config/license /license
#ADD config/volumes/database /volumes/database
#ADD config/volumes/workload-logs /volumes/workload-logs
10 changes: 7 additions & 3 deletions crates/hyperion-bot/src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ pub struct Bot {

impl Bot {
#[tracing::instrument(skip_all, fields(name))]
pub async fn new(name: String, uuid: Uuid, addr: impl ToSocketAddrs + std::fmt::Display) -> Self {
pub async fn new(
name: String,
uuid: Uuid,
addr: impl ToSocketAddrs + std::fmt::Display,
) -> Self {
info!("connecting to {addr}");
let addr = TcpStream::connect(addr).await.unwrap();

let encoder = PacketEncoder::default();
let decoder = PacketDecoder::default();

let decode_buf = BytesMut::with_capacity(1024 * 1024); // 1 MiB

Self {
Expand Down
5 changes: 1 addition & 4 deletions crates/hyperion-bot/src/bot/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use antithesis::{assert_always, assert_never, random::AntithesisRng};
use eyre::bail;
use rand::Rng;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tracing::info;
use valence_protocol::{
Bounded, Encode, PROTOCOL_VERSION, Packet, VarInt, packets,
Bounded, PROTOCOL_VERSION, Packet, VarInt, packets,
packets::handshaking::handshake_c2s::HandshakeNextState,
};

Expand All @@ -16,8 +15,6 @@ impl Bot {

let protocol_version: i32 = random_either(|| PROTOCOL_VERSION, || rng.r#gen::<i32>());

let is_correct_protocol_version = protocol_version == PROTOCOL_VERSION;

let addr = "placeholder";

let packet = packets::handshaking::HandshakeC2s {
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperion-bot/src/generate.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mod name;
pub use name::{generate as name, Name};
pub use name::generate as name;
8 changes: 4 additions & 4 deletions crates/hyperion-bot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ mod util;
mod bot;

pub async fn bootstrap(config: &Config) {
// Wait for TCP port to be available
// Wait for TCP port to be available
util::wait_for_tcp_port(&config.host).await;
// todo: use life cycle

let mut rng = AntithesisRng;

let first_name = generate::name();
assert_sometimes!(first_name.is_valid, "First name is never invalid");
assert_sometimes!(!first_name.is_valid, "First name is always valid");

let first_uuid: u128 = rng.r#gen();
let first_uuid = Uuid::from_u128(first_uuid);

let mut join_set = JoinSet::new();

for _ in 0..config.max_number_of_bots {
Expand All @@ -37,6 +37,6 @@ pub async fn bootstrap(config: &Config) {
bot.await.handshake().await.unwrap();
});
}

join_set.join_all().await;
}
14 changes: 6 additions & 8 deletions crates/hyperion-bot/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ use rand::Rng;

pub fn random_either<T>(left: impl FnOnce() -> T, right: impl FnOnce() -> T) -> T {
let mut rng = AntithesisRng;
if rng.r#gen::<bool>() {
left()
} else {
right()
}
if rng.r#gen::<bool>() { left() } else { right() }
}

use tokio::net::TcpStream;
use tokio::time::{sleep, Duration};
use tokio::{
net::TcpStream,
time::{Duration, sleep},
};
use tracing::{info, warn};

pub async fn wait_for_tcp_port(addr: &str) {
Expand All @@ -28,4 +26,4 @@ pub async fn wait_for_tcp_port(addr: &str) {
}
}
}
}
}
3 changes: 1 addition & 2 deletions events/proof-of-concept/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#![feature(iter_from_coroutine)]
#![feature(exact_size_is_empty)]

use std::collections::HashSet;
use std::net::ToSocketAddrs;
use std::{collections::HashSet, net::ToSocketAddrs};

use flecs_ecs::prelude::*;
use hyperion::{
Expand Down

0 comments on commit e99c3a3

Please sign in to comment.