1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-23 06:35:11 +01:00

Set max timestamp in API call to 9999/12/31 (#2112)

Previous value was 10001950-04-24 09:07:11+00 which is out of range for Postgresql.
9999 seems far away enough for most databases.
This commit is contained in:
Fabrice Drouin 2021-12-20 19:54:34 +01:00 committed by GitHub
parent 76936961f9
commit 0b807d257a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -43,7 +43,7 @@ trait ExtraDirectives extends Directives {
val nodeIdsFormParam: NameUnmarshallerReceptacle[List[PublicKey]] = "nodeIds".as[List[PublicKey]](pubkeyListUnmarshaller)
val paymentHashFormParam: NameUnmarshallerReceptacle[ByteVector32] = "paymentHash".as[ByteVector32](sha256HashUnmarshaller)
val fromFormParam: NameDefaultUnmarshallerReceptacle[TimestampSecond] = "from".as[TimestampSecond](timestampSecondUnmarshaller).?(TimestampSecond.min)
val toFormParam: NameDefaultUnmarshallerReceptacle[TimestampSecond] = "to".as[TimestampSecond](timestampSecondUnmarshaller).?(TimestampSecond.max)
val toFormParam: NameDefaultUnmarshallerReceptacle[TimestampSecond] = "to".as[TimestampSecond](timestampSecondUnmarshaller).?(TimestampSecond(253402300799L)) // 31/12/9999
val amountMsatFormParam: NameReceptacle[MilliSatoshi] = "amountMsat".as[MilliSatoshi]
val invoiceFormParam: NameReceptacle[PaymentRequest] = "invoice".as[PaymentRequest]
val routeFormatFormParam: NameUnmarshallerReceptacle[RouteFormat] = "format".as[RouteFormat](routeFormatUnmarshaller)

View file

@ -1056,6 +1056,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
test("'audit'") {
val eclair = mock[Eclair]
val mockService = new MockService(eclair)
val year9999 = TimestampSecond(253402300799L)
val auditResponse = AuditResponse(Seq.empty, Seq.empty, Seq.empty)
eclair.audit(any, any)(any[Timeout]) returns Future.successful(auditResponse)
@ -1065,16 +1066,16 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
check {
assert(handled)
assert(status == OK)
eclair.audit(TimestampSecond.min, TimestampSecond.max)(any[Timeout]).wasCalled(once)
eclair.audit(TimestampSecond.min, year9999)(any[Timeout]).wasCalled(once)
}
Post("/audit", FormData("from" -> TimestampSecond.min.toLong.toString, "to" -> TimestampSecond.max.toLong.toString)) ~>
Post("/audit", FormData("from" -> TimestampSecond.min.toLong.toString, "to" -> year9999.toLong.toString)) ~>
addCredentials(BasicHttpCredentials("", mockApi().password)) ~>
Route.seal(mockService.audit) ~>
check {
assert(handled)
assert(status == OK)
eclair.audit(TimestampSecond.min, TimestampSecond.max)(any[Timeout]).wasCalled(twice)
eclair.audit(TimestampSecond.min, year9999)(any[Timeout]).wasCalled(twice)
}
Post("/audit", FormData("from" -> 123456.toString, "to" -> 654321.toString)) ~>