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

Commit

Permalink
Update refreshKey event (#596)
Browse files Browse the repository at this point in the history
* Update refreshKey event to emit hash string

* Update refreshKey signature

* Update refreshKey tests
  • Loading branch information
nmlinaric authored Jul 14, 2022
1 parent aa9614c commit 35a3e8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions contracts/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract Bridge is Pausable, Context {

event EndKeygen();

event KeyRefresh();
event KeyRefresh(string hash);

event Retry(string txHash);

Expand Down Expand Up @@ -364,9 +364,10 @@ contract Bridge is Pausable, Context {
It's used to trigger the belonging process on the MPC side which also handles keygen function calls order.
@notice Only callable by address that has the right to call the specific function,
which is mapped in {functionAccess} in AccessControlSegregator contract.
@param hash Topology hash which prevents changes during refresh process.
*/
function refreshKey() external onlyAllowed {
emit KeyRefresh();
function refreshKey(string memory hash) external onlyAllowed {
emit KeyRefresh(hash);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions test/contractBridge/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contract('Bridge - [admin]', async (accounts) => {
const expectedBridgeAdmin = accounts[0];
const someAddress = "0xcafecafecafecafecafecafecafecafecafecafe";
const nullAddress = "0x0000000000000000000000000000000000000000";
const topologyHash = "549f715f5b06809ada23145c2dc548db";

const bytes32 = "0x0";
let ADMIN_ROLE;
Expand Down Expand Up @@ -103,14 +104,16 @@ contract('Bridge - [admin]', async (accounts) => {
await TruffleAssert.reverts(BridgeInstance.endKeygen(someAddress), "MPC address can't be updated");
});

it('Should successfully emit "KeyRefresh" event if called by admin', async () => {
const startKeygenTx = await BridgeInstance.refreshKey();
it('Should successfully emit "KeyRefresh" event with expected hash value if called by admin', async () => {
const startKeygenTx = await BridgeInstance.refreshKey(topologyHash);

TruffleAssert.eventEmitted(startKeygenTx, 'KeyRefresh');
TruffleAssert.eventEmitted(startKeygenTx, 'KeyRefresh', (event) => {
return event.hash = topologyHash;
});
});

it('Should fail if "refreshKey" is called by non admin', async () => {
await assertOnlyAdmin(BridgeInstance.refreshKey);
await assertOnlyAdmin(BridgeInstance.refreshKey, topologyHash);
});

// Set Handler Address
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const deployBridge = async (domainID, admin) => {
"0xbd2a1820", // adminWithdraw
"0x6ba6db6b", // startKeygen
"0xd2e5fae9", // endKeygen
"0xf5f63b39", // refreshKey
"0xd8236744", // refreshKey

],
Array(13).fill(admin)
Expand Down

0 comments on commit 35a3e8e

Please sign in to comment.