itest: refactor testBakeMacaroon

This commit is contained in:
yyforyongyu 2022-08-09 14:33:15 +08:00
parent 9794dbd7b2
commit 64bf6f4e26
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
3 changed files with 11 additions and 11 deletions

View File

@ -349,4 +349,8 @@ var allTestCasesTemp = []*lntemp.TestCase{
Name: "macaroon authentication",
TestFunc: testMacaroonAuthentication,
},
{
Name: "bake macaroon",
TestFunc: testBakeMacaroon,
},
}

View File

@ -296,8 +296,8 @@ func testMacaroonAuthentication(ht *lntemp.HarnessTest) {
// testBakeMacaroon checks that when creating macaroons, the permissions param
// in the request must be set correctly, and the baked macaroon has the intended
// permissions.
func testBakeMacaroon(net *lntest.NetworkHarness, t *harnessTest) {
var testNode = net.Alice
func testBakeMacaroon(ht *lntemp.HarnessTest) {
var testNode = ht.Alice
testCases := []struct {
name string
@ -429,7 +429,7 @@ func testBakeMacaroon(net *lntest.NetworkHarness, t *harnessTest) {
newMac, err := readMacaroonFromHex(bakeResp.Macaroon)
require.NoError(t, err)
cleanup, readOnlyClient := macaroonClientOld(
cleanup, readOnlyClient := macaroonClient(
t, testNode, newMac,
)
defer cleanup()
@ -498,17 +498,17 @@ func testBakeMacaroon(net *lntest.NetworkHarness, t *harnessTest) {
for _, tc := range testCases {
tc := tc
t.t.Run(tc.name, func(tt *testing.T) {
ht.Run(tc.name, func(tt *testing.T) {
ctxt, cancel := context.WithTimeout(
context.Background(), defaultTimeout,
ht.Context(), defaultTimeout,
)
defer cancel()
adminMac, err := testNode.ReadMacaroon(
testNode.AdminMacPath(), defaultTimeout,
testNode.Cfg.AdminMacPath, defaultTimeout,
)
require.NoError(tt, err)
cleanup, client := macaroonClientOld(tt, testNode, adminMac)
cleanup, client := macaroonClient(tt, testNode, adminMac)
defer cleanup()
tc.run(ctxt, tt, client)

View File

@ -52,10 +52,6 @@ var allTestCases = []*testCase{
name: "cpfp",
test: testCPFP,
},
{
name: "bake macaroon",
test: testBakeMacaroon,
},
{
name: "delete macaroon id",
test: testDeleteMacaroonID,