SHA256
Новый формат блоков CORE/CONTENT test5595
This commit is contained in:
@@ -27,12 +27,20 @@ test('подмена payload не проходит проверку подпис
|
||||
assert.equal(proof.signatureValid, false);
|
||||
assert.notEqual(Buffer.from(proof.frameHashBytes).toString('hex'), expectedHash);
|
||||
});
|
||||
test('по API нельзя скачать DataItem с подменённым хешем или ID', async () => {
|
||||
const bytes = new Uint8Array(await readFile(signedPath));
|
||||
test('по API проверяется полная пара и отклоняется неверный номер, хеш или ID', async () => {
|
||||
const { packCoreContent } = await import('../js/services/core-content.js');
|
||||
const row = (await readFile(new URL('../../docs/Blockchain/vectors/core-content-v1.tsv', import.meta.url), 'utf8')).trim().split('\n')[1].split('\t');
|
||||
const bytes = packCoreContent(Buffer.from(row[6], 'hex'), Buffer.from(row[8], 'hex'));
|
||||
const id = Buffer.from(row[7], 'hex').toString('base64url');
|
||||
const args = { blockchainName: 'wwwww@shine-001', blockNumber: 0, blockHash: row[3], dataItemId: id };
|
||||
const authService = { ws: { request: async () => ({ status: 200, payload: {
|
||||
blockHash: expectedHash, blockBytesB64: Buffer.from(bytes).toString('base64'),
|
||||
blockHash: row[3], blockBytesB64: Buffer.from(bytes).toString('base64'),
|
||||
} }) } };
|
||||
assert.equal((await readSignedBlock({authService, blockchainName:'wwwww@shine-001',blockNumber:11,blockHash:expectedHash,dataItemId:expectedId})).bytes.length, 412);
|
||||
await assert.rejects(readSignedBlock({authService, blockchainName:'wwwww@shine-001',blockNumber:11,blockHash:expectedHash,dataItemId:'A'.repeat(43)}), /Arweave/);
|
||||
assert.deepEqual((await readSignedBlock({authService, ...args})).bytes, bytes);
|
||||
await assert.rejects(readSignedBlock({authService, ...args, dataItemId:'A'.repeat(43)}), /Arweave/);
|
||||
await assert.rejects(readSignedBlock({authService, ...args, blockNumber:1}), /номер/);
|
||||
await assert.rejects(readSignedBlock({authService, ...args, blockHash:'a'.repeat(64)}), /хеш/);
|
||||
bytes[bytes.length - 1] ^= 1;
|
||||
await assert.rejects(readSignedBlock({authService, ...args}));
|
||||
assert.equal(arweaveBlockUrl('../evil'), '');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user