RosegoldMC / rosegold.cr

Legal (Civ servers) minecraft bot client written in crystal
https://RosegoldMC.github.io/rosegold.cr/
MIT License
19 stars 8 forks source link

Create 2-way serialization specs for Clientbound (incoming) packets #104

Open grepsedawk opened 1 year ago

grepsedawk commented 1 year ago

You can read how to capture packets here: https://github.com/RosegoldMC/rosegold.cr/wiki/How-to-capture-packet-for-fixtures

I would like a spec for every clientbound packet we have that tests that we can properly read, then write -- then check that the original packet matches the written data

I do this with NBT, this is probably SUPER helpful: https://github.com/RosegoldMC/rosegold.cr/blob/main/spec/minecraft/nbt_spec.cr#L22

This will prove that we are at minimum parsing all of the data because we wouldn't be able to write it without first parsing properly

It's probably ideal to have all of these specs located in their own files, as this will allow us to add additional specs with minimal effort. Such as callback specs

Alternatively... we could have 1 serialization spec that simply parses all of the packets as found in spec/fixtures/packets/clientbound/

grepsedawk commented 1 year ago

Example spec: https://github.com/RosegoldMC/rosegold.cr/pull/138