Skip to content

Commit

Permalink
npm run lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thaarok committed Nov 1, 2024
1 parent 29076f6 commit b54c90f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
7 changes: 6 additions & 1 deletion contracts/interfaces/ISFC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ interface ISFC {
address _owner
) external;

function setGenesisValidator(address auth, uint256 validatorID, bytes calldata pubkey, uint256 createdTime) external;
function setGenesisValidator(
address auth,
uint256 validatorID,
bytes calldata pubkey,
uint256 createdTime
) external;

function setGenesisDelegation(address delegator, uint256 toValidatorID, uint256 stake) external;

Expand Down
7 changes: 6 additions & 1 deletion contracts/sfc/NodeDriver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ contract NodeDriver is Initializable {

// Methods which are called only by the node

function setGenesisValidator(address auth, uint256 validatorID, bytes calldata pubkey, uint256 createdTime) external onlyNode {
function setGenesisValidator(
address auth,
uint256 validatorID,
bytes calldata pubkey,
uint256 createdTime
) external onlyNode {
backend.setGenesisValidator(auth, validatorID, pubkey, createdTime);
}

Expand Down
7 changes: 6 additions & 1 deletion contracts/sfc/NodeDriverAuth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ contract NodeDriverAuth is Initializable, Ownable {
driver.updateValidatorPubkey(validatorID, pubkey);
}

function setGenesisValidator(address auth, uint256 validatorID, bytes calldata pubkey, uint256 createdTime) external onlyDriver {
function setGenesisValidator(
address auth,
uint256 validatorID,
bytes calldata pubkey,
uint256 createdTime
) external onlyDriver {
sfc.setGenesisValidator(auth, validatorID, pubkey, createdTime);
}

Expand Down
10 changes: 8 additions & 2 deletions contracts/sfc/SFC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ contract SFC is Initializable, Ownable, Version {
}

// delegator => validator ID => withdrawal ID => withdrawal request
mapping(address delegator => mapping(uint256 validatorID => mapping(uint256 wrID => WithdrawalRequest))) public getWithdrawalRequest;
mapping(address delegator => mapping(uint256 validatorID => mapping(uint256 wrID => WithdrawalRequest)))
public getWithdrawalRequest;

// delegator => validator ID => current stake
mapping(address delegator => mapping(uint256 validatorID => uint256 stake)) public getStake;
Expand Down Expand Up @@ -340,7 +341,12 @@ contract SFC is Initializable, Ownable, Version {
node.updateMinGasPrice(minGasPrice);
}

function setGenesisValidator(address auth, uint256 validatorID, bytes calldata pubkey, uint256 createdTime) external onlyDriver {
function setGenesisValidator(
address auth,
uint256 validatorID,
bytes calldata pubkey,
uint256 createdTime
) external onlyDriver {
_rawCreateValidator(
auth,
validatorID,
Expand Down
14 changes: 5 additions & 9 deletions test/NodeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,7 @@ describe('NodeDriver', () => {
it('Should revert when not node', async function () {
const account = ethers.Wallet.createRandom();
await expect(
this.nodeDriver.setGenesisValidator(
account,
1,
account.publicKey,
Date.now(),
),
this.nodeDriver.setGenesisValidator(account, 1, account.publicKey, Date.now()),
).to.be.revertedWithCustomError(this.nodeDriver, 'NotNode');
});
});
Expand All @@ -138,9 +133,10 @@ describe('NodeDriver', () => {
describe('Set genesis delegation', () => {
it('Should revert when not node', async function () {
const account = ethers.Wallet.createRandom();
await expect(
this.nodeDriver.setGenesisDelegation(account, 1, 100),
).to.be.revertedWithCustomError(this.nodeDriver, 'NotNode');
await expect(this.nodeDriver.setGenesisDelegation(account, 1, 100)).to.be.revertedWithCustomError(
this.nodeDriver,
'NotNode',
);
});
});

Expand Down
28 changes: 7 additions & 21 deletions test/SFC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ describe('SFC', () => {
beforeEach(async function () {
const validator = ethers.Wallet.createRandom();
await this.sfc.enableNonNodeCalls();
await this.sfc.setGenesisValidator(
validator.address,
1,
validator.publicKey,
Date.now(),
);
await this.sfc.setGenesisValidator(validator.address, 1, validator.publicKey, Date.now());
await this.sfc.deactivateValidator(1, 1 << 3);
await this.sfc.disableNonNodeCalls();
});
Expand Down Expand Up @@ -312,12 +307,7 @@ describe('SFC', () => {
it('Should revert when setGenesisValidator is not called not node', async function () {
const validator = ethers.Wallet.createRandom();
await expect(
this.sfc.setGenesisValidator(
validator,
1,
validator.publicKey,
Date.now(),
),
this.sfc.setGenesisValidator(validator, 1, validator.publicKey, Date.now()),
).to.be.revertedWithCustomError(this.sfc, 'NotDriverAuth');
});

Expand Down Expand Up @@ -970,19 +960,15 @@ describe('SFC', () => {
it('Should revert when calling setGenesisValidator if not NodeDriver', async function () {
const key = ethers.Wallet.createRandom().publicKey;
await expect(
this.nodeDriverAuth.setGenesisValidator(
this.delegator,
1,
key,
Date.now(),
),
this.nodeDriverAuth.setGenesisValidator(this.delegator, 1, key, Date.now()),
).to.be.revertedWithCustomError(this.nodeDriverAuth, 'NotDriver');
});

it('Should revert when calling setGenesisDelegation if not NodeDriver', async function () {
await expect(
this.nodeDriverAuth.setGenesisDelegation(this.delegator, 1, 100),
).to.be.revertedWithCustomError(this.nodeDriverAuth, 'NotDriver');
await expect(this.nodeDriverAuth.setGenesisDelegation(this.delegator, 1, 100)).to.be.revertedWithCustomError(
this.nodeDriverAuth,
'NotDriver',
);
});

it('Should revert when calling deactivateValidator if not NodeDriver', async function () {
Expand Down

0 comments on commit b54c90f

Please sign in to comment.