Skip to content

Commit

Permalink
Merge branch 'develop' into deploy/testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
IPadawans committed Jan 26, 2024
2 parents a4e8e79 + aac9126 commit db22140
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ object BountyRewardsTest extends SimpleIOSuite {

pureTest("Get bounty reward amount - AnalyticsSubscriptionBounty") {
val currentAddress = Address("DAG0DQPuvVThrHnz66S4V6cocrtpg59oesAWyRMb")
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentEpochProgress = 2880L

val deviceInfo = DeviceInfo(123456L, currentDeviceInfoAPIResponse, currentEpochProgress, AnalyticsBountyInformation(2880L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)
val deviceInfo = DeviceInfo(123456L, currentDeviceInfoAPIResponse, currentEpochProgress, AnalyticsBountyInformation(2880L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)

val unitDeployedBountyAmount = new AnalyticsBountyRewards().getDeviceBountyRewardsAmount(deviceInfo, currentEpochProgress)
expect.eql(25000000000L, unitDeployedBountyAmount)
}

pureTest("Get bounty reward amount - AnalyticsSubscriptionBounty - 0L when not reach correct epochProgress") {
val currentAddress = Address("DAG0DQPuvVThrHnz66S4V6cocrtpg59oesAWyRMb")
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentEpochProgress = 2880L

val deviceInfo = DeviceInfo(123456L, currentDeviceInfoAPIResponse, currentEpochProgress, AnalyticsBountyInformation(3500L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)
val deviceInfo = DeviceInfo(123456L, currentDeviceInfoAPIResponse, currentEpochProgress, AnalyticsBountyInformation(3500L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)

val unitDeployedBountyAmount = new AnalyticsBountyRewards().getDeviceBountyRewardsAmount(deviceInfo, currentEpochProgress)
expect.eql(0L, unitDeployedBountyAmount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ object BuildRewardsTest extends SimpleIOSuite {

test("Build correctly rewards - AnalyticsSubscriptionBounty") {
val currentAddress = Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb")
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val lastArtifactEpochProgress = 1441L

val calculatedState = CheckInDataCalculatedState(Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
val calculatedState = CheckInDataCalculatedState(Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
val balances = SortedMap(currentAddress -> Balance(NonNegLong.unsafeFrom(toTokenAmountFormat(1))))

for {
Expand All @@ -150,14 +150,14 @@ object BuildRewardsTest extends SimpleIOSuite {
val currentAddress = Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb")
val currentAddress2 = Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oepAWyRMb")

val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse2 = DorAPIResponse(currentAddress2.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse2 = DorAPIResponse(currentAddress2.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)

val lastArtifactEpochProgress = 1441L

val calculatedState = CheckInDataCalculatedState(Map(
currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some),
currentAddress2 -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse2, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)
currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some),
currentAddress2 -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse2, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)
))

val balances = SortedMap(
Expand Down Expand Up @@ -238,12 +238,12 @@ object BuildRewardsTest extends SimpleIOSuite {
val currentAddress2 = Address("DAG0DQCuvVThrHnz66S4V6cocrtpg59oesAWyRMb")
val rewardAddress = Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb")

val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, rewardAddress.some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, rewardAddress.some)
val lastArtifactEpochProgress = 1441L

val calculatedState = CheckInDataCalculatedState(Map(
currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", "123", 10L, rewardAddress.some).some),
currentAddress2 -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", "123", 10L, rewardAddress.some).some)
currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", 123L, 10L, rewardAddress.some).some),
currentAddress2 -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, lastArtifactEpochProgress, AnalyticsBountyInformation(1442L, "1", 123L, 10L, rewardAddress.some).some)
))

val balances = SortedMap(currentAddress -> Balance(NonNegLong.unsafeFrom(toTokenAmountFormat(1))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object DeviceCheckIn {
private def updateAnalyticsBountyInformation(
epochProgress : EpochProgress,
dorAPIResponse : DorAPIResponse,
lastBillingId : String,
lastBillingId : Long,
oldAnalyticsBountyInformation: AnalyticsBountyInformation
): AnalyticsBountyInformation = {
if (oldAnalyticsBountyInformation.lastBillingId == lastBillingId || oldAnalyticsBountyInformation.nextEpochProgressToRewardAnalytics > epochProgress.value.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ object Types {
isInstalled : Boolean,
locationType : Option[String],
billedAmountMonthly: Option[Long],
lastBillingId : Option[String],
lastBillingId : Option[Long],
teamId : Option[String],
billedAmount : Option[Long],
orgRewardAddress : Option[Address]
Expand Down Expand Up @@ -137,7 +137,7 @@ object Types {
case class AnalyticsBountyInformation(
nextEpochProgressToRewardAnalytics: Long,
teamId : String,
lastBillingId : String,
lastBillingId : Long,
billedAmount : Long,
analyticsRewardAddress : Option[Address]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object CombinersTest extends SimpleIOSuite {
val checkInDataCalculatedState: CheckInDataCalculatedState = CheckInDataCalculatedState(Map.empty)
val oldState = DataState(checkInStateOnChain, checkInDataCalculatedState)
val address = Address.fromBytes("DAG0DQPuvVThrHnz66S4V6cocrtpg59oesAWyRMb".getBytes)
val deviceInfoAPIResponse = DorAPIResponse(address.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val deviceInfoAPIResponse = DorAPIResponse(address.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val checkInRaw = CheckInUpdate("123", "456", 1669815076L, "123", deviceInfoAPIResponse.some)

val epochProgress = EpochProgress(1439L)
Expand All @@ -93,12 +93,12 @@ object CombinersTest extends SimpleIOSuite {

pureTest("Update check in of device - AnalyticsBountyInformation do not update when billingID is the same than last") {
val currentAddress = Address.fromBytes("DAG0DQPuvVThrHnz66S4V6cocrtpg59oesAWyRMb".getBytes)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
var currentEpochProgress = EpochProgress(1440L)

val checkInStateOnChain: CheckInStateOnChain = CheckInStateOnChain(List.empty)
val checkInDataCalculatedState: CheckInDataCalculatedState = CheckInDataCalculatedState(
Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, currentEpochProgress.value.value, AnalyticsBountyInformation(1440L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, currentEpochProgress.value.value, AnalyticsBountyInformation(1440L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
val oldState = DataState(checkInStateOnChain, checkInDataCalculatedState)

val deviceInfo = oldState.calculated.devices(currentAddress)
Expand Down Expand Up @@ -132,12 +132,12 @@ object CombinersTest extends SimpleIOSuite {

pureTest("Update check in of device - AnalyticsBountyInformation update when billingID is different than last") {
val currentAddress = Address.fromBytes("DAG0DQPuvVThrHnz66S4V6cocrtpg59oesAWyRMb".getBytes)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
var currentEpochProgress = EpochProgress(1440L)

val checkInStateOnChain: CheckInStateOnChain = CheckInStateOnChain(List.empty)
val checkInDataCalculatedState: CheckInDataCalculatedState = CheckInDataCalculatedState(
Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, currentEpochProgress.value.value, AnalyticsBountyInformation(1440L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, currentEpochProgress.value.value, AnalyticsBountyInformation(1440L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
val oldState = DataState(checkInStateOnChain, checkInDataCalculatedState)

val deviceInfo = oldState.calculated.devices(currentAddress)
Expand All @@ -151,7 +151,7 @@ object CombinersTest extends SimpleIOSuite {
}

currentEpochProgress = EpochProgress(3000L)
val checkInRaw = CheckInUpdate("123", "456", 12345, "123", currentDeviceInfoAPIResponse.copy(lastBillingId = "456".some).some)
val checkInRaw = CheckInUpdate("123", "456", 12345, "123", currentDeviceInfoAPIResponse.copy(lastBillingId = 456L.some).some)
val allCheckIns = combineDeviceCheckIn(oldState, checkInRaw, currentAddress, currentEpochProgress)

val deviceInfo2 = allCheckIns.calculated.devices(currentAddress)
Expand All @@ -171,12 +171,12 @@ object CombinersTest extends SimpleIOSuite {

pureTest("Update check in of device - AnalyticsBountyInformation do not update when nextEpochProgressToRewardAnalytics is greater than current") {
val currentAddress = Address.fromBytes("DAG0DQPuvVThrHnz66S4V6cocrtpg59oesAWyRMb".getBytes)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, "123".some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
val currentDeviceInfoAPIResponse = DorAPIResponse(currentAddress.some, isInstalled = true, "Retail".some, none, 123L.some, "1".some, 10L.some, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some)
var currentEpochProgress = EpochProgress(1440L)

val checkInStateOnChain: CheckInStateOnChain = CheckInStateOnChain(List.empty)
val checkInDataCalculatedState: CheckInDataCalculatedState = CheckInDataCalculatedState(
Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, currentEpochProgress.value.value, AnalyticsBountyInformation(20000L, "1", "123", 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
Map(currentAddress -> DeviceInfo(1693526401L, currentDeviceInfoAPIResponse, currentEpochProgress.value.value, AnalyticsBountyInformation(20000L, "1", 123L, 10L, Address("DAG0DQPuvVThrVnz66S4V6cocrtpg59oesAWyRMb").some).some)))
val oldState = DataState(checkInStateOnChain, checkInDataCalculatedState)

val deviceInfo = oldState.calculated.devices(currentAddress)
Expand Down

0 comments on commit db22140

Please sign in to comment.