Skip to content

Commit

Permalink
Make getAddressInfo Tests not reliant on timestamp (#1635)
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jul 8, 2020
1 parent 29a43b4 commit 68bbee3
Showing 1 changed file with 4 additions and 22 deletions.
Expand Up @@ -107,57 +107,39 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest {
} yield assert(signed.complete)
}

private val SpreadInSeconds = 40

it should "be able to get the address info for a given address" in {
for {
(client, _) <- clientsF
addr <- client.getNewAddress
addrTime = System.currentTimeMillis()
info <- client.getAddressInfo(addr)
} yield assert(
info.timestamp
.map(_.toEpochSecond)
.getOrElse(0L) === addrTime / 1000 +- SpreadInSeconds)
} yield assert(info.address == addr)
}

it should "be able to get the address info for a given P2SHSegwit address" in {
for {
(client, _) <- clientsF
addr <- client.getNewAddress(addressType = AddressType.P2SHSegwit)
addrTime = System.currentTimeMillis()
info <- client.getAddressInfo(addr)
} yield assert(
info.timestamp
.map(_.toEpochSecond)
.getOrElse(0L) === addrTime / 1000 +- SpreadInSeconds)
} yield assert(info.address == addr)
}

it should "be able to get the address info for a given Legacy address" in {
for {
(client, _) <- clientsF
addr <- client.getNewAddress(addressType = AddressType.Legacy)
addrTime = System.currentTimeMillis()
info <- client.getAddressInfo(addr)
} yield assert(
info.timestamp
.map(_.toEpochSecond)
.getOrElse(0L) === addrTime / 1000 +- SpreadInSeconds)
} yield assert(info.address == addr)
}

// needs #360 to be merged
it should "be able to get the address info for a given Bech32 address" in {
for {
(client, _) <- clientsF
addr <- client.getNewAddress(AddressType.Bech32)
addrTime = System.currentTimeMillis()
info <- client.getAddressInfo(addr)
} yield {
assert(info.address.networkParameters == RegTest)
assert(
info.timestamp
.map(_.toEpochSecond)
.getOrElse(0L) === addrTime / 1000 +- SpreadInSeconds)
assert(info.address == addr)
}
}

Expand Down

0 comments on commit 68bbee3

Please sign in to comment.