-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5d4dc7
commit 24f5a6c
Showing
4 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
pragma solidity 0.5.17; | ||
|
||
import "../schemes/ContinuousLocking4Reputation.sol"; | ||
|
||
/** | ||
* @title ContinuousLocking4ReputationFactory | ||
*/ | ||
contract ContinuousLocking4ReputationFactory { | ||
|
||
event NewCL4R(address continuousLocking4Reputation); | ||
|
||
function createCL4R( | ||
Avatar _avatar, | ||
uint256 _reputationReward, | ||
uint256 _startTime, | ||
uint256 _batchTime, | ||
uint256 _redeemEnableTime, | ||
uint256 _maxLockingBatches, | ||
uint256 _repRewardConstA, | ||
uint256 _repRewardConstB, | ||
uint256 _batchesIndexCap, | ||
IERC20 _token, | ||
bytes32 _agreementHash) public returns(address) { | ||
ContinuousLocking4Reputation continuousLocking4Reputation = new ContinuousLocking4Reputation(); | ||
continuousLocking4Reputation.initialize( | ||
_avatar, | ||
_reputationReward, | ||
_startTime, | ||
_batchTime, | ||
_redeemEnableTime, | ||
_maxLockingBatches, | ||
_repRewardConstA, | ||
_repRewardConstB, | ||
_batchesIndexCap, | ||
_token, | ||
_agreementHash | ||
); | ||
emit NewCL4R(address(continuousLocking4Reputation)); | ||
return address(continuousLocking4Reputation); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const helpers = require('./helpers'); | ||
|
||
const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); | ||
const ContinuousLocking4Reputation = artifacts.require('./ContinuousLocking4Reputation.sol'); | ||
const ContinuousLocking4ReputationFactory = artifacts.require('./ContinuousLocking4ReputationFactory.sol'); | ||
|
||
const setup = async function () { | ||
var testSetup = new helpers.TestSetup(); | ||
testSetup.continuousLocking4ReputationFactory = await ContinuousLocking4ReputationFactory.new(); | ||
return testSetup; | ||
}; | ||
|
||
contract('competitionFactory', function(accounts) { | ||
it('initialize', async () => { | ||
let testSetup = await setup(); | ||
testSetup.lockingToken = await ERC20Mock.new(accounts[0], web3.utils.toWei('100', "ether")); | ||
testSetup.startTime = (await web3.eth.getBlock("latest")).timestamp; | ||
testSetup.redeemEnableTime = (await web3.eth.getBlock("latest")).timestamp + (30*60*60); | ||
testSetup.continuousLocking4Reputation = await ContinuousLocking4Reputation.new(); | ||
testSetup.periodsUnit = (30*60*60); | ||
testSetup.agreementHash = helpers.SOME_HASH; | ||
testSetup.maxLockingPeriod = 12; | ||
|
||
testSetup.repRewardConstA = 85000; | ||
testSetup.repRewardConstB = 900; | ||
testSetup.reputationReward = 850000; | ||
testSetup.periodsCap = 100; | ||
let cl4rAddress = await testSetup.continuousLocking4ReputationFactory.createCL4R.call( | ||
helpers.SOME_ADDRESS, | ||
testSetup.reputationReward, | ||
testSetup.startTime, | ||
testSetup.periodsUnit, | ||
testSetup.redeemEnableTime, | ||
testSetup.maxLockingPeriod, | ||
testSetup.repRewardConstA, | ||
testSetup.repRewardConstB, | ||
testSetup.periodsCap, | ||
testSetup.lockingToken.address, | ||
testSetup.agreementHash | ||
); | ||
await testSetup.continuousLocking4ReputationFactory.createCL4R( | ||
helpers.SOME_ADDRESS, | ||
testSetup.reputationReward, | ||
testSetup.startTime, | ||
testSetup.periodsUnit, | ||
testSetup.redeemEnableTime, | ||
testSetup.maxLockingPeriod, | ||
testSetup.repRewardConstA, | ||
testSetup.repRewardConstB, | ||
testSetup.periodsCap, | ||
testSetup.lockingToken.address, | ||
testSetup.agreementHash | ||
); | ||
let continuousLocking4Reputation = await ContinuousLocking4Reputation.at(cl4rAddress); | ||
assert.equal(await continuousLocking4Reputation.reputationRewardLeft(),testSetup.reputationReward); | ||
assert.equal(await continuousLocking4Reputation.startTime(),testSetup.startTime); | ||
assert.equal(await continuousLocking4Reputation.redeemEnableTime(),testSetup.redeemEnableTime); | ||
assert.equal(await continuousLocking4Reputation.token(),testSetup.lockingToken.address); | ||
assert.equal(await continuousLocking4Reputation.batchTime(),testSetup.periodsUnit); | ||
assert.equal(await continuousLocking4Reputation.getAgreementHash(),testSetup.agreementHash); | ||
assert.equal(await continuousLocking4Reputation.batchesIndexCap(),testSetup.periodsCap); | ||
}); | ||
|
||
}); |