Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test branch #37

Merged
merged 52 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
43b64b4
added smart contract environment setup for Robot Framework
neptune-v Jan 17, 2023
e2ddef4
Add keywords to handle contract.
Andlyn Feb 16, 2023
c300ace
Add coordinator contract keywords.
Andlyn Feb 16, 2023
57bfdac
Update .gitignore
Andlyn Mar 8, 2023
848eedb
Merge branch 'main' into scenario-testing
Andlyn Mar 8, 2023
d58e70b
Add keywords of node.
Andlyn Mar 8, 2023
85d094d
Add controller and user contract deploy.
Andlyn Mar 8, 2023
40968c4
Add keyword to get value from log.
Andlyn Mar 14, 2023
4d42cd4
Add doc string and remove useless function.
Andlyn Mar 23, 2023
07c9594
Add scenario happy path#1
Andlyn Mar 28, 2023
b87f43f
Add test cases of DKG.
Andlyn Apr 5, 2023
df7273c
Merge branch 'pr/20' into test-branch
Andlyn Apr 12, 2023
456f522
add ./venv to gitignore
Andlyn Apr 12, 2023
5960937
Merge remote-tracking branch 'upstream/prepare-testnet-deployment' in…
Andlyn Apr 12, 2023
b267081
Adapt to contracts changes.
Andlyn Apr 13, 2023
89e5a51
Add long running test case.
Andlyn Apr 13, 2023
5e719f1
Merge remote-tracking branch 'upstream/add-retry-and-polling-manageme…
Andlyn Apr 13, 2023
b4cc211
Adapt node changes.
Andlyn Apr 14, 2023
ccdc33d
Change node config.
Andlyn Apr 19, 2023
6977674
Switch to proxy config.
Andlyn Apr 19, 2023
40e7af4
change node stdout.
Andlyn Apr 26, 2023
f78e6b4
Add BLS test case.
Andlyn May 16, 2023
93db540
Merge remote-tracking branch 'upstream/add-retry-and-polling-manageme…
Andlyn May 16, 2023
1fe602d
Merge remote-tracking branch 'origin/main' into test-branch
Andlyn May 16, 2023
d6537c5
Adapt to node and contract change.
Andlyn May 18, 2023
c96021c
Merge remote-tracking branch 'origin/main' into test-branch
Andlyn May 18, 2023
8aa954e
Add BLS test cases.
Andlyn May 26, 2023
61df6d1
Fix continuous executing bug.
Andlyn May 26, 2023
ca4f9a4
Add BLS corner2 test case.
Andlyn May 31, 2023
8f8ea59
Merge branch 'pr/27' into test-branch
Andlyn May 31, 2023
9e958e6
Merge branch 'pr/28' into test-branch
Andlyn May 31, 2023
5d60116
Adapt to the changes of contract and node.
Andlyn May 31, 2023
e360828
Merge remote-tracking branch 'origin/main' into test-branch
Andlyn Jun 7, 2023
f5b70c4
Add staking and marketing test cases.
Andlyn Jul 4, 2023
4d7f990
Merge remote-tracking branch 'origin/main' into test-branch
Andlyn Jul 4, 2023
a0fec1e
Add a staking test case.
Andlyn Jul 6, 2023
903d9eb
Merge branch 'main' into test-branch
Andlyn Jul 17, 2023
727dc3b
Optimize test cases and adapt to the node changes.
Andlyn Jul 20, 2023
8bba6f2
Add python requirements.txt.
Andlyn Jul 24, 2023
1ec47b7
Check if log exist.
Andlyn Jul 24, 2023
31571ba
Update log.py
Andlyn Jul 24, 2023
fde56de
Adapt to Ubuntu OS.
Andlyn Jul 25, 2023
86a18b4
Adapt to ubuntu OS.
Andlyn Jul 25, 2023
82c296c
Optimize use case execution time.
Andlyn Jul 26, 2023
74efcfb
Optimize use case execution time.
Andlyn Jul 26, 2023
40d6e26
Optimize case and Dockfile.
Andlyn Jul 27, 2023
313fd5c
Update scenario-tests.yml
Andlyn Jul 28, 2023
8c95e3a
Delete useless file.
Andlyn Jul 28, 2023
e6e56df
Update scenario-tests.yml
Andlyn Jul 28, 2023
b7694d9
Update scenario-tests.yml
Andlyn Jul 28, 2023
f80c220
Update scenario-tests.yml
Andlyn Jul 28, 2023
f0d42c1
Fix issues.
Andlyn Aug 22, 2023
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
20 changes: 20 additions & 0 deletions .github/workflows/scenario-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: scenario-test

