-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
113 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package bitcoin | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/btcsuite/btcd/chaincfg/chainhash" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestProve(t *testing.T) { | ||
t.Run("returns true", func(t *testing.T) { | ||
result := Prove(chainhash.Hash{}, chainhash.Hash{}, []byte{}, 0) | ||
require.True(t, result) | ||
}) | ||
} | ||
|
||
func TestVerifyHash256Merkle(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
proof []byte | ||
index uint | ||
want bool | ||
}{ | ||
{ | ||
name: "valid length but invalid index and content", | ||
proof: make([]byte, 32), | ||
index: 0, | ||
want: true, | ||
}, | ||
{ | ||
name: "invalid length not multiple of 32", | ||
proof: make([]byte, 34), | ||
index: 0, | ||
want: false, | ||
}, | ||
{ | ||
name: "invalid length equal to 64", | ||
proof: make([]byte, 64), | ||
index: 0, | ||
want: false, | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
result := VerifyHash256Merkle(tc.proof, tc.index) | ||
require.Equal(t, tc.want, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters