mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-23 14:40:34 +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:
parent
76936961f9
commit
0b807d257a
2 changed files with 5 additions and 4 deletions
|
@ -43,7 +43,7 @@ trait ExtraDirectives extends Directives {
|
||||||
val nodeIdsFormParam: NameUnmarshallerReceptacle[List[PublicKey]] = "nodeIds".as[List[PublicKey]](pubkeyListUnmarshaller)
|
val nodeIdsFormParam: NameUnmarshallerReceptacle[List[PublicKey]] = "nodeIds".as[List[PublicKey]](pubkeyListUnmarshaller)
|
||||||
val paymentHashFormParam: NameUnmarshallerReceptacle[ByteVector32] = "paymentHash".as[ByteVector32](sha256HashUnmarshaller)
|
val paymentHashFormParam: NameUnmarshallerReceptacle[ByteVector32] = "paymentHash".as[ByteVector32](sha256HashUnmarshaller)
|
||||||
val fromFormParam: NameDefaultUnmarshallerReceptacle[TimestampSecond] = "from".as[TimestampSecond](timestampSecondUnmarshaller).?(TimestampSecond.min)
|
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 amountMsatFormParam: NameReceptacle[MilliSatoshi] = "amountMsat".as[MilliSatoshi]
|
||||||
val invoiceFormParam: NameReceptacle[PaymentRequest] = "invoice".as[PaymentRequest]
|
val invoiceFormParam: NameReceptacle[PaymentRequest] = "invoice".as[PaymentRequest]
|
||||||
val routeFormatFormParam: NameUnmarshallerReceptacle[RouteFormat] = "format".as[RouteFormat](routeFormatUnmarshaller)
|
val routeFormatFormParam: NameUnmarshallerReceptacle[RouteFormat] = "format".as[RouteFormat](routeFormatUnmarshaller)
|
||||||
|
|
|
@ -1056,6 +1056,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
|
||||||
test("'audit'") {
|
test("'audit'") {
|
||||||
val eclair = mock[Eclair]
|
val eclair = mock[Eclair]
|
||||||
val mockService = new MockService(eclair)
|
val mockService = new MockService(eclair)
|
||||||
|
val year9999 = TimestampSecond(253402300799L)
|
||||||
val auditResponse = AuditResponse(Seq.empty, Seq.empty, Seq.empty)
|
val auditResponse = AuditResponse(Seq.empty, Seq.empty, Seq.empty)
|
||||||
eclair.audit(any, any)(any[Timeout]) returns Future.successful(auditResponse)
|
eclair.audit(any, any)(any[Timeout]) returns Future.successful(auditResponse)
|
||||||
|
|
||||||
|
@ -1065,16 +1066,16 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
|
||||||
check {
|
check {
|
||||||
assert(handled)
|
assert(handled)
|
||||||
assert(status == OK)
|
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)) ~>
|
addCredentials(BasicHttpCredentials("", mockApi().password)) ~>
|
||||||
Route.seal(mockService.audit) ~>
|
Route.seal(mockService.audit) ~>
|
||||||
check {
|
check {
|
||||||
assert(handled)
|
assert(handled)
|
||||||
assert(status == OK)
|
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)) ~>
|
Post("/audit", FormData("from" -> 123456.toString, "to" -> 654321.toString)) ~>
|
||||||
|
|
Loading…
Add table
Reference in a new issue