on:
pull_request:

jobs:
scenario-test:
runs-on: ubuntu-latest
steps:
- name: Pull Docker image
run: docker pull andlyn/arpanetwork-test:latest

- name: Run Docker container
run: |
docker run --name=scenario \
andlyn/arpanetwork-test:latest \
/bin/bash -c "git config --global url."https://".insteadOf git://; \
git clone ${{ github.repositoryUrl }}; \
cd BLS-TSS-Network; git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.head_ref }}; git checkout ${{ github.head_ref }}; \
robot ./"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ solidity/build
# Custom
contracts/test/Test.t.sol
.DS_Store
/.venv
*.sqlite
passwd
*.pyc
*.history
2 changes: 1 addition & 1 deletion contracts/lib/openzeppelin-contracts
149 changes: 149 additions & 0 deletions contracts/script/ControllerScenarioTest.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script} from "forge-std/Script.sol";
import {Controller} from "../src/Controller.sol";
import {ControllerProxy} from "../src/ControllerProxy.sol";
import {IControllerOwner} from "../src/interfaces/IControllerOwner.sol";
import {Adapter} from "../src/Adapter.sol";
import {IAdapterOwner} from "../src/interfaces/IAdapterOwner.sol";
import {Arpa} from "./ArpaLocalTest.sol";
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import {ERC1967Proxy} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {Staking} from "Staking-v0.1/Staking.sol";

