itest: refactor testBakeMacaroon

This commit is contained in:
yyforyongyu committed 2023-01-17 07:26:57 +08:00
1 parent 9794dbd7b2
commit 64bf6f4e26
3 files changed
+11 -11

No files matched your search

+4
View File
@@ -349,4 +349,8 @@ var allTestCasesTemp = []*lntemp.TestCase{
Name: "macaroon authentication",
TestFunc: testMacaroonAuthentication,
},
{
Name: "bake macaroon",
TestFunc: testBakeMacaroon,
},
}
+7 -7
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)
-4
View File
@@ -52,10 +52,6 @@ var allTestCases = []*testCase{
name: "cpfp",
test: testCPFP,
},
{
name: "bake macaroon",
test: testBakeMacaroon,
},
{
name: "delete macaroon id",
test: testDeleteMacaroonID,