Dorian 0d073fa89e Add comprehensive installation and setup documentation
- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
2026-01-27 17:18:21 +00:00

50 lines
1.1 KiB
JavaScript

import { garbage } from 'ipld-garbage';
import {
decode,
encode
} from '../cborg.js';
import chai from 'chai';
const {assert} = chai;
describe('Fuzz round-trip', () => {
it('random objects', function () {
this.timeout(5000);
for (let i = 0; i < 1000; i++) {
const obj = garbage(300, { weights: { CID: 0 } });
const byts = encode(obj);
const decoded = decode(byts);
assert.deepEqual(decoded, obj);
}
});
it('circular references error', () => {
let obj = {};
obj.obj = obj;
assert.throws(() => encode(obj), /circular references/);
obj = {
blip: [
1,
2,
{ blop: {} }
]
};
obj.blip[2].blop.boop = obj;
assert.throws(() => encode(obj), /circular references/);
obj = {
blip: [
1,
2,
{ blop: {} }
]
};
obj.blip[2].blop.boop = obj.blip;
assert.throws(() => encode(obj), /circular references/);
obj = {
blip: {},
bloop: {}
};
obj.bloop = obj.blip;
assert.doesNotThrow(() => encode(obj));
const arr = [];
arr[0] = arr;
assert.throws(() => encode(arr), /circular references/);
});
});