// solhint-disable-next-line max-states-count
contract ControllerScenarioTest is Script {
uint256 internal _deployerPrivateKey = vm.envUint("ADMIN_PRIVATE_KEY");

uint256 internal _disqualifiedNodePenaltyAmount = vm.envUint("DISQUALIFIED_NODE_PENALTY_AMOUNT");
uint256 internal _defaultNumberOfCommitters = vm.envUint("DEFAULT_NUMBER_OF_COMMITTERS");
uint256 internal _defaultDkgPhaseDuration = vm.envUint("DEFAULT_DKG_PHASE_DURATION");
uint256 internal _groupMaxCapacity = vm.envUint("GROUP_MAX_CAPACITY");
uint256 internal _idealNumberOfGroups = vm.envUint("IDEAL_NUMBER_OF_GROUPS");
uint256 internal _pendingBlockAfterQuit = vm.envUint("PENDING_BLOCK_AFTER_QUIT");
uint256 internal _dkgPostProcessReward = vm.envUint("DKG_POST_PROCESS_REWARD");
uint256 internal _lastOutput = vm.envUint("LAST_OUTPUT");

uint16 internal _minimumRequestConfirmations = uint16(vm.envUint("MINIMUM_REQUEST_CONFIRMATIONS"));
uint32 internal _maxGasLimit = uint32(vm.envUint("MAX_GAS_LIMIT"));
uint32 internal _gasAfterPaymentCalculation = uint32(vm.envUint("GAS_AFTER_PAYMENT_CALCULATION"));
uint32 internal _gasExceptCallback = uint32(vm.envUint("GAS_EXCEPT_CALLBACK"));
uint256 internal _signatureTaskExclusiveWindow = vm.envUint("SIGNATURE_TASK_EXCLUSIVE_WINDOW");
uint256 internal _rewardPerSignature = vm.envUint("REWARD_PER_SIGNATURE");
uint256 internal _committerRewardPerSignature = vm.envUint("COMMITTER_REWARD_PER_SIGNATURE");

uint32 internal _fulfillmentFlatFeeEthPPMTier1 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER1"));
uint32 internal _fulfillmentFlatFeeEthPPMTier2 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER2"));
uint32 internal _fulfillmentFlatFeeEthPPMTier3 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER3"));
uint32 internal _fulfillmentFlatFeeEthPPMTier4 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER4"));
uint32 internal _fulfillmentFlatFeeEthPPMTier5 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER5"));
uint24 internal _reqsForTier2 = uint24(vm.envUint("REQS_FOR_TIER2"));
uint24 internal _reqsForTier3 = uint24(vm.envUint("REQS_FOR_TIER3"));
uint24 internal _reqsForTier4 = uint24(vm.envUint("REQS_FOR_TIER4"));
uint24 internal _reqsForTier5 = uint24(vm.envUint("REQS_FOR_TIER5"));

uint16 internal _flatFeePromotionGlobalPercentage = uint16(vm.envUint("FLAT_FEE_PROMOTION_GLOBAL_PERCENTAGE"));
bool internal _isFlatFeePromotionEnabledPermanently = vm.envBool("IS_FLAT_FEE_PROMOTION_ENABLED_PERMANENTLY");
uint256 internal _flatFeePromotionStartTimestamp = block.timestamp;
uint256 internal _flatFeePromotionEndTimestamp = block.timestamp + 86400;

uint256 internal _initialMaxPoolSize = vm.envUint("INITIAL_MAX_POOL_SIZE");
uint256 internal _initialMaxCommunityStakeAmount = vm.envUint("INITIAL_MAX_COMMUNITY_STAKE_AMOUNT");
uint256 internal _minCommunityStakeAmount = vm.envUint("MIN_COMMUNITY_STAKE_AMOUNT");
uint256 internal _operatorStakeAmount = vm.envUint("OPERATOR_STAKE_AMOUNT");
uint256 internal _minInitialOperatorCount = vm.envUint("MIN_INITIAL_OPERATOR_COUNT");
uint256 internal _minRewardDuration = vm.envUint("MIN_REWARD_DURATION");
uint256 internal _delegationRateDenominator = vm.envUint("DELEGATION_RATE_DENOMINATOR");
uint256 internal _unstakeFreezingDuration = vm.envUint("UNSTAKE_FREEZING_DURATION");

function run() external {
Controller controller;
ControllerProxy proxy;
ERC1967Proxy adapter;
Adapter adapterImpl;
Staking staking;
IERC20 arpa;

vm.broadcast(_deployerPrivateKey);
arpa = new Arpa();

Staking.PoolConstructorParams memory params = Staking.PoolConstructorParams(
IERC20(address(arpa)),
_initialMaxPoolSize,
_initialMaxCommunityStakeAmount,
_minCommunityStakeAmount,
_operatorStakeAmount,
_minInitialOperatorCount,
_minRewardDuration,
_delegationRateDenominator,
_unstakeFreezingDuration
);
vm.broadcast(_deployerPrivateKey);
staking = new Staking(params);

vm.broadcast(_deployerPrivateKey);
controller = new Controller();

vm.broadcast(_deployerPrivateKey);
proxy = new ControllerProxy(address(controller));

vm.broadcast(_deployerPrivateKey);
IControllerOwner(address(proxy)).initialize(address(staking), _lastOutput);

vm.broadcast(_deployerPrivateKey);
adapterImpl = new Adapter();

vm.broadcast(_deployerPrivateKey);
adapter =
new ERC1967Proxy(address(adapterImpl),abi.encodeWithSignature("initialize(address)",address(proxy)));

vm.broadcast(_deployerPrivateKey);
IControllerOwner(address(proxy)).setControllerConfig(
address(staking),
address(adapter),
_operatorStakeAmount,
_disqualifiedNodePenaltyAmount,
_defaultNumberOfCommitters,
_defaultDkgPhaseDuration,
_groupMaxCapacity,
_idealNumberOfGroups,
_pendingBlockAfterQuit,
_dkgPostProcessReward
);

vm.broadcast(_deployerPrivateKey);
IAdapterOwner(address(adapter)).setAdapterConfig(
_minimumRequestConfirmations,
_maxGasLimit,
_gasAfterPaymentCalculation,
_gasExceptCallback,
_signatureTaskExclusiveWindow,
_rewardPerSignature,
_committerRewardPerSignature
);

vm.broadcast(_deployerPrivateKey);
IAdapterOwner(address(adapter)).setFlatFeeConfig(
IAdapterOwner.FeeConfig(
_fulfillmentFlatFeeEthPPMTier1,
_fulfillmentFlatFeeEthPPMTier2,
_fulfillmentFlatFeeEthPPMTier3,
_fulfillmentFlatFeeEthPPMTier4,
_fulfillmentFlatFeeEthPPMTier5,
_reqsForTier2,
_reqsForTier3,
_reqsForTier4,
_reqsForTier5
),
_flatFeePromotionGlobalPercentage,
_isFlatFeePromotionEnabledPermanently,
_flatFeePromotionStartTimestamp,
_flatFeePromotionEndTimestamp
);

vm.broadcast(_deployerPrivateKey);
staking.setController(address(proxy));
}
}
32 changes: 32 additions & 0 deletions contracts/script/GetRandomNumberScenarioTest.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {Script} from "forge-std/Script.sol";
import {IAdapter} from "../src/interfaces/IAdapter.sol";
import {GetRandomNumberExample} from "../src/user/examples/GetRandomNumberExample.sol";

