diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0c81f6904..8a2ff377c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -30,7 +30,7 @@ jobs:
dotnet run --project tests/DotNetLightning.Core.Tests
- name: Run other tests
run: |
- dotnet test
+ dotnet test --filter "FullyQualifiedName!~Macaroon" # see https://github.com/joemphilips/DotNetLightning/issues/153
build_with_fsharp_from_mono:
runs-on: ubuntu-20.04
diff --git a/README.md b/README.md
index fe0ce895c..0b82f9397 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ The package is compiled and published with two variants
* This uses a pre-compiled `libsodium` for cryptographic operations.
* It only supports `windows`, `mac` and `linux` environments.
* This is what you want if you need performance and the environments above are the only ones you are planning to support.
-
+
run `dotnet add package` with the one you want.
Currently it is in alpha, so you probably want to install a latest version by specifying it with `--version`.
The version is prefixed with git commit hash and date. Please take a look at the nuget page.
@@ -86,3 +86,6 @@ Which contains macaroon authentication token.
The api is mostly the same with [libmacaroon](https://github.com/rescrv/libmacaroons) See libmacaroon's readme for the
usage.
+Currently it is only supported in BouncyCastle build (which means not in `DotNetLightning.Core),
+see https://github.com/joemphilips/DotNetLightning/issues/153 For the detail.
+
diff --git a/src/DotNetLightning.Core/DotNetLightning.Core.fsproj b/src/DotNetLightning.Core/DotNetLightning.Core.fsproj
index 753f3d290..d62431d86 100644
--- a/src/DotNetLightning.Core/DotNetLightning.Core.fsproj
+++ b/src/DotNetLightning.Core/DotNetLightning.Core.fsproj
@@ -8,7 +8,7 @@
3
true
-
+
@@ -26,7 +26,7 @@
-
+
diff --git a/tests/DotNetLightning.Core.Tests/Generators/Generators.fs b/tests/DotNetLightning.Core.Tests/Generators/Generators.fs
index f5250ddfd..fc420da04 100644
--- a/tests/DotNetLightning.Core.Tests/Generators/Generators.fs
+++ b/tests/DotNetLightning.Core.Tests/Generators/Generators.fs
@@ -16,12 +16,12 @@ type PrimitiveGenerators =
static member UInt256(): Arbitrary =
Arb.fromGen(uint256Gen)
-
+
static member PubKey() = Arb.fromGen(pubKeyGen)
-
+
static member NodeId() = Arb.fromGen(NodeId pubKeyGen)
-
-
+
+
type P2PMsgGenerators =
static member Init() : Arbitrary =
Arb.fromGen(initGen)
@@ -97,15 +97,15 @@ type P2PMsgGenerators =
static member ChannelUpdate(): Arbitrary =
Arb.fromGen channelUpdateGen
-
+
static member QueryShortChannelIds(): Arbitrary =
Arb.fromGen queryShortChannelIdsGen
static member ReplyShortChannelIds() =
Arb.fromGen(replyShortChannelIdsEndGen)
-
+
static member QueryChannelRange() = Arb.fromGen queryChannelRangeGen
-
+
static member ReplyChannelRange = Arb.fromGen replyChannelRangeGen
static member GossipTimestampFilter = Arb.fromGen gossipTimestampFilterGen
static member OnionPayload() = Arb.fromGen(onionPayloadGen)
@@ -142,8 +142,5 @@ type P2PMsgGenerators =
gossipTimestampFilterGen |> Gen.map(fun i -> i :> ILightningMsg)
]
|> Arb.fromGen
-
-
-type PaymentGenerators =
- static member MacaroonIdentifier: Arbitrary =
- macaroonIdGen |> Arb.fromGen
+
+
diff --git a/tests/DotNetLightning.Core.Tests/Generators/Payments.fs b/tests/DotNetLightning.Core.Tests/Generators/Payments.fs
index 1986e21e1..d0a4c7149 100644
--- a/tests/DotNetLightning.Core.Tests/Generators/Payments.fs
+++ b/tests/DotNetLightning.Core.Tests/Generators/Payments.fs
@@ -5,13 +5,13 @@ open DotNetLightning.Payment.LSAT
open DotNetLightning.Utils.Primitives
open FsCheck
open PrimitiveGenerators
-
+#if BouncyCastle
let private macaroonIdV1Gen =
(uint256Gen |> Gen.map(PaymentHash.PaymentHash), uint256Gen)
||> Gen.map2(fun p u -> { MacaroonIdentifierV0.PaymentHash = p
TokenId = u })
- |> Gen.map(MacaroonIdentifier.V0)
+ |> Gen.map(MacaroonIdentifier.V0)
let private macaroonUnknownIdGen(knownVersions: uint16 seq) =
gen {
let! t =
@@ -26,3 +26,5 @@ let macaroonIdGen: Gen =
macaroonIdV1Gen
macaroonUnknownIdGen([0us])
]
+
+#endif
diff --git a/tests/DotNetLightning.Core.Tests/LSATTests.fs b/tests/DotNetLightning.Core.Tests/LSATTests.fs
index 302b3f224..3f79f3edb 100644
--- a/tests/DotNetLightning.Core.Tests/LSATTests.fs
+++ b/tests/DotNetLightning.Core.Tests/LSATTests.fs
@@ -1,5 +1,6 @@
module DotNetLightning.Tests.LSATTests
+#if BouncyCastle
open System
open System.Linq
open Expecto
@@ -33,7 +34,7 @@ let lsatTests =
let r = Service.ParseMany ",,"
Expect.isError (Result.ToFSharpCoreResult r) "can not parse empty services"
()
-
+
testList "check macaroon verification works in LSAT compliant way" [
testCase "successful verification" <| fun _ ->
let secret = "My secret key"
@@ -46,7 +47,7 @@ let lsatTests =
let v = m.VerifyLSATCaveats(caveats, satisfiers, secret)
Expect.isTrue(v.Success) (sprintf "%A" v.Messages)
()
-
+
testCase "successful verification with unknown service name" <| fun _ ->
let secret = "My secret key"
let identifier = "my macaroon identifier"
@@ -58,7 +59,7 @@ let lsatTests =
satisfiers.Add(ServiceSatisfier("my-service-name") :> ISatisfier)
let v = m.VerifyLSATCaveats(caveats, satisfiers, secret)
Expect.isTrue(v.Success) (sprintf "%A" v.Messages)
-
+
testCase "successful verification with capabilities satisfier" <| fun _ ->
let secret = "My secret key"
let identifier = "my macaroon identifier"
@@ -71,7 +72,7 @@ let lsatTests =
satisfiers.Add(CapabilitiesSatisfier("my-service-name", "read") :> ISatisfier)
let v = m.VerifyLSATCaveats(caveats, satisfiers, secret)
Expect.isTrue(v.Success) (sprintf "%A" v.Messages)
-
+
testCase "verification succeeds when caveats includes required capabilities" <| fun _ ->
let secret = "My secret key"
let identifier = "my macaroon identifier"
@@ -82,7 +83,7 @@ let lsatTests =
satisfiers.Add(CapabilitiesSatisfier("my-service-name", "read") :> ISatisfier)
let v = m.VerifyLSATCaveats(caveats, satisfiers, secret)
Expect.isTrue(v.Success) (sprintf "%A" v.Messages)
-
+
testCase "failure case: different secret" <| fun _ ->
let secret = "My secret key"
let identifier = "my macaroon identifier"
@@ -93,7 +94,7 @@ let lsatTests =
satisfiers.Add(ServiceSatisfier("my-service-name") :> ISatisfier)
let v = m.VerifyLSATCaveats(caveats, satisfiers, "wrong secret key")
Expect.isFalse(v.Success) ""
-
+
testCase "failure case: different service name" <| fun _ ->
let secret = "My secret key"
let identifier = "my macaroon identifier"
@@ -104,22 +105,22 @@ let lsatTests =
satisfiers.Add(ServiceSatisfier("my-service-name") :> ISatisfier)
let v = m.VerifyLSATCaveats(caveats, satisfiers, secret)
Expect.isFalse(v.Success) ""
-
+
testCase "failure case: verification fails if restriction gets loose then before" <| fun _ ->
let secret = "My secret key"
let identifier = "my macaroon identifier"
let m = Macaroon("http://my.awesome.service", secret, identifier)
let satisfiers = ResizeArray()
satisfiers.Add(ServiceSatisfier("my-service-name") :> ISatisfier)
-
+
let caveats = ResizeArray()
// latter caveats has more power here. which is invalid for lsat.
caveats.Add(Caveat("service=my-service-name:0"))
caveats.Add(Caveat("service=my-service-name:0,another-service-name:0"))
-
+
let v = m.VerifyLSATCaveats(caveats, satisfiers, secret)
Expect.isFalse(v.Success) ""
-
+
satisfiers.Add(CapabilitiesSatisfier("my-service-name", "read") :> ISatisfier)
let caveats = ResizeArray()
// latter caveats has more power here. which is invalid for lsat.
@@ -127,6 +128,8 @@ let lsatTests =
caveats.Add(Caveat("my-service-name_capabilities = read,write"))
let v = m.VerifyLSATCaveats(caveats, satisfiers, secret)
Expect.isFalse(v.Success) ""
-
+
]
]
+
+#endif
diff --git a/tests/DotNetLightning.Core.Tests/PaymentPropertyTests.fs b/tests/DotNetLightning.Core.Tests/PaymentPropertyTests.fs
index 96dfc9f55..73ae39562 100644
--- a/tests/DotNetLightning.Core.Tests/PaymentPropertyTests.fs
+++ b/tests/DotNetLightning.Core.Tests/PaymentPropertyTests.fs
@@ -1,11 +1,18 @@
module DotNetLightning.Tests.PaymentPropertyTests
+#if BouncyCastle
+
open DotNetLightning.Payment
open DotNetLightning.Payment.LSAT
open Expecto
+open PaymentGenerators
+open FsCheck
open Generators
open ResultUtils
+type PaymentGenerators =
+ static member MacaroonIdentifier: Arbitrary =
+ macaroonIdGen |> Arb.fromGen
[]
let lsatTests =
@@ -19,4 +26,6 @@ let lsatTests =
let i2 = MacaroonIdentifier.TryCreateFromBytes(i.ToBytes()) |> Result.deref
Expect.equal i i2 "failed to de/serialize macaroon id"
]
-
+
+#endif
+