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

Requiring group size and threshold to be > 0 #410

Merged
merged 2 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions solidity/contracts/BondedECDSAKeepFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ contract BondedECDSAKeepFactory is
uint256 _bond,
uint256 _stakeLockDuration
) external payable returns (address keepAddress) {
require(_groupSize > 0, "Minimum signing group size must be greater than 0");
pdyraga marked this conversation as resolved.
Show resolved Hide resolved
require(_groupSize <= 16, "Maximum signing group size is 16");
require(_honestThreshold > 0, "Honest threshold must be greater than 0");
require(
_honestThreshold <= _groupSize,
"Honest threshold must be less or equal the group size"
Expand Down
38 changes: 38 additions & 0 deletions solidity/test/BondedECDSAKeepFactoryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,25 @@ contract("BondedECDSAKeepFactory", async (accounts) => {
)
})

it("reverts when honest threshold is 0", async () => {
const honestThreshold = 0

await expectRevert(
keepFactory.openKeep(
groupSize,
honestThreshold,
keepOwner,
bond,
stakeLockDuration,
{
from: application,
value: feeEstimate,
}
),
"Honest threshold must be greater than 0"
)
})

it("works when honest threshold is equal to the group size", async () => {
const honestThreshold = 3
const groupSize = honestThreshold
Expand Down Expand Up @@ -1080,6 +1099,25 @@ contract("BondedECDSAKeepFactory", async (accounts) => {
)
})

it("reverts when trying to use a group of 0 signers", async () => {
const groupSize = 0

await expectRevert(
keepFactory.openKeep(
groupSize,
threshold,
keepOwner,
bond,
stakeLockDuration,
{
from: application,
value: feeEstimate,
}
),
"Minimum signing group size must be greater than 0"
)
})

async function createDepositAndRegisterMembers(
memberCount,
unbondedAmount
Expand Down