contract GetRandomNumberScenarioTestScript is Script {
function run() external {
GetRandomNumberExample getRandomNumberExample;
IAdapter adapter;

uint256 plentyOfEthBalance = vm.envUint("PLENTY_OF_ETH_BALANCE");
address adapterAddress = vm.envAddress("ADAPTER_ADDRESS");
uint256 userPrivateKey = vm.envUint("USER_PRIVATE_KEY");

adapter = IAdapter(adapterAddress);

vm.startBroadcast(userPrivateKey);
getRandomNumberExample = new GetRandomNumberExample(
adapterAddress
);
uint64 subId = adapter.createSubscription();

adapter.fundSubscription{value: plentyOfEthBalance}(subId);

adapter.addConsumer(subId, address(getRandomNumberExample));

getRandomNumberExample.setCallbackGasConfig(2000000, 1500000000);

}
}
72 changes: 72 additions & 0 deletions contracts/script/StakeOperatorScenarioTest.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script} from "forge-std/Script.sol";
import {Staking} from "Staking-v0.1/Staking.sol";
import {Arpa} from "./ArpaLocalTest.sol";

contract StakeOperatorScenarioTestScript is Script {
uint256 internal _deployerPrivateKey = vm.envUint("ADMIN_PRIVATE_KEY");
uint256 internal _userPrivateKey = vm.envUint("USER_PRIVATE_KEY");

address internal _stakingAddress = vm.envAddress("STAKING_ADDRESS");
address internal _arpaAddress = vm.envAddress("ARPA_ADDRESS");

uint256 internal _rewardAmount = vm.envUint("REWARD_AMOUNT");
uint256 internal _operatorStakeAmount = vm.envUint("OPERATOR_STAKE_AMOUNT");

address[] internal _operators;
string internal _mnemonic = vm.envString("STAKING_NODES_MNEMONIC");
uint32 internal _stakingNodesIndexOffset = uint32(vm.envUint("STAKING_NODES_INDEX_OFFSET"));
uint32 internal _stakingNodesIndexLength = 10;
bool internal _isStakeUser = vm.envBool("IS_STAKE_USER");

Staking internal _staking;
Arpa internal _arpa;

function run() external {
_arpa = Arpa(_arpaAddress);
_staking = Staking(_stakingAddress);

// add operators
for (uint32 i = _stakingNodesIndexOffset; i < _stakingNodesIndexOffset + _stakingNodesIndexLength; i++) {
address operator = vm.rememberKey(vm.deriveKey(_mnemonic, i));
_operators.push(operator);

address payable toOperator = payable(operator);
vm.broadcast(_deployerPrivateKey);
toOperator.transfer(1 ether);
}

vm.broadcast(_deployerPrivateKey);
_staking.addOperators(_operators);

// start the _staking pool
vm.broadcast(_deployerPrivateKey);
_arpa.mint(vm.addr(_deployerPrivateKey), _rewardAmount);

vm.broadcast(_deployerPrivateKey);
_arpa.approve(address(_staking), _rewardAmount);


// let a user stake to accumulate some rewards
if (_isStakeUser) {
vm.broadcast(_deployerPrivateKey);
_staking.start(_rewardAmount, 30 days);
vm.rememberKey(_userPrivateKey);
_stake(vm.addr(_userPrivateKey));
}

}

function _stake(address sender) internal {
vm.broadcast(sender);
_arpa.mint(sender, _operatorStakeAmount);

vm.broadcast(sender);
_arpa.approve(address(_staking), _operatorStakeAmount);

vm.broadcast(sender);
_staking.stake(_operatorStakeAmount);
}
}
47 changes: 47 additions & 0 deletions contracts/script/TestFeeConfig.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script} from "forge-std/Script.sol";
import {Controller} from "../src/Controller.sol";
import {IControllerOwner} from "../src/interfaces/IControllerOwner.sol";
import {Adapter} from "../src/Adapter.sol";
import {IAdapterOwner} from "../src/interfaces/IAdapterOwner.sol";
import {Arpa} from "./ArpaLocalTest.sol";
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import {ERC1967Proxy} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {Staking} from "Staking-v0.1/Staking.sol";

