Bump bedrock-provider in tests (#172)

This commit is contained in:
extremeheat 2022-01-07 18:36:38 -05:00 committed by GitHub
commit eb5ebc6650
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 20 deletions

View file

@ -3,7 +3,7 @@
*/
process.env.DEBUG = 'minecraft-protocol raknet'
const { Client } = require('bedrock-protocol')
const { ChunkColumn, Version } = require('bedrock-provider')
const ChunkColumn = require('bedrock-provider').chunk('bedrock_1.17.10')
async function test () {
const client = new Client({
@ -33,7 +33,7 @@ async function test () {
})
client.on('level_chunk', async packet => {
const cc = new ChunkColumn(Version.v1_4_0, packet.x, packet.z)
const cc = new ChunkColumn(packet.x, packet.z)
await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count)
const blocks = []
for (let x = 0; x < 16; x++) {

View file

@ -37,7 +37,7 @@
"@babel/eslint-parser": "^7.13.10",
"babel-eslint": "^10.1.0",
"bedrock-protocol": "file:.",
"bedrock-provider": "^1.0.0",
"bedrock-provider": "^2.0.0",
"leveldb-zlib": "^1.0.1",
"mocha": "^9.1.2",
"protodef-yaml": "^1.1.0",

View file

@ -3,6 +3,7 @@ const { dumpPackets } = require('../tools/genPacketDumps')
const { ping } = require('../src/createClient')
const { CURRENT_VERSION } = require('../src/options')
const { join } = require('path')
const { waitFor } = require('../src/datatypes/util')
// First we need to dump some packets that a vanilla server would send a vanilla
// client. Then we can replay those back in our custom server.
@ -31,7 +32,7 @@ async function startTest (version = CURRENT_VERSION, ok) {
console.assert(pongData, 'did not get valid pong data from server')
const respawnPacket = get('packets/respawn.json')
const chunks = await requestChunks(respawnPacket.x, respawnPacket.z, 1)
const chunks = await requestChunks(version, respawnPacket.x, respawnPacket.z, 1)
let loop
@ -150,31 +151,31 @@ async function startTest (version = CURRENT_VERSION, ok) {
client.connect()
}
const { ChunkColumn, Version } = require('bedrock-provider')
const { waitFor } = require('../src/datatypes/util')
const mcData = require('minecraft-data')('1.16')
async function requestChunks (version, x, z, radius) {
const ChunkColumn = require('bedrock-provider').chunk('bedrock_1.17.10')
// const mcData = require('minecraft-data')('1.16')
async function requestChunks (x, z, radius) {
const cxStart = (x >> 4) - radius
const cxEnd = (x >> 4) + radius
const czStart = (z >> 4) - radius
const czEnd = (z >> 4) + radius
const stone = mcData.blocksByName.stone
// const stone = mcData.blocksByName.stone
const chunks = []
for (let cx = cxStart; cx < cxEnd; cx++) {
for (let cz = czStart; cz < czEnd; cz++) {
console.log('reading chunk at ', cx, cz)
const cc = new ChunkColumn(Version.v1_2_0_bis, x, z)
const cc = new ChunkColumn(x, z)
for (let x = 0; x < 16; x++) {
for (let y = 0; y < 60; y++) {
for (let z = 0; z < 16; z++) {
cc.setBlock(x, y, z, stone)
}
}
}
// Temporarily disable until 1.18 PR in bedrock-provider goes through
// for (let x = 0; x < 16; x++) {
// for (let y = 0; y < 60; y++) {
// for (let z = 0; z < 16; z++) {
// cc.setBlock({ x, y, z }, stone)
// }
// }
// }
if (!cc) {
console.log('no chunk')

View file

@ -2,9 +2,10 @@
const vanillaServer = require('../tools/startVanillaServer')
const { Client } = require('../src/client')
const { waitFor } = require('../src/datatypes/util')
const { ChunkColumn, Version } = require('bedrock-provider')
async function test (version) {
const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + version)
// Start the server, wait for it to accept clients, throws on timeout
const handle = await vanillaServer.startServerAndWait(version, 1000 * 220)
console.log('Started server')
@ -45,7 +46,7 @@ async function test (version) {
}, 200)
client.on('level_chunk', async packet => { // Chunk read test
const cc = new ChunkColumn(Version.v1_4_0, packet.x, packet.z)
const cc = new ChunkColumn(packet.x, packet.z)
await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count)
})