Skip to content

Commit

Permalink
chore: devnet to testnet (#110)
Browse files Browse the repository at this point in the history
Includes:
- instant delegate withdrawals
- circulating supply event data
- removes `protocolBalance` from `circulatingSupply`
- additional unit tests
- removes unused utils
  • Loading branch information
dtfiedler authored Oct 22, 2024
2 parents a6013a7 + b900391 commit fe4af02
Show file tree
Hide file tree
Showing 20 changed files with 1,605 additions and 285 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: IO Process Status
on:
workflow_dispatch:
schedule:
- cron: '0 0-5,7-23 * * *' # Run every hour except 6AM UTC
- cron: '0 0-5,8-23 * * *' # Run every hour except 6AM UTC

jobs:
monitor:
Expand Down
4 changes: 2 additions & 2 deletions docs/save_observations.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ graph TD
CheckGateway -- Doesn't Exist --> Error[Throw Error]
CheckPrescribedObserver -- Prescribed --> CheckEpoch{Check Epoch Object}
CheckPrescribedObserver -- Not Prescribed --> Error
CheckEpoch -- Does not Exist --> CreateEpoch[Create Epoch Object]
CheckEpoch -- not found --> CreateEpoch[Create Epoch Object]
CheckEpoch -- Exists --> CheckFailedGateway{Check Failed Gateway}
CreateEpoch -- Created --> CheckFailedGateway{Check Failed Gateway}
CheckFailedGateway -- Valid --> ProcessFailedGateway{Check existing gateway failures}
CheckFailedGateway -- Invalid --> Skip
Skip --> UpdateObserverReportTxId[Update Observer Report Tx Id]
ProcessFailedGateway -- Does not Exist --> CreateFailedGateway[Create Failed Gateway Object]
ProcessFailedGateway -- not found --> CreateFailedGateway[Create Failed Gateway Object]
ProcessFailedGateway -- Exists --> UpdateFailedGateway[Update Failed Gateway Object]
UpdateFailedGateway -- Updated --> UpdateObserverReportTxId[Update Observer Report Tx Id]
CreateFailedGateway -- Created --> UpdateObserverReportTxId[Update Observer Report Tx Id]
Expand Down
200 changes: 200 additions & 0 deletions spec/arns_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe("arns", function()
[testAddressArweave] = startBalance,
[testAddressEth] = startBalance,
}
_G.DemandFactor.currentDemandFactor = 1.0
end)

for addressType, testAddress in pairs(testAddresses) do
Expand Down Expand Up @@ -424,6 +425,81 @@ describe("arns", function()
end)
end

describe("getTokenCost", function()
it("should return the correct token cost for a lease", function()
local baseFee = 500000000
local years = 2
local demandFactor = 0.974
local expectedCost = math.floor((years * baseFee * 0.20) + baseFee) * demandFactor
local intendedAction = {
intent = "Buy-Record",
purchaseType = "lease",
years = 2,
name = "test-name",
}
_G.DemandFactor.currentDemandFactor = demandFactor
assert.are.equal(expectedCost, arns.getTokenCost(intendedAction))
end)
it("should return the correct token cost for a permabuy", function()
local baseFee = 500000000
local demandFactor = 1.052
local expectedCost = math.floor((baseFee * 0.2 * 20) + baseFee) * demandFactor
local intendedAction = {
intent = "Buy-Record",
purchaseType = "permabuy",
name = "test-name",
}
_G.DemandFactor.currentDemandFactor = demandFactor
assert.are.equal(expectedCost, arns.getTokenCost(intendedAction))
end)
it("should return the correct token cost for an undername", function()
_G.NameRegistry.records["test-name"] = {
endTimestamp = constants.oneYearMs,
processId = testProcessId,
purchasePrice = 600000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 10,
}
local baseFee = 500000000
local undernamePercentageFee = 0.001
local increaseQty = 5
local demandFactor = 0.60137
local yearsRemaining = 0.5
local expectedCost =
math.floor(baseFee * increaseQty * undernamePercentageFee * yearsRemaining * demandFactor)
local intendedAction = {
intent = "Increase-Undername-Limit",
quantity = 5,
name = "test-name",
currentTimestamp = constants.oneYearMs / 2,
}
_G.DemandFactor.currentDemandFactor = demandFactor
assert.are.equal(expectedCost, arns.getTokenCost(intendedAction))
end)
it("should return the token cost for extending a name", function()
_G.NameRegistry.records["test-name"] = {
endTimestamp = timestamp + constants.oneYearMs,
processId = testProcessId,
purchasePrice = 600000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 10,
}
local baseFee = 500000000
local years = 2
local demandFactor = 1.2405
local expectedCost = math.floor((years * baseFee * 0.20) * demandFactor)
local intendedAction = {
intent = "Extend-Lease",
years = 2,
name = "test-name",
}
_G.DemandFactor.currentDemandFactor = demandFactor
assert.are.equal(expectedCost, arns.getTokenCost(intendedAction))
end)
end)