// solhint-disable-next-line max-states-count
contract TestFeeConfigScript is Script {
uint256 internal _deployerPrivateKey = vm.envUint("DEPLOY_PRIVATE_KEY");

uint32 internal _fulfillmentFlatFeeEthPPMTier1 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER1"));
uint32 internal _fulfillmentFlatFeeEthPPMTier2 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER2"));
uint32 internal _fulfillmentFlatFeeEthPPMTier3 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER3"));
uint32 internal _fulfillmentFlatFeeEthPPMTier4 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER4"));
uint32 internal _fulfillmentFlatFeeEthPPMTier5 = uint32(vm.envUint("FULFILLMENT_FLAT_FEE_ARPA_PPM_TIER5"));
uint24 internal _reqsForTier2 = uint24(vm.envUint("REQS_FOR_TIER2"));
uint24 internal _reqsForTier3 = uint24(vm.envUint("REQS_FOR_TIER3"));
uint24 internal _reqsForTier4 = uint24(vm.envUint("REQS_FOR_TIER4"));
uint24 internal _reqsForTier5 = uint24(vm.envUint("REQS_FOR_TIER5"));

uint16 internal _flatFeePromotionGlobalPercentage = uint16(vm.envUint("FLAT_FEE_PROMOTION_GLOBAL_PERCENTAGE"));
bool internal _isFlatFeePromotionEnabledPermanently = vm.envBool("IS_FLAT_FEE_PROMOTION_ENABLED_PERMANENTLY");
uint256 internal _flatFeePromotionStartTimestamp = block.timestamp;
uint256 internal _flatFeePromotionEndTimestamp = block.timestamp + 120;


address internal _controllerAddress = vm.envAddress("CONTROLLER_ADDRESS");
address internal _stakingAddress = vm.envAddress("STAKING_ADDRESS");
address internal _adapterAddress = vm.envAddress("ADAPTER_ADDRESS");

function run() external {
vm.broadcast(_deployerPrivateKey);
IAdapterOwner(_adapterAddress).setReferralConfig(
true,
2,
2
);
}
}
Loading
Loading