You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
749 B

10 years ago
  1. package merkle
  2. import (
  3. . "github.com/tendermint/tendermint/common"
  4. "testing"
  5. )
  6. // TODO: Actually test. All this does is help debug.
  7. // consensus/part_set tests some of this functionality.
  8. func TestHashTreeMerkleTrail(t *testing.T) {
  9. numHashes := 5
  10. // Make some fake "hashes".
  11. hashes := make([][]byte, numHashes)
  12. for i := 0; i < numHashes; i++ {
  13. hashes[i] = RandBytes(32)
  14. t.Logf("hash %v\t%X\n", i, hashes[i])
  15. }
  16. hashTree := HashTreeFromHashes(hashes)
  17. for i := 0; i < len(hashTree); i++ {
  18. t.Logf("tree %v\t%X\n", i, hashTree[i])
  19. }
  20. for i := 0; i < numHashes; i++ {
  21. t.Logf("trail %v\n", i)
  22. trail := HashTrailForIndex(hashTree, i)
  23. for j := 0; j < len(trail); j++ {
  24. t.Logf("index: %v, hash: %X\n", j, trail[j])
  25. }
  26. }
  27. }