Skip to content

Commit 7bba163

Browse files
author
Claude
committed
test(integration): use valid hex hashes and non-empty Merkle leaves
The integration suite (newly runnable now that it builds against the core package instead of the never-building ochrance-fs) had 5 failures, all from invalid test data rather than code defects: - Hashes like "hash_0"/"wrong_hash"/"correct_0" are not hex, so validateManifest correctly rejected them (tests 02, 03, 23) and the lexer could not form a HASH token on round-trip (test 41). Use hex digests. - test 46 built a Merkle tree from two emptyHash leaves; with the XOR placeholder combiner, xor 0 0 = 0, so the root was (correctly) empty while the test expected non-empty. Use distinct non-empty leaves. Verified: integration tests now 55/55; A2ML 16/16; property 47/47.
1 parent 5da1afe commit 7bba163

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

tests/integration/IntegrationTests.idr

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ createTestFS numBlocks =
4646
MkFSState
4747
numBlocks
4848
(\idx => if idx < numBlocks
49-
then Just (MkHash BLAKE3 ("hash_" ++ show idx))
49+
then Just (MkHash BLAKE3 ("deadbeef" ++ show idx))
5050
else Nothing)
5151
(MkManifestData "0.1.0" "test-filesystem" Nothing)
5252

@@ -94,7 +94,7 @@ test_DetectHashMismatch = do
9494
let fs = createTestFS 2
9595

9696
-- Create manifest with different hash for block 0
97-
let wrongHash = MkHash BLAKE3 "wrong_hash"
97+
let wrongHash = MkHash BLAKE3 "baadf00d"
9898
let wrongRef = MkRef "block_0" wrongHash
9999
let manifest = MkManifest
100100
(MkManifestData "0.1.0" "test-filesystem" Nothing)
@@ -176,8 +176,8 @@ test_LinearVerifyAndRepair = do
176176
-- Create manifest with correct hashes
177177
let manifest = MkManifest
178178
(MkManifestData "0.1.0" "test-filesystem" Nothing)
179-
[ MkRef "block_0" (MkHash BLAKE3 "correct_0")
180-
, MkRef "block_1" (MkHash BLAKE3 "correct_1")
179+
[ MkRef "block_0" (MkHash BLAKE3 "c0ffee00")
180+
, MkRef "block_1" (MkHash BLAKE3 "c0ffee01")
181181
]
182182
Nothing
183183
Nothing
@@ -247,8 +247,10 @@ test_RoundtripSerialization = do
247247
test_MerkleTreeVerification : IO TestResult
248248
test_MerkleTreeVerification = do
249249
-- Create simple Merkle tree
250-
let leaf1 = Leaf emptyHash
251-
let leaf2 = Leaf emptyHash
250+
-- distinct, non-empty leaves: with the XOR placeholder combiner, two *empty*
251+
-- leaves would xor to an empty root, so use non-zero leaf hashes here.
252+
let leaf1 = Leaf (replicate 32 1)
253+
let leaf2 = Leaf (replicate 32 2)
252254
let tree = Node leaf1 leaf2
253255

254256
-- Get root hash

0 commit comments

Comments
 (0)