mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 11:45:02 +01:00
first test passes uwu
This commit is contained in:
parent
6f5fef2f23
commit
9a819bc3f4
7 changed files with 30 additions and 24 deletions
|
|
@ -257,8 +257,15 @@ impl Connection {
|
|||
debug!(?method, "Received method");
|
||||
|
||||
match method {
|
||||
Method::ConnectionClose { .. } => {
|
||||
// todo: handle closing
|
||||
Method::ConnectionClose {
|
||||
reply_code,
|
||||
reply_text,
|
||||
class_id,
|
||||
method_id,
|
||||
} => {
|
||||
info!(%reply_code, %reply_text, %class_id, %method_id, "Closing connection");
|
||||
self.send_method(0, Method::ConnectionCloseOk {}).await?;
|
||||
return Err(ProtocolError::GracefulClose.into());
|
||||
}
|
||||
Method::ChannelOpen { .. } => self.channel_open(frame.channel).await?,
|
||||
Method::ChannelClose { .. } => self.channel_close(frame.channel, method).await?,
|
||||
|
|
|
|||
|
|
@ -209,9 +209,6 @@ pub mod parse {
|
|||
let (input, _) = tag(31_u16.to_be_bytes())(input)?;
|
||||
let (input, channel_max) =
|
||||
domain_short(input).map_err(fail_err("field channel-max in method tune-ok"))?;
|
||||
if channel_max == 0 {
|
||||
fail!("number was 0 for field channel_max")
|
||||
}
|
||||
let (input, frame_max) =
|
||||
domain_long(input).map_err(fail_err("field frame-max in method tune-ok"))?;
|
||||
let (input, heartbeat) =
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
"license": "MIT",
|
||||
"scripts": {
|
||||
"fmt": "prettier -w .",
|
||||
"test": "node test-all.js"
|
||||
"test": "prettier -c . && node test-all.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/amqplib": "^0.8.2",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {connectAmqp, sleep} from './utils/utils.js';
|
||||
import { connectAmqp, sleep } from './utils/utils.js';
|
||||
|
||||
const connection = await connectAmqp();
|
||||
|
||||
|
|
@ -6,8 +6,6 @@ const channel = await connection.createChannel();
|
|||
|
||||
console.log('Successfully opened channel');
|
||||
|
||||
await sleep(100_000);
|
||||
|
||||
await channel.close();
|
||||
await connection.close();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {connectAmqp} from "./utils/utils.js";
|
||||
import { connectAmqp } from './utils/utils.js';
|
||||
|
||||
const connection = await connectAmqp();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
import {connect} from "amqplib";
|
||||
|
||||
import { connect } from 'amqplib';
|
||||
|
||||
export const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
export const connectAmqp = async () => {
|
||||
return connect({
|
||||
protocol: 'amqp',
|
||||
hostname: 'localhost',
|
||||
port: 5672,
|
||||
username: 'admin',
|
||||
password: '',
|
||||
frameMax: 238556565673829,
|
||||
}, {
|
||||
|
||||
});
|
||||
}
|
||||
return connect(
|
||||
{
|
||||
protocol: 'amqp',
|
||||
hostname: 'localhost',
|
||||
port: 5672,
|
||||
username: 'admin',
|
||||
password: '',
|
||||
frameMax: 0,
|
||||
channelMax: 1000,
|
||||
},
|
||||
{}
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -176,11 +176,14 @@ pub type IResult<'a, T> = nom::IResult<&'a [u8], T, TransError>;
|
|||
).ok();
|
||||
}
|
||||
"short" => {
|
||||
writeln!(
|
||||
// todo https://github.com/amqp-node/amqplib/issues/672
|
||||
if var_name != "channel_max" {
|
||||
writeln!(
|
||||
self.output,
|
||||
r#" if {var_name} == 0 {{ fail!("number was 0 for field {var_name}") }}"#
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue