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

Commit

Permalink
Add retry function (#574)
Browse files Browse the repository at this point in the history
* Add retry method

* Add retry method test
  • Loading branch information
nmlinaric committed Jun 20, 2022
1 parent 34cf568 commit b5c335f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contracts/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ contract Bridge is Pausable, AccessControl {

event KeyRefresh();

event Retry(string txHash);

modifier onlyAdmin() {
_onlyAdmin();
_;
Expand Down Expand Up @@ -301,6 +303,14 @@ contract Bridge is Pausable, AccessControl {
emit KeyRefresh();
}

/**
@notice This method is used to trigger the process for retrying failed deposits on the MPC side.
@param txHash Transaction hash which contains deposit that should be retried
*/
function retry(string memory txHash) external {
emit Retry(txHash);
}

/**
@notice Returns a boolean value.
@param domainID ID of chain deposit originated from.
Expand Down
38 changes: 38 additions & 0 deletions test/contractBridge/publicMethods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2020 ChainSafe Systems
* SPDX-License-Identifier: LGPL-3.0-only
*/
const TruffleAssert = require('truffle-assertions');
const Ethers = require('ethers');

const Helpers = require('../helpers');

const BridgeContract = artifacts.require("Bridge");

// This test does NOT include all getter methods, just
// getters that should work with only the constructor called
contract('Bridge - [public]', async (accounts) => {
const domainID = 1;

const txHash = "0x59d881e01ca682130e550e3576b6de760951fb45b1d5dd81342132f57920bbfa";

let BridgeInstance;


beforeEach(async () => {
BridgeInstance = await BridgeContract.new(domainID);

// set MPC address to unpause the Bridge
await BridgeInstance.endKeygen(Helpers.mpcAddress);
});

// Testing public methods

it('Should successfully emit Retry event', async () => {
const eventTx = await BridgeInstance.retry(txHash);

TruffleAssert.eventEmitted(eventTx, 'Retry', (event) => {
return event.txHash === txHash
});
});
});

0 comments on commit b5c335f

Please sign in to comment.