Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cleanup): address TODOs PE-7339 #296

Merged
merged 9 commits into from
Jan 3, 2025
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,6 @@ dependencies = {

### Deployment

TODO:
Merging to develop or main will evolve the devnet or testnet contract to the next version. The script managing the logic is located at `tools/evolve.mjs`, which uses aoconnect to perform an `Eval` action. The deployment process is automated using Github Actions.

[contract whitepaper]: https://ar.io/whitepaper
21 changes: 19 additions & 2 deletions spec/balances_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local balances = require("balances")
local testAddress1 = "test-this-is-valid-arweave-wallet-address-1"
local testAddress2 = "test-this-is-valid-arweave-wallet-address-2"
local testAddressEth = "0xFCAd0B19bB29D4674531d6f115237E16AfCE377c"
local unsafeAddress = "not-a-real-address"

describe("balances", function()
before_each(function()
Expand All @@ -16,21 +17,37 @@ describe("balances", function()
end)

it("should transfer tokens", function()
local result = balances.transfer(testAddress2, testAddress1, 100)
local result = balances.transfer(testAddress2, testAddress1, 100, false)
assert.are.same(result[testAddress2], _G.Balances[testAddress2])
assert.are.same(result[testAddress1], _G.Balances[testAddress1])
assert.are.equal(100, _G.Balances[testAddress2])
assert.are.equal(0, _G.Balances[testAddress1])
end)

it("should transfer tokens between Arweave and ETH addresses", function()
local result = balances.transfer(testAddressEth, testAddress1, 100)
local result = balances.transfer(testAddressEth, testAddress1, 100, false)
assert.are.same(result[testAddressEth], _G.Balances[testAddressEth])
assert.are.same(result[testAddress1], _G.Balances[testAddress1])
assert.are.equal(100, _G.Balances[testAddressEth])
assert.are.equal(0, _G.Balances[testAddress1])
end)

it("should fail when transferring to unsafe address and unsafe flag is true", function()
local status, result = pcall(balances.transfer, unsafeAddress, testAddress1, 100, false)
assert.is_false(status)
assert.match("Invalid recipient", result)
assert.are.equal(nil, _G.Balances[unsafeAddress])
assert.are.equal(100, _G.Balances[testAddress1])
end)

it("should not fail when transferring to unsafe address and unsafe flag is false", function()
local result = balances.transfer(unsafeAddress, testAddress1, 100, true)
assert.are.same(result[unsafeAddress], _G.Balances[unsafeAddress])
assert.are.same(result[testAddress1], _G.Balances[testAddress1])
assert.are.equal(100, _G.Balances[unsafeAddress])
assert.are.equal(0, _G.Balances[testAddress1])
end)

it("should error on insufficient balance", function()
local status, result = pcall(balances.transfer, testAddress2, testAddress1, 101)
assert.is_false(status)
Expand Down
48 changes: 48 additions & 0 deletions spec/epochs_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ describe("epochs", function()
settings = testSettings,
status = "joined",
observerAddress = "observerAddress",
weights = {
normalizedCompositeWeight = 1,
stakeWeight = 1,
tenureWeight = 1,
gatewayRewardRatioWeight = 1,
observerRewardRatioWeight = 1,
compositeWeight = 1,
},
}
local expectation = {
["observerAddress"] = "test-this-is-valid-arweave-wallet-address-1",
Expand Down Expand Up @@ -158,6 +166,14 @@ describe("epochs", function()
settings = testSettings,
status = "joined",
observerAddress = "observer-address-" .. i,
weights = {
normalizedCompositeWeight = 1,
stakeWeight = 1,
tenureWeight = 1,
gatewayRewardRatioWeight = 1,
observerRewardRatioWeight = 1,
compositeWeight = 1,
},
}
-- note - ordering of keys is not guaranteed when insert into maps
_G.GatewayRegistry["observer" .. i] = gateway
Expand Down Expand Up @@ -304,6 +320,14 @@ describe("epochs", function()
settings = testSettings,
status = "joined",
observerAddress = "test-this-is-valid-arweave-observer-address-1",
weights = {
normalizedCompositeWeight = 1,
stakeWeight = 1,
tenureWeight = 1,
gatewayRewardRatioWeight = 1,
observerRewardRatioWeight = 1,
compositeWeight = 1,
},
},
["test-this-is-valid-arweave-wallet-address-2"] = {
operatorStake = gar.getSettings().operators.minStake,
Expand All @@ -323,6 +347,14 @@ describe("epochs", function()
settings = testSettings,
status = "joined",
observerAddress = "test-this-is-valid-arweave-observer-address-2",
weights = {
normalizedCompositeWeight = 1,
stakeWeight = 1,
tenureWeight = 1,
gatewayRewardRatioWeight = 1,
observerRewardRatioWeight = 1,
compositeWeight = 1,
},
},
["test-this-is-valid-arweave-wallet-address-3"] = {
operatorStake = gar.getSettings().operators.minStake,
Expand All @@ -342,6 +374,14 @@ describe("epochs", function()
settings = testSettings,
status = "joined",
observerAddress = "test-this-is-valid-arweave-observer-address-3",
weights = {
normalizedCompositeWeight = 1,
stakeWeight = 1,
tenureWeight = 1,
gatewayRewardRatioWeight = 1,
observerRewardRatioWeight = 1,
compositeWeight = 1,
},
},
["test-this-is-valid-arweave-wallet-address-4"] = {
operatorStake = gar.getSettings().operators.minStake,
Expand All @@ -362,6 +402,14 @@ describe("epochs", function()
settings = testSettings,
status = "leaving", -- leaving, so it is not eligible to receive stats from this epoch
observerAddress = "test-this-is-valid-arweave-observer-address-4",
weights = {
normalizedCompositeWeight = 1,
stakeWeight = 1,
tenureWeight = 1,
gatewayRewardRatioWeight = 1,
observerRewardRatioWeight = 1,
compositeWeight = 1,
},
},
}
_G.Epochs[0].prescribedObservers = {
Expand Down
Loading
Loading