Skip to content

Commit f9dda39

Browse files
committed
Fix empty tree test to expect InvalidOperationException
- Update test to expect exception for empty trees without root - Empty trees without root are not valid for selective disclosure - This prevents potential issues in calling code
1 parent a82d6b8 commit f9dda39

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

tests/Evoq.Blockchain.Tests/Blockchain.Merkle/MerkleTreeV1Tests.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -834,23 +834,18 @@ public void From_WithSelectivePrivacy_ShouldCreateMixedTree()
834834
}
835835

836836
[TestMethod]
837-
public void From_WithEmptyTree_ShouldCreateEmptyTree()
837+
[ExpectedException(typeof(InvalidOperationException))]
838+
public void From_WithEmptyTree_ShouldThrowInvalidOperationException()
838839
{
839-
// Arrange - Create empty source tree
840+
// Arrange - Create empty tree without root
840841
var sourceTree = new MerkleTree("1.0");
841842
// Note: We don't call RecomputeSha256Root() on empty trees as it throws an exception
842843

843-
// Act - Create selective disclosure tree
844-
var selectiveTree = MerkleTree.From(
844+
// Act & Assert - Should throw because empty trees without root are not valid for selective disclosure
845+
MerkleTree.From(
845846
sourceTree,
846847
makePrivate: leaf => true
847848
);
848-
849-
// Assert - Should be empty tree with same metadata
850-
Assert.AreEqual(sourceTree.Root, selectiveTree.Root);
851-
Assert.AreEqual(sourceTree.Metadata.Version, selectiveTree.Metadata.Version);
852-
Assert.AreEqual(sourceTree.Metadata.HashAlgorithm, selectiveTree.Metadata.HashAlgorithm);
853-
Assert.AreEqual(0, selectiveTree.Leaves.Count);
854849
}
855850

856851
[TestMethod]

0 commit comments

Comments
 (0)