Skip to content

Commit 5d739ba

Browse files
committed
internal/test: add ReadTestDataFile
1 parent 6f66242 commit 5d739ba

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/test/helpers.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package test
33
import (
44
"bytes"
55
"encoding/hex"
6+
"os"
7+
"path/filepath"
68
"strconv"
79
"strings"
810
"sync"
@@ -369,3 +371,13 @@ func ScriptSchnorrSig(t *testing.T, pubKey *btcec.PublicKey) txscript.TapLeaf {
369371
require.NoError(t, err)
370372
return txscript.NewBaseTapLeaf(script2)
371373
}
374+
375+
// ReadTestDataFile reads a file from the testdata directory and returns its
376+
// content as a string.
377+
func ReadTestDataFile(t *testing.T, fileName string) string {
378+
path := filepath.Join("testdata", fileName)
379+
fileBytes, err := os.ReadFile(path)
380+
require.NoError(t, err)
381+
382+
return string(fileBytes)
383+
}

0 commit comments

Comments
 (0)