mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
Fix the time based test cases in BitcoindV17RpcClientTest (#1224)
This commit is contained in:
parent
54f90f5fad
commit
c5f5b8c065
2 changed files with 12 additions and 7 deletions
|
@ -16,7 +16,6 @@ import org.bitcoins.rpc.client.v17.BitcoindV17RpcClient
|
|||
import org.bitcoins.rpc.util.AsyncUtil
|
||||
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
|
||||
import org.bitcoins.testkit.util.BitcoindRpcTest
|
||||
import java.time.LocalDateTime
|
||||
|
||||
import scala.concurrent.Future
|
||||
|
||||
|
@ -108,13 +107,16 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest {
|
|||
} yield assert(signed.complete)
|
||||
}
|
||||
|
||||
private val SpreadInSeconds = 30
|
||||
|
||||
it should "be able to get the address info for a given address" in {
|
||||
for {
|
||||
(client, _) <- clientsF
|
||||
addr <- client.getNewAddress
|
||||
info <- client.getAddressInfo(addr)
|
||||
} yield assert(
|
||||
info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear))
|
||||
info.timestamp.map(_.toEpochSecond).getOrElse(0L) === System
|
||||
.currentTimeMillis() / 1000 +- SpreadInSeconds)
|
||||
}
|
||||
|
||||
it should "be able to get the address info for a given P2SHSegwit address" in {
|
||||
|
@ -123,7 +125,8 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest {
|
|||
addr <- client.getNewAddress(addressType = AddressType.P2SHSegwit)
|
||||
info <- client.getAddressInfo(addr)
|
||||
} yield assert(
|
||||
info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear))
|
||||
info.timestamp.map(_.toEpochSecond).getOrElse(0L) === System
|
||||
.currentTimeMillis() / 1000 +- SpreadInSeconds)
|
||||
}
|
||||
|
||||
it should "be able to get the address info for a given Legacy address" in {
|
||||
|
@ -132,7 +135,8 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest {
|
|||
addr <- client.getNewAddress(addressType = AddressType.Legacy)
|
||||
info <- client.getAddressInfo(addr)
|
||||
} yield assert(
|
||||
info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear))
|
||||
info.timestamp.map(_.toEpochSecond).getOrElse(0L) === System
|
||||
.currentTimeMillis() / 1000 +- SpreadInSeconds)
|
||||
}
|
||||
|
||||
// needs #360 to be merged
|
||||
|
@ -144,7 +148,8 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest {
|
|||
} yield {
|
||||
assert(info.address.networkParameters == RegTest)
|
||||
assert(
|
||||
info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear))
|
||||
info.timestamp.map(_.toEpochSecond).getOrElse(0L) === System
|
||||
.currentTimeMillis() / 1000 +- SpreadInSeconds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.bitcoins.rpc.jsonmodels
|
||||
|
||||
import java.io.File
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
import org.bitcoins.core.crypto.{
|
||||
DoubleSha256DigestBE,
|
||||
|
@ -221,7 +221,7 @@ case class AddressInfoResult(
|
|||
pubkey: Option[ECPublicKey],
|
||||
embedded: Option[EmbeddedResult],
|
||||
label: String,
|
||||
timestamp: Option[LocalDateTime],
|
||||
timestamp: Option[ZonedDateTime],
|
||||
hdkeypath: Option[BIP32Path],
|
||||
hdseedid: Option[RipeMd160Digest],
|
||||
hdmasterkeyid: Option[RipeMd160Digest],
|
||||
|
|
Loading…
Add table
Reference in a new issue