Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
itest: generate NUMS dummy macaroon
Browse files Browse the repository at this point in the history
  • Loading branch information
aakselrod committed Feb 6, 2023
1 parent e2b734c commit b9af6b2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion itest/itest_lndharness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func (l *lndHarness) Start() {

mustGenCertPair(l.tctx.t, certPath, keyPath)

macPath := path.Join(l.lndDir, "dummy.macaroon")

mustGenMacaroon(l.tctx.t, macPath)

signerAddr := "127.0.0.1:" + newPortString()
fullSignerAddr := "tcp://" + signerAddr

Expand Down Expand Up @@ -137,7 +141,7 @@ func (l *lndHarness) Start() {
"--remotesigner.enable",
"--remotesigner.rpchost="+signerAddr,
"--remotesigner.tlscertpath="+certPath,
"--remotesigner.macaroonpath=./testdata/signer.custom.macaroon",
"--remotesigner.macaroonpath="+macPath,
)

go waitProc(l.lndCmd)
Expand Down Expand Up @@ -366,3 +370,28 @@ func mustGenCertPair(t *testing.T, certFile, keyFile string) {

require.NoError(t, os.WriteFile(keyFile, keyBuf.Bytes(), 0600))
}

func mustGenMacaroon(t *testing.T, macPath string) {
var macData []byte

macData = append(macData, 2) // version
macData = append(macData, 1) // field type loc
macData = append(macData, 1) // length
macData = append(macData, 65) // loc ("A")
macData = append(macData, 2) // field type id
macData = append(macData, 1) // length
macData = append(macData, 65) // id ("A")
macData = append(macData, 0) // end of seq
macData = append(macData, 0) // end of seq
macData = append(macData, 6) // field type sig
macData = append(macData, 32) // length
macData = append(macData, // sig (32 * "A")
65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 65, 65,
)
macData = append(macData, 0) // end of seq

require.NoError(t, os.WriteFile(macPath, macData, 0644))
}
Binary file removed itest/testdata/signer.custom.macaroon
Binary file not shown.

0 comments on commit b9af6b2

Please sign in to comment.