import packet from '../networking/packet';

test('can construct a packet', () => {
  const p = new packet('my password');
  console.log(p);
  expect(p.token).toEqual('my password');
  expect(p.buffer).toEqual(new Uint8Array(0));
  expect(p.decode_offset).toEqual(0);
});

test('can encrypt and decrypt a packet', async () => {
  console.log('testing');
  const p = new packet('my password');
  p.encode_utf8('moose');
  await p.encrypt();
  await p.decrypt();
  const str = p.decode_utf8();
  expect(str).toEqual('moose');
});
