Skip to content

Commit 31d333c

Browse files
committed
tapscript: add test for NewFundingScriptTree
This commit adds a test to ensure that `NewFundingScriptTree` returns the value we expect.
1 parent 2f269b9 commit 31d333c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tapscript/script_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package tapscript
2+
3+
import (
4+
"encoding/hex"
5+
"testing"
6+
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
// TestNewFundingScriptTree tests the NewFundingScriptTree function. We use this
11+
// function to filter out assets used for custom channel funding from the
12+
// balance queries. Therefor the script key cannot change since this would lead
13+
// to inconsistencies in the balance queries.
14+
func TestNewFundingScriptTree(t *testing.T) {
15+
// This key, threaded through asset.NewScriptKey() would start with 02.
16+
// We don't do that here so we compare it to the expected compressed
17+
// form of the public key.
18+
expectedTaprootKeyHex := "0350aaeb166f4234650d84a2d8a130987aeaf695020" +
19+
"6e0905401ee74ff3f8d18e6"
20+
expectedTaprootKeyBytes, err := hex.DecodeString(expectedTaprootKeyHex)
21+
require.NoError(t, err)
22+
23+
fundingScriptTree := NewFundingScriptTree()
24+
taprootKey := fundingScriptTree.TaprootKey
25+
26+
serializedTaprootKey := taprootKey.SerializeCompressed()
27+
require.Equal(t, expectedTaprootKeyBytes, serializedTaprootKey)
28+
}

0 commit comments

Comments
 (0)