Skip to content

Commit

Permalink
Update contracts for coordinator test
Browse files Browse the repository at this point in the history
  • Loading branch information
vzotova committed Aug 30, 2023
1 parent c74edc6 commit 7b7899c
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
49 changes: 49 additions & 0 deletions contracts/test/CoordinatorTestSet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;

import "../threshold/ITACoChildApplication.sol";

/**
* @notice Contract for testing Coordinator contract
*/
contract ChildApplicationForCoordinatorMock is ITACoChildApplication {
mapping(address => uint96) public authorizedStake;
mapping(address => address) public operatorFromStakingProvider;
mapping(address => address) public stakingProviderFromOperator;
mapping(address => bool) public confirmations;

function updateOperator(address _stakingProvider, address _operator) external {
address oldOperator = operatorFromStakingProvider[_stakingProvider];
stakingProviderFromOperator[oldOperator] = address(0);
operatorFromStakingProvider[_stakingProvider] = _operator;
stakingProviderFromOperator[_operator] = _stakingProvider;
}

function updateAuthorization(address _stakingProvider, uint96 _amount) external {
authorizedStake[_stakingProvider] = _amount;
}

function confirmOperatorAddress(address _operator) external {
confirmations[_operator] = true;
}
}

// /**
// * @notice Intermediary contract for testing operator
// */
// contract Intermediary {
// TACoApplication public immutable application;

// constructor(TACoApplication _application) {
// application = _application;
// }

// function bondOperator(address _operator) external {
// application.bondOperator(address(this), _operator);
// }

// function confirmOperatorAddress() external {
// application.confirmOperatorAddress();
// }
// }
47 changes: 47 additions & 0 deletions contracts/test/TACoChildApplicationTestSet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;

import "../contracts/coordination/ITACoRootToChild.sol";
import "../contracts/coordination/ITACoChildToRoot.sol";

/**
* @notice Contract for testing TACo child application contract
*/
contract RootApplicationForTACoChildApplicationMock {
ITACoRootToChild public childApplication;

mapping(address => bool) public confirmations;

function setChildApplication(ITACoRootToChild _childApplication) external {
childApplication = _childApplication;
}

function updateOperator(address _stakingProvider, address _operator) external {
childApplication.updateOperator(_stakingProvider, _operator);
}

function updateAuthorization(address _stakingProvider, uint96 _amount) external {
childApplication.updateAuthorization(_stakingProvider, _amount);
}

function confirmOperatorAddress(address _operator) external {
confirmations[_operator] = true;
}

function resetConfirmation(address _operator) external {
confirmations[_operator] = false;
}
}

contract CoordinatorForTACoChildApplicationMock {
ITACoChildToRoot public immutable application;

constructor(ITACoChildToRoot _application) {
application = _application;
}

function confirmOperatorAddress(address _operator) external {
application.confirmOperatorAddress(_operator);
}
}

0 comments on commit 7b7899c

Please sign in to comment.