describe("pruneRecords", function()
it("should prune records", function()
local currentTimestamp = 1000000000
Expand Down Expand Up @@ -529,4 +605,128 @@ describe("arns", function()
assert.are.equal(registrationFees["51"].lease["1"], 480000000)
end)
end)

describe("getPaginatedRecords", function()
before_each(function()
_G.NameRegistry = {
records = {
["active-record"] = {
endTimestamp = 100, -- far in the future
processId = "oldest-process-id",
purchasePrice = 600000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 10,
},
["active-record-1"] = {
endTimestamp = 10000,
processId = "middle-process-id",
purchasePrice = 400000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 5,
},
["active-record-2"] = {
endTimestamp = 10000000,
processId = "newest-process-id",
purchasePrice = 500000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 8,
},
["permabuy-record"] = {
endTimestamp = nil,
processId = "permabuy-process-id",
purchasePrice = 600000000,
startTimestamp = 0,
type = "permabuy",
undernameLimit = 10,
},
},
}
end)

it("should return the correct paginated records with ascending putting permabuy at the end", function()
local paginatedRecords = arns.getPaginatedRecords(nil, 1, "endTimestamp", "asc")
assert.are.same({
limit = 1,
sortBy = "endTimestamp",
sortOrder = "asc",
hasMore = true,
totalItems = 4,
nextCursor = "active-record",
items = {
{
name = "active-record",
endTimestamp = 100,
processId = "oldest-process-id",
purchasePrice = 600000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 10,
},
},
}, paginatedRecords)
local paginatedRecords2 = arns.getPaginatedRecords(paginatedRecords.nextCursor, 1, "endTimestamp", "asc")
assert.are.same({
limit = 1,
sortBy = "endTimestamp",
sortOrder = "asc",
hasMore = true,
totalItems = 4,
nextCursor = "active-record-1",
items = {
{
name = "active-record-1",
endTimestamp = 10000,
processId = "middle-process-id",
purchasePrice = 400000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 5,
},
},
}, paginatedRecords2)
local paginatedRecords3 = arns.getPaginatedRecords(paginatedRecords2.nextCursor, 1, "endTimestamp", "asc")
assert.are.same({
limit = 1,
sortBy = "endTimestamp",
sortOrder = "asc",
hasMore = true,
totalItems = 4,
nextCursor = "active-record-2",
items = {
{
name = "active-record-2",
endTimestamp = 10000000,
processId = "newest-process-id",
purchasePrice = 500000000,
startTimestamp = 0,
type = "lease",
undernameLimit = 8,
},
},
}, paginatedRecords3)
local paginatedRecords4 = arns.getPaginatedRecords(paginatedRecords3.nextCursor, 1, "endTimestamp", "asc")
assert.are.same({
limit = 1,
sortBy = "endTimestamp",
sortOrder = "asc",
hasMore = false,
totalItems = 4,
nextCursor = nil,
items = {
{
name = "permabuy-record",
endTimestamp = nil,
processId = "permabuy-process-id",
purchasePrice = 600000000,
startTimestamp = 0,
type = "permabuy",
undernameLimit = 10,
},
},
}, paginatedRecords4)
end)
end)
end)
19 changes: 19 additions & 0 deletions spec/balances_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,23 @@ describe("balances", function()
assert.are.equal(0, balances.getBalance(testAddress2))
assert.are.equal(100, balances.getBalance(testAddress1))
end)

describe("getPaginatedBalances", function()
it("should return paginated balances", function()
local balances = balances.getPaginatedBalances(nil, 10, "balance", "desc")
assert.are.same(balances, {
limit = 10,
sortBy = "balance",
sortOrder = "desc",
hasMore = false,
totalItems = 1,
items = {
{
address = testAddress1,
balance = 100,
},
},
})
end)
end)
end)
Loading

0 comments on commit fe4af02

Please sign in to comment.