Add native metaprotocol field

This commit is contained in:
recovery committed 2026-10-05 04:03:16 +00:00
1 parent 5d1a1ae866
commit bcc9f0f1cd
7 files changed
+52 -19

No files matched your search

+22
View File
@@ -453,3 +453,25 @@ test('multiple input ranges flow FIFO across outputs and protect inscribed fee t
assert.throws(()=>chain.submitPackage([Tx.encode(burn).hex]),/fee loss/);
assert.deepEqual(chain.snapshot(),after); assert.ok(after.mempool.length>before.mempool.length);
});
test("native metaprotocol tag 7 round-trips and overrides metadata.protocol for tracking", () => {
const {ins,chain} = setup();
const id = ins.inscribe("hello", null, {protocol:"metadata-fallback", note:"kept"}, {metaprotocol:"tea-v1"});
const record = chain.transactions.get(id.slice(0,-2));
const witness = record.tx.vin.find(i => i.witness?.length === 3).witness;
const item = readEnvelope(witness);
assert.equal(item.metaprotocol, "tea-v1");
assert.deepEqual(item.metadata, {protocol:"metadata-fallback", note:"kept"});
const event = new MetadataIndex(chain).events.find(e => e.id === id);
assert.equal(event.metaprotocol, "tea-v1");
assert.equal(event.protocol, "tea-v1");
assert.deepEqual(new MetadataIndex(chain).forProtocol("tea-v1").map(e => e.id), [id]);
});
test("metadata.protocol remains a fallback when native metaprotocol is absent", () => {
const {ins,chain} = setup();
const id = ins.inscribe("legacy", null, {protocol:"legacy-protocol"});
const event = new MetadataIndex(chain).events.find(e => e.id === id);
assert.equal(event.metaprotocol, null);
assert.equal(event.protocol, "legacy-protocol");
});