Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
test getRemainingUpdateTime functions
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasDotSol committed Mar 6, 2020
1 parent e5cd842 commit d7adb82
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 2 deletions.
5 changes: 5 additions & 0 deletions implementation/contracts/system/TBTCSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ contract TBTCSystem is Ownable, ITBTCSystem, DepositLog {
0:
governanceTimeDelay.sub(elapsed);
}

function getGovernanceTimeDelay() public view returns (uint256) {
return governanceTimeDelay;
}

// Price Feed

/// @notice Get the price of one satoshi in wei.
Expand Down
126 changes: 124 additions & 2 deletions implementation/test/TBTCSystemTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const {expect} = require("chai")

const TBTCSystem = contract.fromArtifact("TBTCSystem")

// eslint-disable-next-line no-only-tests/no-only-tests
describe.only("TBTCSystem", async function() {
describe("TBTCSystem", async function() {
let tbtcSystem
let ecdsaKeepFactory

Expand Down Expand Up @@ -70,6 +69,129 @@ describe.only("TBTCSystem", async function() {
})
})

describe("geRemainingSignerFeeDivisorUpdateTime", async () => {
let totalDelay

before(async () => {
totalDelay = await tbtcSystem.getGovernanceTimeDelay.call()
})

beforeEach(async () => {
await createSnapshot()
})

afterEach(async () => {
await restoreSnapshot()
})

it("reverts if update has not been initiated", async () => {
await expectRevert(
tbtcSystem.geRemainingSignerFeeDivisorUpdateTime.call(),
"Update not initiated",
)
})

it("returns total delay if no time has passed ", async () => {
await tbtcSystem.beginSignerFeeDivisorUpdate(new BN("200"))
const remaining = await tbtcSystem.geRemainingSignerFeeDivisorUpdateTime.call()
expect(remaining).to.eq.BN(totalDelay)
})

it("returns the correct remaining time", async () => {
await tbtcSystem.beginSignerFeeDivisorUpdate(new BN("200"))
const expectedRemaining = 100
await increaseTime(totalDelay.toNumber() - expectedRemaining)

const remaining = await tbtcSystem.geRemainingSignerFeeDivisorUpdateTime.call()
expect(remaining).to.eq.BN(expectedRemaining)
})
})

describe("getRemainingLotSizesUpdateTime", async () => {
let totalDelay
const lotSizes = [new BN(10 ** 8), new BN(10 ** 6)]

before(async () => {
totalDelay = await tbtcSystem.getGovernanceTimeDelay.call()
})

beforeEach(async () => {
await createSnapshot()
})

afterEach(async () => {
await restoreSnapshot()
})

it("reverts if update has not been initiated", async () => {
await expectRevert(
tbtcSystem.getRemainingLotSizesUpdateTime.call(),
"Update not initiated",
)
})

it("returns total delay if no time has passed ", async () => {
await tbtcSystem.beginLotSizesUpdate(lotSizes)
const remaining = await tbtcSystem.getRemainingLotSizesUpdateTime.call()
expect(remaining).to.eq.BN(totalDelay)
})

it("returns the correct remaining time", async () => {
await tbtcSystem.beginLotSizesUpdate(lotSizes)
const expectedRemaining = 100
await increaseTime(totalDelay.toNumber() - expectedRemaining)

const remaining = await tbtcSystem.getRemainingLotSizesUpdateTime.call()
expect(remaining).to.eq.BN(expectedRemaining)
})
})

describe("getRemainingCollateralizationUpdateTime", async () => {
let totalDelay

before(async () => {
totalDelay = await tbtcSystem.getGovernanceTimeDelay.call()
})

beforeEach(async () => {
await createSnapshot()
})

afterEach(async () => {
await restoreSnapshot()
})

it("reverts if update has not been initiated", async () => {
await expectRevert(
tbtcSystem.getRemainingCollateralizationUpdateTime.call(),
"Update not initiated",
)
})

it("returns total delay if no time has passed ", async () => {
await tbtcSystem.beginCollateralizationThresholdsUpdate(
new BN("150"),
new BN("130"),
new BN("120"),
)
const remaining = await tbtcSystem.getRemainingCollateralizationUpdateTime.call()
expect(remaining).to.eq.BN(totalDelay)
})

it("returns the correct remaining time", async () => {
await tbtcSystem.beginCollateralizationThresholdsUpdate(
new BN("150"),
new BN("130"),
new BN("120"),
)
const expectedRemaining = 100
await increaseTime(totalDelay.toNumber() - expectedRemaining)

const remaining = await tbtcSystem.getRemainingCollateralizationUpdateTime.call()
expect(remaining).to.eq.BN(expectedRemaining)
})
})

describe("update signer fee", async () => {
describe("beginSignerFeeDivisorUpdate", async () => {
const newFee = new BN("201")
Expand Down

0 comments on commit d7adb82

Please sign in to comment.