Skip to content

Commit

Permalink
Merge PR #749 from 'pinheadmz/fix-spv-proof-test'
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Jul 5, 2022
2 parents ab8b151 + f99241c commit 959fb8d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/net-spv-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ describe('SPV', function() {
assert.strictEqual(full.chain.height, spv.chain.height);
});

it('should get proof of nonexistence', async () => {
it('should get proof of nonexistence from empty tree', async () => {
const waiter = new Promise((res, rej) => {
spv.pool.once('packet', (packet) => {
if (packet.type === packetTypes.PROOF)
res(packet.proof.type);
});
});

const ns = await spv.pool.resolve(nameHash);
const ns = await spv.pool.resolve(Buffer.alloc(32, 0xab));
assert.strictEqual(ns, null);
const proofType = await waiter;
assert.strictEqual(proofType, urkelTypes.TYPE_DEADEND);
Expand All @@ -135,6 +135,20 @@ describe('SPV', function() {
await mineBlocks(treeInterval + SAFE_ROOT);
});

it('should get proof of nonexistence from filled tree', async () => {
const waiter = new Promise((res, rej) => {
spv.pool.once('packet', (packet) => {
if (packet.type === packetTypes.PROOF)
res(packet.proof.type);
});
});

const ns = await spv.pool.resolve(Buffer.alloc(32, 0xab));
assert.strictEqual(ns, null);
const proofType = await waiter;
assert.strictEqual(proofType, urkelTypes.TYPE_COLLISION);
});

it('should get proof of existence with data', async () => {
const waiter = new Promise((res, rej) => {
spv.pool.once('packet', (packet) => {
Expand Down

0 comments on commit 959fb8d

Please sign in to comment.