Phase 1 Testing: Core primitives (hash + CBOR + memory store) #3
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
验证目标
从零开始建立 monorepo,实现最小可用的 CAS:能存节点、取节点、验证 hash。
前置
@uncaged/json-cas(core,纯计算,零平台 API)测试步骤
Step 1: monorepo 结构可构建
预期: 构建成功,无报错
Step 2: CBOR deterministic 编码
相同对象不同 key 顺序 → 相同 bytes
预期:
encode({ z:1, a:2 })===encode({ a:2, z:1 })Step 3: hash 计算
hash(typeHash, payload)→ 13-char Crockford Base32预期: 幂等;type 参与计算(不同 type + 相同 payload → 不同 hash)
Step 4: memory store put/get round-trip
预期:
node.type === metaHash,node.payload.name === "test",node.timestamp自动填充Step 5: verify 完整性
预期:
verify(h, node) === trueStep 6: 幂等 put
预期: 重复 put 返回相同 hash,timestamp 保留首次值
验证完成标准
✅ 所有 checkbox 打勾
✅
bun test全过✅ biome check 无报错
Ref: #1