SHA256
Разделить среды и закрепить лицензии в HEADER 1.0
This commit is contained in:
@@ -16,7 +16,7 @@ const special = new Map([[SHINE_CORE_LINE_PROFILE,'P'],[SHINE_CORE_LINE_CONNECTI
|
||||
test('CORE v2 namespace и числовые линии согласованы в Java и UI', () => {
|
||||
const server=fs.readFileSync(new URL('../../SHiNE-server/shine-server-blockchain/src/main/java/blockchain/ShineProtocolTags.java',import.meta.url),'utf8');
|
||||
assert.equal(SHINE_CORE_NAMESPACE,'SHiNE');
|
||||
assert.match(server,/CORE_NAMESPACE\s*=\s*"SHiNE"/);
|
||||
assert.match(server,/CORE_NAMESPACE\s*=\s*utils.config.ServerEnvironment.ARWEAVE_APP_TAG/);
|
||||
assert.equal(SHINE_CORE_MAX_BLOCK_NUMBER,2147482623);
|
||||
assert.deepEqual([...special.keys()],[2147483645,2147483646,2147483647]);
|
||||
});
|
||||
@@ -41,7 +41,7 @@ test('CORE/CONTENT fixtures: BigEndian, hash, ANS-104 Ed25519 и подписи
|
||||
newCore.writeInt32BE(history.length,33);
|
||||
newCore.writeBigInt64BE(core.readBigInt64BE(37),37);
|
||||
unhex(contentHash).copy(newCore,45); unhex(contentId).copy(newCore,77);
|
||||
const tags=[{name:'App',value:'test5599'},{name:'n',value:String(history.length)}];
|
||||
const tags=[{name:'App',value:'test5570'},{name:'n',value:String(history.length)}];
|
||||
if(core.length===149) {
|
||||
const line=core.readInt32BE(109), prev=core.readInt32BE(113);
|
||||
newCore.writeInt32BE(line,109); newCore.writeInt32BE(prev,113); unhex(history[prev]).copy(newCore,117);
|
||||
@@ -70,7 +70,7 @@ test('Minimal pair codec and container: exact vectors, tampering, unsigned lengt
|
||||
for (const [name,ownerHex,coreHex,coreHash,contentHex,contentHash,coreItemHex,coreId,contentItemHex,contentId] of rows) {
|
||||
const core=decodeCore(unhex(coreHex)), content=decodeContent(unhex(contentHex)), owner=unhex(ownerHex);
|
||||
assert.equal(hex(encodeCore(core)),coreHex); assert.equal(hex(encodeContent(content)),contentHex);
|
||||
const signed=await signCoreContentPair({owner32:owner,privateKey:key,content, ...core});
|
||||
const signed=await signCoreContentPair({arweaveAppTag:"SHiNE",owner32:owner,privateKey:key,content, ...core});
|
||||
assert.notEqual(hex(signed.coreDataItem),coreItemHex,name); assert.equal(hex(signed.contentDataItem),contentItemHex,name);
|
||||
const raw=packCoreContent(signed.coreDataItem,signed.contentDataItem);
|
||||
assert.equal(Buffer.from(raw).readUInt32BE(),signed.coreDataItem.length);
|
||||
@@ -97,15 +97,15 @@ test('HEADER 1.0 signed CORE/CONTENT and inspector accept arbitrary UTF-8 licens
|
||||
const key=await crypto.subtle.importKey('pkcs8',pkcs8,{name:'Ed25519'},false,['sign']);
|
||||
const owner=unhex(rows[0][1]);
|
||||
const login=Buffer.from('Alice@shine');
|
||||
for (const license of ['', 'CC-BY-NC-4.0', 'Лицензия 🌞', '\ufeffx', 'x'.repeat(255)]) {
|
||||
for (const license of ['', 'CC-BY-NC-4.0', 'Лицензия 🌞', '\ufeffx', 'x'.repeat(300)]) {
|
||||
const bytes=Buffer.from(license);
|
||||
const body=Buffer.concat([Buffer.from('SHiNE'),Buffer.of(login.length),login,Buffer.of(1, 0, 0, bytes.length),bytes,owner]);
|
||||
const body=Buffer.concat([Buffer.from('SHiNE'),Buffer.of(login.length),login,Buffer.of(1, 0, 0, bytes.length >> 8, bytes.length & 255),bytes,owner]);
|
||||
const content={type:0,subType:0,version:1,body};
|
||||
const signed=await signCoreContentPair({owner32:owner,privateKey:key,content,prevCoreHash32:new Uint8Array(32),blockNumber:0,timestamp:1700001000n,line:null});
|
||||
const signed=await signCoreContentPair({arweaveAppTag:"SHiNE",owner32:owner,privateKey:key,content,prevCoreHash32:new Uint8Array(32),blockNumber:0,timestamp:1700001000n,line:null});
|
||||
const raw=packCoreContent(signed.coreDataItem,signed.contentDataItem);
|
||||
const result=await inspectBlockchainDataItem(Buffer.from(raw).toString('base64'));
|
||||
assert.equal(result.frame.body.license,license);
|
||||
assert.equal(result.frame.version,1);
|
||||
await assert.rejects(signCoreContentPair({owner32:owner,privateKey:key,content:{...content,version:4},prevCoreHash32:new Uint8Array(32),blockNumber:0,timestamp:1700001000n,line:null}));
|
||||
await assert.rejects(signCoreContentPair({arweaveAppTag:"SHiNE",owner32:owner,privateKey:key,content:{...content,version:4},prevCoreHash32:new Uint8Array(32),blockNumber:0,timestamp:1700001000n,line:null}));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user