(Fix) tests to fit solidity-coverage's needs
This commit is contained in:
parent
52a4eed2bd
commit
f604f682e0
|
@ -2,7 +2,9 @@ node_modules
|
|||
build
|
||||
flat
|
||||
mochawesome-report
|
||||
coverage
|
||||
coverageEnv
|
||||
scTopics
|
||||
.DS_Store
|
||||
coverage.json
|
||||
contracts.json
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
norpc: true,
|
||||
compileCommand: '../node_modules/.bin/truffle compile',
|
||||
testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage',
|
||||
skipFiles: ['Migrations.sol'],
|
||||
copyNodeModules: true
|
||||
skipFiles: ['interfaces','libs']
|
||||
}
|
|
@ -66,10 +66,10 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
})
|
||||
it('thresholds are correct', async () => {
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(
|
||||
await ballotsStorage.getBallotThreshold(1)
|
||||
await ballotsStorage.getBallotThreshold.call(1)
|
||||
);
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(
|
||||
await ballotsStorage.getBallotThreshold(2)
|
||||
await ballotsStorage.getBallotThreshold.call(2)
|
||||
);
|
||||
})
|
||||
})
|
||||
|
@ -92,11 +92,11 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
})
|
||||
it('sets new value for Keys threshold', async () => {
|
||||
await ballotsStorage.setThreshold(5, 1, {from: accounts[3]}).should.be.fulfilled;
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold(1));
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold.call(1));
|
||||
})
|
||||
it('sets new value for MetadataChange threshold', async () => {
|
||||
await ballotsStorage.setThreshold(6, 2, {from: accounts[3]}).should.be.fulfilled;
|
||||
new web3.BigNumber(6).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold(2));
|
||||
new web3.BigNumber(6).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold.call(2));
|
||||
})
|
||||
})
|
||||
describe('#getTotalNumberOfValidators', async () => {
|
||||
|
@ -105,14 +105,14 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.setSystemAddress(masterOfCeremony);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
const getValidators = await poaNetworkConsensus.getValidators();
|
||||
const getValidators = await poaNetworkConsensus.getValidators.call();
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(getValidators.length);
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await ballotsStorage.getTotalNumberOfValidators())
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await ballotsStorage.getTotalNumberOfValidators.call())
|
||||
})
|
||||
})
|
||||
describe('#getProxyThreshold', async () => {
|
||||
it('return value is correct', async () => {
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold())
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call())
|
||||
await proxyStorage.setKeysManagerMock(masterOfCeremony);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true);
|
||||
|
@ -122,13 +122,13 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setKeysManagerMock(keysManager.address);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
const getValidators = await poaNetworkConsensus.getValidators();
|
||||
const getValidators = await poaNetworkConsensus.getValidators.call();
|
||||
new web3.BigNumber(6).should.be.bignumber.equal(getValidators.length);
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(false);
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold())
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(false);
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call())
|
||||
});
|
||||
it('return value is correct if MoC is removed', async () => {
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold())
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call())
|
||||
await proxyStorage.setKeysManagerMock(masterOfCeremony);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true);
|
||||
|
@ -139,9 +139,9 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setKeysManagerMock(keysManager.address);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
const getValidators = await poaNetworkConsensus.getValidators();
|
||||
const getValidators = await poaNetworkConsensus.getValidators.call();
|
||||
new web3.BigNumber(7).should.be.bignumber.equal(getValidators.length);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold());
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call());
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000001', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000002', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000003', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
@ -156,39 +156,39 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000012', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.removeMiningKey(masterOfCeremony, {from: votingToChangeKeys});
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(6);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold());
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(6);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call());
|
||||
});
|
||||
})
|
||||
describe('#getVotingToChangeThreshold', async () => {
|
||||
it('returns voting to change min threshold address', async () => {
|
||||
votingToChangeMinThreshold.should.be.equal(await ballotsStorage.getVotingToChangeThreshold())
|
||||
votingToChangeMinThreshold.should.be.equal(await ballotsStorage.getVotingToChangeThreshold.call())
|
||||
await proxyStorage.setVotingToChangeMinThresholdMock(accounts[4]);
|
||||
accounts[4].should.be.equal(await ballotsStorage.getVotingToChangeThreshold())
|
||||
accounts[4].should.be.equal(await ballotsStorage.getVotingToChangeThreshold.call())
|
||||
})
|
||||
})
|
||||
describe('#getBallotLimitPerValidator', async () => {
|
||||
it('returns correct limit', async () => {
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(200);
|
||||
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addMiningKey(accounts[2]).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(100);
|
||||
});
|
||||
it('returns correct limit if MoC is removed', async () => {
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(200);
|
||||
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addMiningKey(accounts[2]).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(3);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(3);
|
||||
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000001', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000002', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
@ -204,10 +204,10 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000012', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.removeMiningKey(masterOfCeremony, {from: votingToChangeKeys});
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(2);
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(2);
|
||||
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(100);
|
||||
});
|
||||
})
|
||||
|
@ -228,27 +228,27 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
});
|
||||
it('should change implementation address', async () => {
|
||||
let ballotsStorageNew = await BallotsStorageNew.new();
|
||||
const oldImplementation = await ballotsStorage.implementation();
|
||||
const oldImplementation = await ballotsStorage.implementation.call();
|
||||
const newImplementation = ballotsStorageNew.address;
|
||||
(await ballotsEternalStorage.implementation()).should.be.equal(oldImplementation);
|
||||
(await ballotsEternalStorage.implementation.call()).should.be.equal(oldImplementation);
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorageStubAddress);
|
||||
await ballotsEternalStorage.upgradeTo(newImplementation, {from: proxyStorageStubAddress});
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorage.address);
|
||||
ballotsStorageNew = await BallotsStorageNew.at(ballotsEternalStorage.address);
|
||||
(await ballotsStorageNew.implementation()).should.be.equal(newImplementation);
|
||||
(await ballotsEternalStorage.implementation()).should.be.equal(newImplementation);
|
||||
(await ballotsStorageNew.implementation.call()).should.be.equal(newImplementation);
|
||||
(await ballotsEternalStorage.implementation.call()).should.be.equal(newImplementation);
|
||||
});
|
||||
it('should increment implementation version', async () => {
|
||||
let ballotsStorageNew = await BallotsStorageNew.new();
|
||||
const oldVersion = await ballotsStorage.version();
|
||||
const oldVersion = await ballotsStorage.version.call();
|
||||
const newVersion = oldVersion.add(1);
|
||||
(await ballotsEternalStorage.version()).should.be.bignumber.equal(oldVersion);
|
||||
(await ballotsEternalStorage.version.call()).should.be.bignumber.equal(oldVersion);
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorageStubAddress);
|
||||
await ballotsEternalStorage.upgradeTo(ballotsStorageNew.address, {from: proxyStorageStubAddress});
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorage.address);
|
||||
ballotsStorageNew = await BallotsStorageNew.at(ballotsEternalStorage.address);
|
||||
(await ballotsStorageNew.version()).should.be.bignumber.equal(newVersion);
|
||||
(await ballotsEternalStorage.version()).should.be.bignumber.equal(newVersion);
|
||||
(await ballotsStorageNew.version.call()).should.be.bignumber.equal(newVersion);
|
||||
(await ballotsEternalStorage.version.call()).should.be.bignumber.equal(newVersion);
|
||||
});
|
||||
it('new implementation should work', async () => {
|
||||
let ballotsStorageNew = await BallotsStorageNew.new();
|
||||
|
@ -256,16 +256,16 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
await ballotsEternalStorage.upgradeTo(ballotsStorageNew.address, {from: proxyStorageStubAddress});
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorage.address);
|
||||
ballotsStorageNew = await BallotsStorageNew.at(ballotsEternalStorage.address);
|
||||
(await ballotsStorageNew.initialized()).should.be.equal(false);
|
||||
(await ballotsStorageNew.initialized.call()).should.be.equal(false);
|
||||
await ballotsStorageNew.initialize();
|
||||
(await ballotsStorageNew.initialized()).should.be.equal(true);
|
||||
(await ballotsStorageNew.initialized.call()).should.be.equal(true);
|
||||
});
|
||||
it('new implementation should use the same proxyStorage address', async () => {
|
||||
let ballotsStorageNew = await BallotsStorageNew.new();
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorageStubAddress);
|
||||
await ballotsEternalStorage.upgradeTo(ballotsStorageNew.address, {from: proxyStorageStubAddress});
|
||||
ballotsStorageNew = await BallotsStorageNew.at(ballotsEternalStorage.address);
|
||||
(await ballotsStorageNew.proxyStorage()).should.be.equal(proxyStorageStubAddress);
|
||||
(await ballotsStorageNew.proxyStorage.call()).should.be.equal(proxyStorageStubAddress);
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorage.address);
|
||||
});
|
||||
it('new implementation should use the same storage', async () => {
|
||||
|
@ -274,7 +274,7 @@ contract('BallotsStorage [all features]', function (accounts) {
|
|||
await ballotsEternalStorage.setProxyStorage(proxyStorageStubAddress);
|
||||
await ballotsEternalStorage.upgradeTo(ballotsStorageNew.address, {from: proxyStorageStubAddress});
|
||||
ballotsStorageNew = await BallotsStorageNew.at(ballotsEternalStorage.address);
|
||||
const threshold = await ballotsStorageNew.getBallotThreshold(1);
|
||||
const threshold = await ballotsStorageNew.getBallotThreshold.call(1);
|
||||
threshold.should.be.bignumber.equal(6);
|
||||
await ballotsEternalStorage.setProxyStorage(proxyStorage.address);
|
||||
});
|
||||
|
|
|
@ -72,10 +72,10 @@ contract('BallotsStorage upgraded [all features]', function (accounts) {
|
|||
})
|
||||
it('thresholds are correct', async () => {
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(
|
||||
await ballotsStorage.getBallotThreshold(1)
|
||||
await ballotsStorage.getBallotThreshold.call(1)
|
||||
);
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(
|
||||
await ballotsStorage.getBallotThreshold(2)
|
||||
await ballotsStorage.getBallotThreshold.call(2)
|
||||
);
|
||||
})
|
||||
})
|
||||
|
@ -98,11 +98,11 @@ contract('BallotsStorage upgraded [all features]', function (accounts) {
|
|||
})
|
||||
it('sets new value for Keys threshold', async () => {
|
||||
await ballotsStorage.setThreshold(5, 1, {from: accounts[3]}).should.be.fulfilled;
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold(1));
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold.call(1));
|
||||
})
|
||||
it('sets new value for MetadataChange threshold', async () => {
|
||||
await ballotsStorage.setThreshold(6, 2, {from: accounts[3]}).should.be.fulfilled;
|
||||
new web3.BigNumber(6).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold(2));
|
||||
new web3.BigNumber(6).should.be.bignumber.equal(await ballotsStorage.getBallotThreshold.call(2));
|
||||
})
|
||||
})
|
||||
describe('#getTotalNumberOfValidators', async () => {
|
||||
|
@ -111,14 +111,14 @@ contract('BallotsStorage upgraded [all features]', function (accounts) {
|
|||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.setSystemAddress(masterOfCeremony);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
const getValidators = await poaNetworkConsensus.getValidators();
|
||||
const getValidators = await poaNetworkConsensus.getValidators.call();
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(getValidators.length);
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await ballotsStorage.getTotalNumberOfValidators())
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await ballotsStorage.getTotalNumberOfValidators.call())
|
||||
})
|
||||
})
|
||||
describe('#getProxyThreshold', async () => {
|
||||
it('return value is correct', async () => {
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold())
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call())
|
||||
await proxyStorage.setKeysManagerMock(masterOfCeremony);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true);
|
||||
|
@ -128,13 +128,13 @@ contract('BallotsStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setKeysManagerMock(keysManager.address);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
const getValidators = await poaNetworkConsensus.getValidators();
|
||||
const getValidators = await poaNetworkConsensus.getValidators.call();
|
||||
new web3.BigNumber(6).should.be.bignumber.equal(getValidators.length);
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(false);
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold())
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(false);
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call())
|
||||
});
|
||||
it('return value is correct if MoC is removed', async () => {
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold())
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call())
|
||||
await proxyStorage.setKeysManagerMock(masterOfCeremony);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true);
|
||||
|
@ -145,9 +145,9 @@ contract('BallotsStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setKeysManagerMock(keysManager.address);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
const getValidators = await poaNetworkConsensus.getValidators();
|
||||
const getValidators = await poaNetworkConsensus.getValidators.call();
|
||||
new web3.BigNumber(7).should.be.bignumber.equal(getValidators.length);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold());
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call());
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000001', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000002', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000003', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
@ -162,39 +162,39 @@ contract('BallotsStorage upgraded [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000012', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.removeMiningKey(masterOfCeremony, {from: votingToChangeKeys});
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(6);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold());
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(6);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await ballotsStorage.getProxyThreshold.call());
|
||||
});
|
||||
})
|
||||
describe('#getVotingToChangeThreshold', async () => {
|
||||
it('returns voting to change min threshold address', async () => {
|
||||
votingToChangeMinThreshold.should.be.equal(await ballotsStorage.getVotingToChangeThreshold())
|
||||
votingToChangeMinThreshold.should.be.equal(await ballotsStorage.getVotingToChangeThreshold.call())
|
||||
await proxyStorage.setVotingToChangeMinThresholdMock(accounts[4]);
|
||||
accounts[4].should.be.equal(await ballotsStorage.getVotingToChangeThreshold())
|
||||
accounts[4].should.be.equal(await ballotsStorage.getVotingToChangeThreshold.call())
|
||||
})
|
||||
})
|
||||
describe('#getBallotLimitPerValidator', async () => {
|
||||
it('returns correct limit', async () => {
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(200);
|
||||
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addMiningKey(accounts[2]).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(100);
|
||||
});
|
||||
it('returns correct limit if MoC is removed', async () => {
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
let limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(200);
|
||||
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addMiningKey(accounts[2]).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(3);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(3);
|
||||
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000001', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000002', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
@ -210,10 +210,10 @@ contract('BallotsStorage upgraded [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000012', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.removeMiningKey(masterOfCeremony, {from: votingToChangeKeys});
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(2);
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(true);
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(2);
|
||||
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator();
|
||||
limit = await ballotsStorage.getBallotLimitPerValidator.call();
|
||||
limit.should.be.bignumber.equal(100);
|
||||
});
|
||||
})
|
||||
|
|
|
@ -44,12 +44,12 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
|
||||
describe('#constructor', async () => {
|
||||
it('sets masterOfCeremony, proxyStorage, poaConsensus', async () => {
|
||||
masterOfCeremony.should.be.equal(await keysManager.masterOfCeremony());
|
||||
proxyStorageMock.address.should.be.equal(await keysManager.proxyStorage());
|
||||
poaNetworkConsensusMock.address.should.be.equal(await keysManager.poaNetworkConsensus());
|
||||
masterOfCeremony.should.be.equal(await keysManager.masterOfCeremony.call());
|
||||
proxyStorageMock.address.should.be.equal(await keysManager.proxyStorage.call());
|
||||
poaNetworkConsensusMock.address.should.be.equal(await keysManager.poaNetworkConsensus.call());
|
||||
})
|
||||
it('adds masterOfCeremony to validators hash', async () => {
|
||||
const validator = await keysManager.validatorKeys(masterOfCeremony);
|
||||
const validator = await keysManager.validatorKeys.call(masterOfCeremony);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -87,7 +87,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
})
|
||||
|
||||
it('should not allow to initialize more than maxNumberOfInitialKeys', async () => {
|
||||
let maxNumberOfInitialKeys = await keysManager.maxNumberOfInitialKeys();
|
||||
let maxNumberOfInitialKeys = await keysManager.maxNumberOfInitialKeys.call();
|
||||
maxNumberOfInitialKeys.should.be.bignumber.equal(12);
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000001', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000002', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
@ -105,18 +105,18 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
})
|
||||
|
||||
it('should increment initialKeyCount by 1', async () => {
|
||||
let initialKeysCount = await keysManager.initialKeysCount();
|
||||
let initialKeysCount = await keysManager.initialKeysCount.call();
|
||||
initialKeysCount.should.be.bignumber.equal(0);
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
initialKeysCount = await keysManager.initialKeysCount();
|
||||
initialKeysCount = await keysManager.initialKeysCount.call();
|
||||
initialKeysCount.should.be.bignumber.equal(1);
|
||||
})
|
||||
|
||||
it('should set initialKeys hash to activated status', async() => {
|
||||
new web3.BigNumber(0).should.be.bignumber.equal(await keysManager.initialKeys(accounts[1]));
|
||||
new web3.BigNumber(0).should.be.bignumber.equal(await keysManager.initialKeys.call(accounts[1]));
|
||||
const {logs} = await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await keysManager.initialKeys(accounts[1]));
|
||||
let initialKeysCount = await keysManager.initialKeysCount();
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await keysManager.initialKeys.call(accounts[1]));
|
||||
let initialKeysCount = await keysManager.initialKeysCount.call();
|
||||
// event InitialKeyCreated(address indexed initialKey, uint256 time, uint256 initialKeysCount);
|
||||
logs[0].event.should.equal("InitialKeyCreated");
|
||||
logs[0].args.initialKey.should.be.equal(accounts[1]);
|
||||
|
@ -145,13 +145,13 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
const {logs} = await keysManager.createKeys(accounts[4], accounts[3], accounts[2], {from: accounts[1]}).should.be.fulfilled;
|
||||
true.should.be.equal(
|
||||
await keysManager.isMiningActive(accounts[4])
|
||||
await keysManager.isMiningActive.call(accounts[4])
|
||||
)
|
||||
true.should.be.equal(
|
||||
await keysManager.isVotingActive(accounts[3])
|
||||
await keysManager.isVotingActive.call(accounts[3])
|
||||
)
|
||||
true.should.be.equal(
|
||||
await keysManager.isPayoutActive(accounts[4])
|
||||
await keysManager.isPayoutActive.call(accounts[4])
|
||||
)
|
||||
// event ValidatorInitialized(address indexed miningKey, address indexed votingKey, address indexed payoutKey);
|
||||
logs[0].event.should.be.equal('ValidatorInitialized');
|
||||
|
@ -163,22 +163,22 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
it('should assigns voting <-> mining key relationship', async () => {
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(accounts[4], accounts[3], accounts[2], {from: accounts[1]});
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(accounts[3]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(accounts[3]);
|
||||
miningKey.should.be.equal(accounts[4]);
|
||||
});
|
||||
it('adds validator to poaConsensus contract', async () => {
|
||||
let miningKey = accounts[4];
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, accounts[3], accounts[2], {from: accounts[1]});
|
||||
const index = await poaNetworkConsensusMock.currentValidatorsLength();
|
||||
(await poaNetworkConsensusMock.pendingList(index)).should.be.equal(miningKey);
|
||||
const index = await poaNetworkConsensusMock.currentValidatorsLength.call();
|
||||
(await poaNetworkConsensusMock.pendingList.call(index)).should.be.equal(miningKey);
|
||||
})
|
||||
|
||||
it('should set validatorKeys hash', async () => {
|
||||
let miningKey = accounts[4];
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, accounts[3], accounts[2], {from: accounts[1]});
|
||||
const validatorKey = await keysManager.validatorKeys(miningKey);
|
||||
const validatorKey = await keysManager.validatorKeys.call(miningKey);
|
||||
validatorKey.should.be.deep.equal([
|
||||
accounts[3],
|
||||
accounts[2],
|
||||
|
@ -192,7 +192,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
let miningKey = accounts[4];
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, accounts[3], accounts[2], {from: accounts[1]});
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await keysManager.initialKeys(accounts[1]));
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await keysManager.initialKeys.call(accounts[1]));
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -208,7 +208,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
})
|
||||
it('should set validatorKeys hash', async () => {
|
||||
const {logs} = await keysManager.addMiningKey(accounts[2]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[2]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[2]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -227,13 +227,13 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(accounts[2],accounts[1], {from: accounts[3]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.addVotingKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
true.should.be.equal(await keysManager.isVotingActive(accounts[2]));
|
||||
true.should.be.equal(await keysManager.isVotingActive.call(accounts[2]));
|
||||
logs[0].event.should.be.equal('VotingKeyChanged');
|
||||
logs[0].args.key.should.be.equal(accounts[2]);
|
||||
logs[0].args.miningKey.should.be.equal(accounts[1]);
|
||||
logs[0].args.action.should.be.equal('added');
|
||||
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(accounts[2]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(accounts[2]);
|
||||
miningKey.should.be.equal(accounts[1]);
|
||||
})
|
||||
it('should only be called if mining is active', async () => {
|
||||
|
@ -246,9 +246,9 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
false.should.be.equal(await keysManager.isVotingActive(accounts[2]));
|
||||
true.should.be.equal(await keysManager.isVotingActive(accounts[3]));
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
false.should.be.equal(await keysManager.isVotingActive.call(accounts[2]));
|
||||
true.should.be.equal(await keysManager.isVotingActive.call(accounts[3]));
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ accounts[3],
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -279,8 +279,8 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
true.should.be.equal(await keysManager.isPayoutActive(accounts[1]));
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
true.should.be.equal(await keysManager.isPayoutActive.call(accounts[1]));
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
accounts[3],
|
||||
|
@ -297,7 +297,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removeMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -308,7 +308,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
logs[0].event.should.be.equal('MiningKeyChanged');
|
||||
logs[0].args.key.should.be.equal(accounts[1]);
|
||||
logs[0].args.action.should.be.equal('removed');
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(validator[0]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(validator[0]);
|
||||
miningKey.should.be.equal('0x0000000000000000000000000000000000000000');
|
||||
})
|
||||
|
||||
|
@ -317,18 +317,18 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
await keysManager.removeMiningKey(accounts[1]).should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensusMock.currentValidatorsLength();
|
||||
let currentValidatorsLength = await poaNetworkConsensusMock.currentValidatorsLength.call();
|
||||
let pendingList = [];
|
||||
for(let i = 0; i < currentValidatorsLength.sub(1).toNumber(); i++){
|
||||
let pending = await poaNetworkConsensusMock.pendingList(i);
|
||||
let pending = await poaNetworkConsensusMock.pendingList.call(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
pendingList.should.not.contain(accounts[1]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(accounts[1]);
|
||||
const expected = currentValidatorsLength.sub(1);
|
||||
const actual = await poaNetworkConsensusMock.currentValidatorsLength();
|
||||
const actual = await poaNetworkConsensusMock.currentValidatorsLength.call();
|
||||
expected.should.be.bignumber.equal(actual);
|
||||
});
|
||||
|
||||
|
@ -346,20 +346,20 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000011', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
||||
await keysManager.removeMiningKey(masterOfCeremony).should.be.rejectedWith(ERROR_MSG);
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(false);
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.isValidator(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength()).should.be.bignumber.equal(1);
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(false);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.isValidator.call(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength.call()).should.be.bignumber.equal(1);
|
||||
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000012', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
||||
await keysManager.removeMiningKey(masterOfCeremony).should.be.fulfilled;
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(true);
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(true);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
(await poaNetworkConsensusMock.isValidator(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength()).should.be.bignumber.equal(0);
|
||||
(await poaNetworkConsensusMock.isValidator.call(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength.call()).should.be.bignumber.equal(0);
|
||||
});
|
||||
|
||||
it('should still enforce removal of votingKey to 0x0 even if voting key didnot exist', async () => {
|
||||
|
@ -367,8 +367,8 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await proxyStorageMock.setVotingContractMock(masterOfCeremony);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removeMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(validator[0]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(validator[0]);
|
||||
miningKey.should.be.equal('0x0000000000000000000000000000000000000000');
|
||||
})
|
||||
})
|
||||
|
@ -381,7 +381,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(voting, mining).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(payout, mining).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removeVotingKey(mining).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(mining);
|
||||
const validator = await keysManager.validatorKeys.call(mining);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
payout,
|
||||
|
@ -392,7 +392,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
logs[0].event.should.be.equal('VotingKeyChanged');
|
||||
logs[0].args.key.should.be.equal(voting);
|
||||
logs[0].args.action.should.be.equal('removed');
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(accounts[1]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(accounts[1]);
|
||||
miningKey.should.be.equal('0x0000000000000000000000000000000000000000');
|
||||
})
|
||||
})
|
||||
|
@ -404,7 +404,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addPayoutKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removePayoutKey(accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ accounts[3],
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -423,7 +423,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.swapMiningKey(accounts[1], accounts[2], {from: accounts[4]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.swapMiningKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -431,7 +431,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
false,
|
||||
false ]
|
||||
)
|
||||
const validatorNew = await keysManager.validatorKeys(accounts[2]);
|
||||
const validatorNew = await keysManager.validatorKeys.call(accounts[2]);
|
||||
validatorNew.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -441,15 +441,15 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
)
|
||||
});
|
||||
it('should swap MoC', async () => {
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
await keysManager.swapMiningKey(accounts[1], masterOfCeremony).should.be.fulfilled;
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.isValidator(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.isValidator(accounts[1])).should.be.equal(true);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony.call()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.isValidator.call(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.isValidator.call(accounts[1])).should.be.equal(true);
|
||||
});
|
||||
it('should keep voting and payout keys', async () => {
|
||||
const oldMining = accounts[1];
|
||||
|
@ -460,10 +460,10 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(voting, oldMining).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(payout, oldMining).should.be.fulfilled;
|
||||
const {logs} = await keysManager.swapMiningKey(newMining, oldMining).should.be.fulfilled;
|
||||
const mining = await keysManager.getMiningKeyByVoting(voting);
|
||||
const validator = await keysManager.validatorKeys(oldMining);
|
||||
const mining = await keysManager.getMiningKeyByVoting.call(voting);
|
||||
const validator = await keysManager.validatorKeys.call(oldMining);
|
||||
|
||||
const miningCheck = await keysManager.getMiningKeyByVoting(voting);
|
||||
const miningCheck = await keysManager.getMiningKeyByVoting.call(voting);
|
||||
miningCheck.should.be.equal(newMining);
|
||||
|
||||
validator.should.be.deep.equal(
|
||||
|
@ -473,7 +473,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
false,
|
||||
false ]
|
||||
)
|
||||
const validatorNew = await keysManager.validatorKeys(newMining);
|
||||
const validatorNew = await keysManager.validatorKeys.call(newMining);
|
||||
validatorNew.should.be.deep.equal(
|
||||
[ voting,
|
||||
payout,
|
||||
|
@ -481,10 +481,10 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
true,
|
||||
true]
|
||||
)
|
||||
oldMining.should.be.equal(await keysManager.getMiningKeyHistory(newMining));
|
||||
oldMining.should.be.equal(await keysManager.getMiningKeyHistory.call(newMining));
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(oldMining);
|
||||
validators.should.contain(newMining);
|
||||
})
|
||||
|
@ -496,7 +496,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.swapVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ accounts[3],
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -513,7 +513,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.swapPayoutKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
accounts[3],
|
||||
|
@ -534,9 +534,9 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await newKeysManager.init(masterOfCeremony, keysManager.address).should.be.fulfilled;
|
||||
|
||||
keysManager.address.should.be.equal(
|
||||
await newKeysManager.previousKeysManager()
|
||||
await newKeysManager.previousKeysManager.call()
|
||||
)
|
||||
let initialKeys = await newKeysManager.initialKeysCount();
|
||||
let initialKeys = await newKeysManager.initialKeysCount.call();
|
||||
initialKeys.should.be.bignumber.equal(1);
|
||||
let {logs} = await newKeysManager.migrateInitialKey(accounts[1]);
|
||||
logs[0].event.should.equal("Migrated");
|
||||
|
@ -544,11 +544,11 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
logs[0].args.name.should.be.equal("initialKey");
|
||||
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(
|
||||
await newKeysManager.initialKeys(accounts[1])
|
||||
await newKeysManager.initialKeys.call(accounts[1])
|
||||
)
|
||||
await newKeysManager.migrateInitialKey(accounts[2]).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(0).should.be.bignumber.equal(
|
||||
await newKeysManager.initialKeys(accounts[2])
|
||||
await newKeysManager.initialKeys.call(accounts[2])
|
||||
)
|
||||
})
|
||||
it('copies validator keys', async () => {
|
||||
|
@ -561,7 +561,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, votingKey, payoutKey, {from: accounts[1]}).should.be.fulfilled;
|
||||
const validatorKeyFromOld = await keysManager.validatorKeys(miningKey);
|
||||
const validatorKeyFromOld = await keysManager.validatorKeys.call(miningKey);
|
||||
validatorKeyFromOld.should.be.deep.equal([
|
||||
votingKey,
|
||||
payoutKey,
|
||||
|
@ -581,9 +581,9 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
logs[0].args.key.should.be.equal(miningKey);
|
||||
logs[0].args.name.should.be.equal("miningKey");
|
||||
|
||||
let initialKeys = await newKeysManager.initialKeysCount();
|
||||
let initialKeys = await newKeysManager.initialKeysCount.call();
|
||||
initialKeys.should.be.bignumber.equal(1);
|
||||
const validatorKey = await newKeysManager.validatorKeys(miningKey);
|
||||
const validatorKey = await newKeysManager.validatorKeys.call(miningKey);
|
||||
validatorKey.should.be.deep.equal([
|
||||
votingKey,
|
||||
payoutKey,
|
||||
|
@ -592,26 +592,26 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
true
|
||||
])
|
||||
true.should.be.equal(
|
||||
await newKeysManager.successfulValidatorClone(miningKey)
|
||||
await newKeysManager.successfulValidatorClone.call(miningKey)
|
||||
)
|
||||
|
||||
miningKey.should.be.equal(
|
||||
await newKeysManager.getMiningKeyByVoting(votingKey)
|
||||
await newKeysManager.getMiningKeyByVoting.call(votingKey)
|
||||
);
|
||||
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isMiningActive(miningKey)
|
||||
await newKeysManager.isMiningActive.call(miningKey)
|
||||
)
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isVotingActive(votingKey)
|
||||
await newKeysManager.isVotingActive.call(votingKey)
|
||||
)
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isPayoutActive(miningKey)
|
||||
await newKeysManager.isPayoutActive.call(miningKey)
|
||||
)
|
||||
|
||||
// mining#2
|
||||
await newKeysManager.migrateMiningKey(mining2);
|
||||
const validatorKey2 = await newKeysManager.validatorKeys(mining2);
|
||||
const validatorKey2 = await newKeysManager.validatorKeys.call(mining2);
|
||||
validatorKey2.should.be.deep.equal([
|
||||
"0x0000000000000000000000000000000000000000",
|
||||
"0x0000000000000000000000000000000000000000",
|
||||
|
@ -621,10 +621,10 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
])
|
||||
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isMiningActive(mining2)
|
||||
await newKeysManager.isMiningActive.call(mining2)
|
||||
)
|
||||
true.should.be.equal(
|
||||
await newKeysManager.successfulValidatorClone(mining2)
|
||||
await newKeysManager.successfulValidatorClone.call(mining2)
|
||||
)
|
||||
})
|
||||
it('throws when trying to copy invalid mining key', async () => {
|
||||
|
@ -634,7 +634,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await newKeysManager.init(masterOfCeremony, keysManager.address).should.be.fulfilled;
|
||||
|
||||
true.should.be.equal(
|
||||
await newKeysManager.successfulValidatorClone(masterOfCeremony)
|
||||
await newKeysManager.successfulValidatorClone.call(masterOfCeremony)
|
||||
);
|
||||
await newKeysManager.migrateMiningKey(masterOfCeremony).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
@ -660,40 +660,40 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
});
|
||||
it('should change implementation address', async () => {
|
||||
let keysManagerNew = await KeysManagerNew.new();
|
||||
let oldImplementation = await keysManager.implementation();
|
||||
let oldImplementation = await keysManager.implementation.call();
|
||||
let newImplementation = keysManagerNew.address;
|
||||
(await keysManagerEternalStorage.implementation()).should.be.equal(oldImplementation);
|
||||
(await keysManagerEternalStorage.implementation.call()).should.be.equal(oldImplementation);
|
||||
await keysManagerEternalStorage.upgradeTo(newImplementation, {from: proxyStorageStubAddress});
|
||||
keysManagerNew = await KeysManagerNew.at(keysManagerEternalStorage.address);
|
||||
(await keysManagerNew.implementation()).should.be.equal(newImplementation);
|
||||
(await keysManagerEternalStorage.implementation()).should.be.equal(newImplementation);
|
||||
(await keysManagerNew.implementation.call()).should.be.equal(newImplementation);
|
||||
(await keysManagerEternalStorage.implementation.call()).should.be.equal(newImplementation);
|
||||
});
|
||||
it('should increment implementation version', async () => {
|
||||
let keysManagerNew = await KeysManagerNew.new();
|
||||
let oldVersion = await keysManager.version();
|
||||
let oldVersion = await keysManager.version.call();
|
||||
let newVersion = oldVersion.add(1);
|
||||
(await keysManagerEternalStorage.version()).should.be.bignumber.equal(oldVersion);
|
||||
(await keysManagerEternalStorage.version.call()).should.be.bignumber.equal(oldVersion);
|
||||
await keysManagerEternalStorage.upgradeTo(keysManagerNew.address, {from: proxyStorageStubAddress});
|
||||
keysManagerNew = await KeysManagerNew.at(keysManagerEternalStorage.address);
|
||||
(await keysManagerNew.version()).should.be.bignumber.equal(newVersion);
|
||||
(await keysManagerEternalStorage.version()).should.be.bignumber.equal(newVersion);
|
||||
(await keysManagerNew.version.call()).should.be.bignumber.equal(newVersion);
|
||||
(await keysManagerEternalStorage.version.call()).should.be.bignumber.equal(newVersion);
|
||||
});
|
||||
it('new implementation should work', async () => {
|
||||
let keysManagerNew = await KeysManagerNew.new();
|
||||
await keysManagerEternalStorage.upgradeTo(keysManagerNew.address, {from: proxyStorageStubAddress});
|
||||
keysManagerNew = await KeysManagerNew.at(keysManagerEternalStorage.address);
|
||||
(await keysManagerNew.initialized()).should.be.equal(false);
|
||||
(await keysManagerNew.initialized.call()).should.be.equal(false);
|
||||
await keysManagerNew.initialize();
|
||||
(await keysManagerNew.initialized()).should.be.equal(true);
|
||||
(await keysManagerNew.initialized.call()).should.be.equal(true);
|
||||
});
|
||||
it('new implementation should use the same proxyStorage address', async () => {
|
||||
let keysManagerNew = await KeysManagerNew.new();
|
||||
await keysManagerEternalStorage.upgradeTo(keysManagerNew.address, {from: proxyStorageStubAddress});
|
||||
keysManagerNew = await KeysManagerNew.at(keysManagerEternalStorage.address);
|
||||
(await keysManagerNew.proxyStorage()).should.be.equal(proxyStorageStubAddress);
|
||||
(await keysManagerNew.proxyStorage.call()).should.be.equal(proxyStorageStubAddress);
|
||||
});
|
||||
it('new implementation should use the same storage', async () => {
|
||||
let keys = await keysManager.validatorKeys(accounts[2]);
|
||||
let keys = await keysManager.validatorKeys.call(accounts[2]);
|
||||
keys.should.be.deep.equal([
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -709,7 +709,7 @@ contract('KeysManager [all features]', function (accounts) {
|
|||
await keysManager.setProxyStorage(proxyStorageStubAddress);
|
||||
await keysManagerEternalStorage.upgradeTo(keysManagerNew.address, {from: proxyStorageStubAddress});
|
||||
keysManagerNew = await KeysManagerNew.at(keysManagerEternalStorage.address);
|
||||
keys = await keysManagerNew.validatorKeys(accounts[2]);
|
||||
keys = await keysManagerNew.validatorKeys.call(accounts[2]);
|
||||
keys.should.be.deep.equal([accounts[3], accounts[4], true, true, true]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -50,12 +50,12 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
|
||||
describe('#constructor', async () => {
|
||||
it('sets masterOfCeremony, proxyStorage, poaConsensus', async () => {
|
||||
masterOfCeremony.should.be.equal(await keysManager.masterOfCeremony());
|
||||
proxyStorageMock.address.should.be.equal(await keysManager.proxyStorage());
|
||||
poaNetworkConsensusMock.address.should.be.equal(await keysManager.poaNetworkConsensus());
|
||||
masterOfCeremony.should.be.equal(await keysManager.masterOfCeremony.call());
|
||||
proxyStorageMock.address.should.be.equal(await keysManager.proxyStorage.call());
|
||||
poaNetworkConsensusMock.address.should.be.equal(await keysManager.poaNetworkConsensus.call());
|
||||
})
|
||||
it('adds masterOfCeremony to validators hash', async () => {
|
||||
const validator = await keysManager.validatorKeys(masterOfCeremony);
|
||||
const validator = await keysManager.validatorKeys.call(masterOfCeremony);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -93,7 +93,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
})
|
||||
|
||||
it('should not allow to initialize more than maxNumberOfInitialKeys', async () => {
|
||||
let maxNumberOfInitialKeys = await keysManager.maxNumberOfInitialKeys();
|
||||
let maxNumberOfInitialKeys = await keysManager.maxNumberOfInitialKeys.call();
|
||||
maxNumberOfInitialKeys.should.be.bignumber.equal(12);
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000001', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000002', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
@ -111,18 +111,18 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
})
|
||||
|
||||
it('should increment initialKeyCount by 1', async () => {
|
||||
let initialKeysCount = await keysManager.initialKeysCount();
|
||||
let initialKeysCount = await keysManager.initialKeysCount.call();
|
||||
initialKeysCount.should.be.bignumber.equal(0);
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
initialKeysCount = await keysManager.initialKeysCount();
|
||||
initialKeysCount = await keysManager.initialKeysCount.call();
|
||||
initialKeysCount.should.be.bignumber.equal(1);
|
||||
})
|
||||
|
||||
it('should set initialKeys hash to activated status', async() => {
|
||||
new web3.BigNumber(0).should.be.bignumber.equal(await keysManager.initialKeys(accounts[1]));
|
||||
new web3.BigNumber(0).should.be.bignumber.equal(await keysManager.initialKeys.call(accounts[1]));
|
||||
const {logs} = await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await keysManager.initialKeys(accounts[1]));
|
||||
let initialKeysCount = await keysManager.initialKeysCount();
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await keysManager.initialKeys.call(accounts[1]));
|
||||
let initialKeysCount = await keysManager.initialKeysCount.call();
|
||||
// event InitialKeyCreated(address indexed initialKey, uint256 time, uint256 initialKeysCount);
|
||||
logs[0].event.should.equal("InitialKeyCreated");
|
||||
logs[0].args.initialKey.should.be.equal(accounts[1]);
|
||||
|
@ -151,13 +151,13 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
const {logs} = await keysManager.createKeys(accounts[4], accounts[3], accounts[2], {from: accounts[1]}).should.be.fulfilled;
|
||||
true.should.be.equal(
|
||||
await keysManager.isMiningActive(accounts[4])
|
||||
await keysManager.isMiningActive.call(accounts[4])
|
||||
)
|
||||
true.should.be.equal(
|
||||
await keysManager.isVotingActive(accounts[3])
|
||||
await keysManager.isVotingActive.call(accounts[3])
|
||||
)
|
||||
true.should.be.equal(
|
||||
await keysManager.isPayoutActive(accounts[4])
|
||||
await keysManager.isPayoutActive.call(accounts[4])
|
||||
)
|
||||
// event ValidatorInitialized(address indexed miningKey, address indexed votingKey, address indexed payoutKey);
|
||||
logs[0].event.should.be.equal('ValidatorInitialized');
|
||||
|
@ -169,22 +169,22 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
it('should assigns voting <-> mining key relationship', async () => {
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(accounts[4], accounts[3], accounts[2], {from: accounts[1]});
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(accounts[3]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(accounts[3]);
|
||||
miningKey.should.be.equal(accounts[4]);
|
||||
});
|
||||
it('adds validator to poaConsensus contract', async () => {
|
||||
let miningKey = accounts[4];
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, accounts[3], accounts[2], {from: accounts[1]});
|
||||
const index = await poaNetworkConsensusMock.currentValidatorsLength();
|
||||
(await poaNetworkConsensusMock.pendingList(index)).should.be.equal(miningKey);
|
||||
const index = await poaNetworkConsensusMock.currentValidatorsLength.call();
|
||||
(await poaNetworkConsensusMock.pendingList.call(index)).should.be.equal(miningKey);
|
||||
})
|
||||
|
||||
it('should set validatorKeys hash', async () => {
|
||||
let miningKey = accounts[4];
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, accounts[3], accounts[2], {from: accounts[1]});
|
||||
const validatorKey = await keysManager.validatorKeys(miningKey);
|
||||
const validatorKey = await keysManager.validatorKeys.call(miningKey);
|
||||
validatorKey.should.be.deep.equal([
|
||||
accounts[3],
|
||||
accounts[2],
|
||||
|
@ -198,7 +198,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
let miningKey = accounts[4];
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, accounts[3], accounts[2], {from: accounts[1]});
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await keysManager.initialKeys(accounts[1]));
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await keysManager.initialKeys.call(accounts[1]));
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -214,7 +214,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
})
|
||||
it('should set validatorKeys hash', async () => {
|
||||
const {logs} = await keysManager.addMiningKey(accounts[2]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[2]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[2]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -233,13 +233,13 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(accounts[2],accounts[1], {from: accounts[3]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.addVotingKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
true.should.be.equal(await keysManager.isVotingActive(accounts[2]));
|
||||
true.should.be.equal(await keysManager.isVotingActive.call(accounts[2]));
|
||||
logs[0].event.should.be.equal('VotingKeyChanged');
|
||||
logs[0].args.key.should.be.equal(accounts[2]);
|
||||
logs[0].args.miningKey.should.be.equal(accounts[1]);
|
||||
logs[0].args.action.should.be.equal('added');
|
||||
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(accounts[2]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(accounts[2]);
|
||||
miningKey.should.be.equal(accounts[1]);
|
||||
})
|
||||
it('should only be called if mining is active', async () => {
|
||||
|
@ -252,9 +252,9 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
false.should.be.equal(await keysManager.isVotingActive(accounts[2]));
|
||||
true.should.be.equal(await keysManager.isVotingActive(accounts[3]));
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
false.should.be.equal(await keysManager.isVotingActive.call(accounts[2]));
|
||||
true.should.be.equal(await keysManager.isVotingActive.call(accounts[3]));
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ accounts[3],
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -285,8 +285,8 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
true.should.be.equal(await keysManager.isPayoutActive(accounts[1]));
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
true.should.be.equal(await keysManager.isPayoutActive.call(accounts[1]));
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
accounts[3],
|
||||
|
@ -303,7 +303,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removeMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -314,7 +314,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
logs[0].event.should.be.equal('MiningKeyChanged');
|
||||
logs[0].args.key.should.be.equal(accounts[1]);
|
||||
logs[0].args.action.should.be.equal('removed');
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(validator[0]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(validator[0]);
|
||||
miningKey.should.be.equal('0x0000000000000000000000000000000000000000');
|
||||
})
|
||||
|
||||
|
@ -323,18 +323,18 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
await keysManager.removeMiningKey(accounts[1]).should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensusMock.currentValidatorsLength();
|
||||
let currentValidatorsLength = await poaNetworkConsensusMock.currentValidatorsLength.call();
|
||||
let pendingList = [];
|
||||
for(let i = 0; i < currentValidatorsLength.sub(1).toNumber(); i++){
|
||||
let pending = await poaNetworkConsensusMock.pendingList(i);
|
||||
let pending = await poaNetworkConsensusMock.pendingList.call(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
pendingList.should.not.contain(accounts[1]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(accounts[1]);
|
||||
const expected = currentValidatorsLength.sub(1);
|
||||
const actual = await poaNetworkConsensusMock.currentValidatorsLength();
|
||||
const actual = await poaNetworkConsensusMock.currentValidatorsLength.call();
|
||||
expected.should.be.bignumber.equal(actual);
|
||||
});
|
||||
|
||||
|
@ -352,20 +352,20 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000011', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
||||
await keysManager.removeMiningKey(masterOfCeremony).should.be.rejectedWith(ERROR_MSG);
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(false);
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.isValidator(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength()).should.be.bignumber.equal(1);
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(false);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.isValidator.call(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength.call()).should.be.bignumber.equal(1);
|
||||
|
||||
await keysManager.initiateKeys('0x0000000000000000000000000000000000000012', {from: masterOfCeremony}).should.be.fulfilled;
|
||||
|
||||
await keysManager.removeMiningKey(masterOfCeremony).should.be.fulfilled;
|
||||
(await keysManager.isMasterOfCeremonyRemoved()).should.be.equal(true);
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await keysManager.isMasterOfCeremonyRemoved.call()).should.be.equal(true);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
(await poaNetworkConsensusMock.isValidator(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength()).should.be.bignumber.equal(0);
|
||||
(await poaNetworkConsensusMock.isValidator.call(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.getCurrentValidatorsLength.call()).should.be.bignumber.equal(0);
|
||||
});
|
||||
|
||||
it('should still enforce removal of votingKey to 0x0 even if voting key didnot exist', async () => {
|
||||
|
@ -373,8 +373,8 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await proxyStorageMock.setVotingContractMock(masterOfCeremony);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removeMiningKey(accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(validator[0]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(validator[0]);
|
||||
miningKey.should.be.equal('0x0000000000000000000000000000000000000000');
|
||||
})
|
||||
})
|
||||
|
@ -387,7 +387,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(voting, mining).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(payout, mining).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removeVotingKey(mining).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(mining);
|
||||
const validator = await keysManager.validatorKeys.call(mining);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
payout,
|
||||
|
@ -398,7 +398,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
logs[0].event.should.be.equal('VotingKeyChanged');
|
||||
logs[0].args.key.should.be.equal(voting);
|
||||
logs[0].args.action.should.be.equal('removed');
|
||||
const miningKey = await keysManager.getMiningKeyByVoting(accounts[1]);
|
||||
const miningKey = await keysManager.getMiningKeyByVoting.call(accounts[1]);
|
||||
miningKey.should.be.equal('0x0000000000000000000000000000000000000000');
|
||||
})
|
||||
})
|
||||
|
@ -410,7 +410,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addPayoutKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const {logs} = await keysManager.removePayoutKey(accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ accounts[3],
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -429,7 +429,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.swapMiningKey(accounts[1], accounts[2], {from: accounts[4]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.swapMiningKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -437,7 +437,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
false,
|
||||
false ]
|
||||
)
|
||||
const validatorNew = await keysManager.validatorKeys(accounts[2]);
|
||||
const validatorNew = await keysManager.validatorKeys.call(accounts[2]);
|
||||
validatorNew.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -447,15 +447,15 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
)
|
||||
});
|
||||
it('should swap MoC', async () => {
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
await keysManager.swapMiningKey(accounts[1], masterOfCeremony).should.be.fulfilled;
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
(await keysManager.masterOfCeremony()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.isValidator(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.isValidator(accounts[1])).should.be.equal(true);
|
||||
(await keysManager.masterOfCeremony.call()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.masterOfCeremony.call()).should.be.equal(accounts[1]);
|
||||
(await poaNetworkConsensusMock.isValidator.call(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensusMock.isValidator.call(accounts[1])).should.be.equal(true);
|
||||
});
|
||||
it('should keep voting and payout keys', async () => {
|
||||
const oldMining = accounts[1];
|
||||
|
@ -466,10 +466,10 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(voting, oldMining).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(payout, oldMining).should.be.fulfilled;
|
||||
const {logs} = await keysManager.swapMiningKey(newMining, oldMining).should.be.fulfilled;
|
||||
const mining = await keysManager.getMiningKeyByVoting(voting);
|
||||
const validator = await keysManager.validatorKeys(oldMining);
|
||||
const mining = await keysManager.getMiningKeyByVoting.call(voting);
|
||||
const validator = await keysManager.validatorKeys.call(oldMining);
|
||||
|
||||
const miningCheck = await keysManager.getMiningKeyByVoting(voting);
|
||||
const miningCheck = await keysManager.getMiningKeyByVoting.call(voting);
|
||||
miningCheck.should.be.equal(newMining);
|
||||
|
||||
validator.should.be.deep.equal(
|
||||
|
@ -479,7 +479,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
false,
|
||||
false ]
|
||||
)
|
||||
const validatorNew = await keysManager.validatorKeys(newMining);
|
||||
const validatorNew = await keysManager.validatorKeys.call(newMining);
|
||||
validatorNew.should.be.deep.equal(
|
||||
[ voting,
|
||||
payout,
|
||||
|
@ -487,10 +487,10 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
true,
|
||||
true]
|
||||
)
|
||||
oldMining.should.be.equal(await keysManager.getMiningKeyHistory(newMining));
|
||||
oldMining.should.be.equal(await keysManager.getMiningKeyHistory.call(newMining));
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(oldMining);
|
||||
validators.should.contain(newMining);
|
||||
})
|
||||
|
@ -502,7 +502,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.swapVotingKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ accounts[3],
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -519,7 +519,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addPayoutKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await keysManager.swapPayoutKey(accounts[3], accounts[1]).should.be.fulfilled;
|
||||
const validator = await keysManager.validatorKeys(accounts[1]);
|
||||
const validator = await keysManager.validatorKeys.call(accounts[1]);
|
||||
validator.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
accounts[3],
|
||||
|
@ -540,9 +540,9 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await newKeysManager.init(masterOfCeremony, keysManager.address).should.be.fulfilled;
|
||||
|
||||
keysManager.address.should.be.equal(
|
||||
await newKeysManager.previousKeysManager()
|
||||
await newKeysManager.previousKeysManager.call()
|
||||
)
|
||||
let initialKeys = await newKeysManager.initialKeysCount();
|
||||
let initialKeys = await newKeysManager.initialKeysCount.call();
|
||||
initialKeys.should.be.bignumber.equal(1);
|
||||
let {logs} = await newKeysManager.migrateInitialKey(accounts[1]);
|
||||
logs[0].event.should.equal("Migrated");
|
||||
|
@ -550,11 +550,11 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
logs[0].args.name.should.be.equal("initialKey");
|
||||
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(
|
||||
await newKeysManager.initialKeys(accounts[1])
|
||||
await newKeysManager.initialKeys.call(accounts[1])
|
||||
)
|
||||
await newKeysManager.migrateInitialKey(accounts[2]).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(0).should.be.bignumber.equal(
|
||||
await newKeysManager.initialKeys(accounts[2])
|
||||
await newKeysManager.initialKeys.call(accounts[2])
|
||||
)
|
||||
})
|
||||
it('copies validator keys', async () => {
|
||||
|
@ -567,7 +567,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
|
||||
await keysManager.initiateKeys(accounts[1], {from: masterOfCeremony}).should.be.fulfilled;
|
||||
await keysManager.createKeys(miningKey, votingKey, payoutKey, {from: accounts[1]}).should.be.fulfilled;
|
||||
const validatorKeyFromOld = await keysManager.validatorKeys(miningKey);
|
||||
const validatorKeyFromOld = await keysManager.validatorKeys.call(miningKey);
|
||||
validatorKeyFromOld.should.be.deep.equal([
|
||||
votingKey,
|
||||
payoutKey,
|
||||
|
@ -587,9 +587,9 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
logs[0].args.key.should.be.equal(miningKey);
|
||||
logs[0].args.name.should.be.equal("miningKey");
|
||||
|
||||
let initialKeys = await newKeysManager.initialKeysCount();
|
||||
let initialKeys = await newKeysManager.initialKeysCount.call();
|
||||
initialKeys.should.be.bignumber.equal(1);
|
||||
const validatorKey = await newKeysManager.validatorKeys(miningKey);
|
||||
const validatorKey = await newKeysManager.validatorKeys.call(miningKey);
|
||||
validatorKey.should.be.deep.equal([
|
||||
votingKey,
|
||||
payoutKey,
|
||||
|
@ -598,26 +598,26 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
true
|
||||
])
|
||||
true.should.be.equal(
|
||||
await newKeysManager.successfulValidatorClone(miningKey)
|
||||
await newKeysManager.successfulValidatorClone.call(miningKey)
|
||||
)
|
||||
|
||||
miningKey.should.be.equal(
|
||||
await newKeysManager.getMiningKeyByVoting(votingKey)
|
||||
await newKeysManager.getMiningKeyByVoting.call(votingKey)
|
||||
);
|
||||
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isMiningActive(miningKey)
|
||||
await newKeysManager.isMiningActive.call(miningKey)
|
||||
)
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isVotingActive(votingKey)
|
||||
await newKeysManager.isVotingActive.call(votingKey)
|
||||
)
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isPayoutActive(miningKey)
|
||||
await newKeysManager.isPayoutActive.call(miningKey)
|
||||
)
|
||||
|
||||
// mining#2
|
||||
await newKeysManager.migrateMiningKey(mining2);
|
||||
const validatorKey2 = await newKeysManager.validatorKeys(mining2);
|
||||
const validatorKey2 = await newKeysManager.validatorKeys.call(mining2);
|
||||
validatorKey2.should.be.deep.equal([
|
||||
"0x0000000000000000000000000000000000000000",
|
||||
"0x0000000000000000000000000000000000000000",
|
||||
|
@ -627,10 +627,10 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
])
|
||||
|
||||
true.should.be.equal(
|
||||
await newKeysManager.isMiningActive(mining2)
|
||||
await newKeysManager.isMiningActive.call(mining2)
|
||||
)
|
||||
true.should.be.equal(
|
||||
await newKeysManager.successfulValidatorClone(mining2)
|
||||
await newKeysManager.successfulValidatorClone.call(mining2)
|
||||
)
|
||||
})
|
||||
it('throws when trying to copy invalid mining key', async () => {
|
||||
|
@ -640,7 +640,7 @@ contract('KeysManager upgraded [all features]', function (accounts) {
|
|||
await newKeysManager.init(masterOfCeremony, keysManager.address).should.be.fulfilled;
|
||||
|
||||
true.should.be.equal(
|
||||
await newKeysManager.successfulValidatorClone(masterOfCeremony)
|
||||
await newKeysManager.successfulValidatorClone.call(masterOfCeremony)
|
||||
);
|
||||
await newKeysManager.migrateMiningKey(masterOfCeremony).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
|
|
@ -87,7 +87,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
describe('#createMetadata', async () => {
|
||||
it('happy path', async () => {
|
||||
const {logs} = await metadata.createMetadata(...fakeData, {from: votingKey}).should.be.fulfilled;
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Djamshut"),
|
||||
toHex("Roosvelt"),
|
||||
|
@ -105,7 +105,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
})
|
||||
it('should not let create metadata if called by non-voting key', async () => {
|
||||
const {logs} = await metadata.createMetadata(...fakeData, {from: miningKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
|
@ -126,9 +126,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
})
|
||||
describe('#getMiningByVotingKey', async () => {
|
||||
it('happy path', async () => {
|
||||
let actual = await metadata.getMiningByVotingKey(votingKey);
|
||||
let actual = await metadata.getMiningByVotingKey.call(votingKey);
|
||||
miningKey.should.be.equal(actual);
|
||||
actual = await metadata.getMiningByVotingKey(accounts[4]);
|
||||
actual = await metadata.getMiningByVotingKey.call(accounts[4]);
|
||||
'0x0000000000000000000000000000000000000000'.should.be.equal(actual);
|
||||
})
|
||||
})
|
||||
|
@ -140,7 +140,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
it('happy path', async () => {
|
||||
await metadata.setTime(4444);
|
||||
const {logs} = await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
toHex("Feodosiy"),
|
||||
toHex("Kennedy"),
|
||||
|
@ -164,13 +164,13 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey2});
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey3});
|
||||
let confirmations = await metadata.confirmations(miningKey);
|
||||
let confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(2);
|
||||
const {logs} = await metadata.changeRequest(...anotherData, {from: votingKey}).should.be.fulfilled;
|
||||
confirmations = await metadata.confirmations(miningKey);
|
||||
confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(0);
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey2});
|
||||
confirmations = await metadata.confirmations(miningKey);
|
||||
confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(1);
|
||||
})
|
||||
})
|
||||
|
@ -182,7 +182,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
await metadata.setTime(4444);
|
||||
const {logs} = await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.cancelPendingChange({from: votingKey}).should.be.fulfilled;
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
|
@ -195,7 +195,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
]);
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Djamshut"),
|
||||
toHex("Roosvelt"),
|
||||
|
@ -217,7 +217,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
await metadata.setTime(4444);
|
||||
const {logs} = await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.cancelPendingChange({from: votingKey2}).should.be.fulfilled;
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
toHex("Feodosiy"),
|
||||
toHex("Kennedy"),
|
||||
|
@ -230,7 +230,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
]);
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Djamshut"),
|
||||
toHex("Roosvelt"),
|
||||
|
@ -255,7 +255,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
await metadata.createMetadata(...fakeData, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
const {logs} = await metadata.confirmPendingChange(miningKey, {from: votingKey2}).should.be.fulfilled;
|
||||
const confirmations = await metadata.confirmations(miningKey);
|
||||
const confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Confirmed');
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -266,7 +266,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
const {logs} = await metadata.confirmPendingChange(miningKey, {from: votingKey2}).should.be.fulfilled;
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey2}).should.be.rejectedWith(ERROR_MSG);
|
||||
const confirmations = await metadata.confirmations(miningKey);
|
||||
const confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(1);
|
||||
})
|
||||
});
|
||||
|
@ -279,7 +279,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
await metadata.confirmPendingChange(miningKey, {from: votingKey2});
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey3});
|
||||
const {logs} = await metadata.finalize(miningKey, {from: votingKey});
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Feodosiy"),
|
||||
toHex("Kennedy"),
|
||||
|
@ -292,7 +292,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
]);
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
|
@ -312,29 +312,29 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
|
||||
describe('#getMinThreshold', async () => {
|
||||
it('returns default value', async () => {
|
||||
(await metadata.getMinThreshold()).should.be.bignumber.equal(2);
|
||||
(await metadata.getMinThreshold.call()).should.be.bignumber.equal(2);
|
||||
})
|
||||
})
|
||||
describe('#setProxyAddress', async () => {
|
||||
let newProxy = "0xfb9c7fc2a00dffc53948e3bbeb11f3d4b56c31b8";
|
||||
it('can request a new proxy address', async () => {
|
||||
"0x0000000000000000000000000000000000000000".should.be.equal
|
||||
(await metadata.pendingProxyStorage());
|
||||
(await metadata.proxyStorage()).should.be.equal(proxyStorageMock.address);
|
||||
(await metadata.pendingProxyStorage.call());
|
||||
(await metadata.proxyStorage.call()).should.be.equal(proxyStorageMock.address);
|
||||
await metadata.setProxyAddress(newProxy, {from: miningKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
const {logs} = await metadata.setProxyAddress(newProxy, {from: votingKey}).should.be.fulfilled;
|
||||
(await metadata.pendingProxyStorage()).should.be.equal(newProxy);
|
||||
(await metadata.pendingProxyConfirmations(newProxy))[0].should.be.bignumber.deep.equal(1);
|
||||
(await metadata.pendingProxyStorage.call()).should.be.equal(newProxy);
|
||||
(await metadata.pendingProxyConfirmations.call(newProxy))[0].should.be.bignumber.deep.equal(1);
|
||||
logs[0].event.should.be.equal("RequestForNewProxy");
|
||||
logs[0].args.newProxyAddress.should.be.equal(newProxy);
|
||||
await metadata.confirmNewProxyAddress(newProxy, {from :votingKey2}).should.be.fulfilled;
|
||||
(await metadata.pendingProxyConfirmations(newProxy))[0].should.be.bignumber.deep.equal(2);
|
||||
(await metadata.pendingProxyConfirmations.call(newProxy))[0].should.be.bignumber.deep.equal(2);
|
||||
let final = await metadata.confirmNewProxyAddress(newProxy, {from: votingKey3}).should.be.fulfilled;
|
||||
final.logs[0].event.should.be.equal("ChangeProxyStorage");
|
||||
final.logs[0].args.newProxyAddress.should.be.equal(newProxy);
|
||||
"0x0000000000000000000000000000000000000000".should.be.equal
|
||||
(await metadata.pendingProxyStorage());
|
||||
(await metadata.proxyStorage()).should.be.equal(newProxy);
|
||||
(await metadata.pendingProxyStorage.call());
|
||||
(await metadata.proxyStorage.call()).should.be.equal(newProxy);
|
||||
})
|
||||
})
|
||||
describe('#upgradeTo', async () => {
|
||||
|
@ -351,37 +351,37 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
});
|
||||
it('should change implementation address', async () => {
|
||||
let metadataNew = await ValidatorMetadataNew.new();
|
||||
let oldImplementation = await metadata.implementation();
|
||||
let oldImplementation = await metadata.implementation.call();
|
||||
let newImplementation = metadataNew.address;
|
||||
(await metadataEternalStorage.implementation()).should.be.equal(oldImplementation);
|
||||
(await metadataEternalStorage.implementation.call()).should.be.equal(oldImplementation);
|
||||
await metadataEternalStorage.upgradeTo(newImplementation, {from: proxyStorageStubAddress});
|
||||
metadataNew = await ValidatorMetadataNew.at(metadataEternalStorage.address);
|
||||
(await metadataNew.implementation()).should.be.equal(newImplementation);
|
||||
(await metadataEternalStorage.implementation()).should.be.equal(newImplementation);
|
||||
(await metadataNew.implementation.call()).should.be.equal(newImplementation);
|
||||
(await metadataEternalStorage.implementation.call()).should.be.equal(newImplementation);
|
||||
});
|
||||
it('should increment implementation version', async () => {
|
||||
let metadataNew = await ValidatorMetadataNew.new();
|
||||
let oldVersion = await metadata.version();
|
||||
let oldVersion = await metadata.version.call();
|
||||
let newVersion = oldVersion.add(1);
|
||||
(await metadataEternalStorage.version()).should.be.bignumber.equal(oldVersion);
|
||||
(await metadataEternalStorage.version.call()).should.be.bignumber.equal(oldVersion);
|
||||
await metadataEternalStorage.upgradeTo(metadataNew.address, {from: proxyStorageStubAddress});
|
||||
metadataNew = await ValidatorMetadataNew.at(metadataEternalStorage.address);
|
||||
(await metadataNew.version()).should.be.bignumber.equal(newVersion);
|
||||
(await metadataEternalStorage.version()).should.be.bignumber.equal(newVersion);
|
||||
(await metadataNew.version.call()).should.be.bignumber.equal(newVersion);
|
||||
(await metadataEternalStorage.version.call()).should.be.bignumber.equal(newVersion);
|
||||
});
|
||||
it('new implementation should work', async () => {
|
||||
let metadataNew = await ValidatorMetadataNew.new();
|
||||
await metadataEternalStorage.upgradeTo(metadataNew.address, {from: proxyStorageStubAddress});
|
||||
metadataNew = await ValidatorMetadataNew.at(metadataEternalStorage.address);
|
||||
(await metadataNew.initialized()).should.be.equal(false);
|
||||
(await metadataNew.initialized.call()).should.be.equal(false);
|
||||
await metadataNew.initialize();
|
||||
(await metadataNew.initialized()).should.be.equal(true);
|
||||
(await metadataNew.initialized.call()).should.be.equal(true);
|
||||
});
|
||||
it('new implementation should use the same proxyStorage address', async () => {
|
||||
let metadataNew = await ValidatorMetadataNew.new();
|
||||
await metadataEternalStorage.upgradeTo(metadataNew.address, {from: proxyStorageStubAddress});
|
||||
metadataNew = await ValidatorMetadataNew.at(metadataEternalStorage.address);
|
||||
(await metadataNew.proxyStorage()).should.be.equal(proxyStorageStubAddress);
|
||||
(await metadataNew.proxyStorage.call()).should.be.equal(proxyStorageStubAddress);
|
||||
});
|
||||
it('new implementation should use the same storage', async () => {
|
||||
await metadata.setTime(55555);
|
||||
|
@ -391,7 +391,7 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
let metadataNew = await ValidatorMetadataNew.new();
|
||||
await metadataEternalStorage.upgradeTo(metadataNew.address, {from: proxyStorageStubAddress});
|
||||
metadataNew = await ValidatorMetadataNew.at(metadataEternalStorage.address);
|
||||
const validators = await metadataNew.validators(miningKey);
|
||||
const validators = await metadataNew.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Djamshut"),
|
||||
toHex("Roosvelt"),
|
||||
|
@ -408,11 +408,6 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
});
|
||||
})
|
||||
|
||||
var toUtf8 = function(hex) {
|
||||
var buf = new Buffer(hex.replace('0x',''),'hex');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
function toHex(someString) {
|
||||
var hex = '0x' + new Buffer(someString).toString('hex');
|
||||
hex = pad(hex);
|
||||
|
|
|
@ -91,7 +91,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
describe('#createMetadata', async () => {
|
||||
it('happy path', async () => {
|
||||
const {logs} = await metadata.createMetadata(...fakeData, {from: votingKey}).should.be.fulfilled;
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Djamshut"),
|
||||
toHex("Roosvelt"),
|
||||
|
@ -109,7 +109,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
})
|
||||
it('should not let create metadata if called by non-voting key', async () => {
|
||||
const {logs} = await metadata.createMetadata(...fakeData, {from: miningKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
|
@ -130,9 +130,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
})
|
||||
describe('#getMiningByVotingKey', async () => {
|
||||
it('happy path', async () => {
|
||||
let actual = await metadata.getMiningByVotingKey(votingKey);
|
||||
let actual = await metadata.getMiningByVotingKey.call(votingKey);
|
||||
miningKey.should.be.equal(actual);
|
||||
actual = await metadata.getMiningByVotingKey(accounts[4]);
|
||||
actual = await metadata.getMiningByVotingKey.call(accounts[4]);
|
||||
'0x0000000000000000000000000000000000000000'.should.be.equal(actual);
|
||||
})
|
||||
})
|
||||
|
@ -144,7 +144,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
it('happy path', async () => {
|
||||
await metadata.setTime(4444);
|
||||
const {logs} = await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
toHex("Feodosiy"),
|
||||
toHex("Kennedy"),
|
||||
|
@ -168,13 +168,13 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey2});
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey3});
|
||||
let confirmations = await metadata.confirmations(miningKey);
|
||||
let confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(2);
|
||||
const {logs} = await metadata.changeRequest(...anotherData, {from: votingKey}).should.be.fulfilled;
|
||||
confirmations = await metadata.confirmations(miningKey);
|
||||
confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(0);
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey2});
|
||||
confirmations = await metadata.confirmations(miningKey);
|
||||
confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(1);
|
||||
})
|
||||
})
|
||||
|
@ -186,7 +186,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
await metadata.setTime(4444);
|
||||
const {logs} = await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.cancelPendingChange({from: votingKey}).should.be.fulfilled;
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
|
@ -199,7 +199,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
]);
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Djamshut"),
|
||||
toHex("Roosvelt"),
|
||||
|
@ -221,7 +221,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
await metadata.setTime(4444);
|
||||
const {logs} = await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.cancelPendingChange({from: votingKey2}).should.be.fulfilled;
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
toHex("Feodosiy"),
|
||||
toHex("Kennedy"),
|
||||
|
@ -234,7 +234,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
]);
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Djamshut"),
|
||||
toHex("Roosvelt"),
|
||||
|
@ -259,7 +259,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
await metadata.createMetadata(...fakeData, {from: votingKey}).should.be.fulfilled;
|
||||
await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
const {logs} = await metadata.confirmPendingChange(miningKey, {from: votingKey2}).should.be.fulfilled;
|
||||
const confirmations = await metadata.confirmations(miningKey);
|
||||
const confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Confirmed');
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -270,7 +270,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
await metadata.changeRequest(...newMetadata, {from: votingKey}).should.be.fulfilled;
|
||||
const {logs} = await metadata.confirmPendingChange(miningKey, {from: votingKey2}).should.be.fulfilled;
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey2}).should.be.rejectedWith(ERROR_MSG);
|
||||
const confirmations = await metadata.confirmations(miningKey);
|
||||
const confirmations = await metadata.confirmations.call(miningKey);
|
||||
confirmations[0].should.be.bignumber.equal(1);
|
||||
})
|
||||
});
|
||||
|
@ -283,7 +283,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
await metadata.confirmPendingChange(miningKey, {from: votingKey2});
|
||||
await metadata.confirmPendingChange(miningKey, {from: votingKey3});
|
||||
const {logs} = await metadata.finalize(miningKey, {from: votingKey});
|
||||
const validators = await metadata.validators(miningKey);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
toHex("Feodosiy"),
|
||||
toHex("Kennedy"),
|
||||
|
@ -296,7 +296,7 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
]);
|
||||
const pendingChanges = await metadata.pendingChanges(miningKey);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
|
@ -316,38 +316,33 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
|
||||
describe('#getMinThreshold', async () => {
|
||||
it('returns default value', async () => {
|
||||
(await metadata.getMinThreshold()).should.be.bignumber.equal(2);
|
||||
(await metadata.getMinThreshold.call()).should.be.bignumber.equal(2);
|
||||
})
|
||||
})
|
||||
describe('#setProxyAddress', async () => {
|
||||
let newProxy = "0xfb9c7fc2a00dffc53948e3bbeb11f3d4b56c31b8";
|
||||
it('can request a new proxy address', async () => {
|
||||
"0x0000000000000000000000000000000000000000".should.be.equal
|
||||
(await metadata.pendingProxyStorage());
|
||||
(await metadata.proxyStorage()).should.be.equal(proxyStorageMock.address);
|
||||
(await metadata.pendingProxyStorage.call());
|
||||
(await metadata.proxyStorage.call()).should.be.equal(proxyStorageMock.address);
|
||||
await metadata.setProxyAddress(newProxy, {from: miningKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
const {logs} = await metadata.setProxyAddress(newProxy, {from: votingKey}).should.be.fulfilled;
|
||||
(await metadata.pendingProxyStorage()).should.be.equal(newProxy);
|
||||
(await metadata.pendingProxyConfirmations(newProxy))[0].should.be.bignumber.deep.equal(1);
|
||||
(await metadata.pendingProxyStorage.call()).should.be.equal(newProxy);
|
||||
(await metadata.pendingProxyConfirmations.call(newProxy))[0].should.be.bignumber.deep.equal(1);
|
||||
logs[0].event.should.be.equal("RequestForNewProxy");
|
||||
logs[0].args.newProxyAddress.should.be.equal(newProxy);
|
||||
await metadata.confirmNewProxyAddress(newProxy, {from :votingKey2}).should.be.fulfilled;
|
||||
(await metadata.pendingProxyConfirmations(newProxy))[0].should.be.bignumber.deep.equal(2);
|
||||
(await metadata.pendingProxyConfirmations.call(newProxy))[0].should.be.bignumber.deep.equal(2);
|
||||
let final = await metadata.confirmNewProxyAddress(newProxy, {from: votingKey3}).should.be.fulfilled;
|
||||
final.logs[0].event.should.be.equal("ChangeProxyStorage");
|
||||
final.logs[0].args.newProxyAddress.should.be.equal(newProxy);
|
||||
"0x0000000000000000000000000000000000000000".should.be.equal
|
||||
(await metadata.pendingProxyStorage());
|
||||
(await metadata.proxyStorage()).should.be.equal(newProxy);
|
||||
(await metadata.pendingProxyStorage.call());
|
||||
(await metadata.proxyStorage.call()).should.be.equal(newProxy);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var toUtf8 = function(hex) {
|
||||
var buf = new Buffer(hex.replace('0x',''),'hex');
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
function toHex(someString) {
|
||||
var hex = '0x' + new Buffer(someString).toString('hex');
|
||||
hex = pad(hex);
|
||||
|
|
|
@ -3,335 +3,335 @@ let ProxyStorageMock = artifacts.require('./mockContracts/ProxyStorageMock');
|
|||
let EternalStorageProxy = artifacts.require('./EternalStorageProxy');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
require('chai')
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-bignumber')(web3.BigNumber))
|
||||
.should();
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-bignumber')(web3.BigNumber))
|
||||
.should();
|
||||
|
||||
contract('PoaNetworkConsensus [all features]', function (accounts) {
|
||||
let poaNetworkConsensus;
|
||||
let proxyStorageMock;
|
||||
let masterOfCeremony = accounts[0];
|
||||
beforeEach(async () => {
|
||||
poaNetworkConsensus = await PoaNetworkConsensus.new(masterOfCeremony, []);
|
||||
|
||||
proxyStorageMock = await ProxyStorageMock.new();
|
||||
const proxyStorageEternalStorage = await EternalStorageProxy.new(0, proxyStorageMock.address);
|
||||
proxyStorageMock = await ProxyStorageMock.at(proxyStorageEternalStorage.address);
|
||||
await proxyStorageMock.init(poaNetworkConsensus.address).should.be.fulfilled;
|
||||
|
||||
await poaNetworkConsensus.setProxyStorage(proxyStorageMock.address);
|
||||
await proxyStorageMock.initializeAddresses(
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0]
|
||||
);
|
||||
let poaNetworkConsensus;
|
||||
let proxyStorageMock;
|
||||
let masterOfCeremony = accounts[0];
|
||||
beforeEach(async () => {
|
||||
poaNetworkConsensus = await PoaNetworkConsensus.new(masterOfCeremony, []);
|
||||
|
||||
proxyStorageMock = await ProxyStorageMock.new();
|
||||
const proxyStorageEternalStorage = await EternalStorageProxy.new(0, proxyStorageMock.address);
|
||||
proxyStorageMock = await ProxyStorageMock.at(proxyStorageEternalStorage.address);
|
||||
await proxyStorageMock.init(poaNetworkConsensus.address).should.be.fulfilled;
|
||||
|
||||
await poaNetworkConsensus.setProxyStorage(proxyStorageMock.address);
|
||||
await proxyStorageMock.initializeAddresses(
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0],
|
||||
accounts[0]
|
||||
);
|
||||
});
|
||||
|
||||
describe('default values', async () => {
|
||||
it('finalized should be false', async () => {
|
||||
let validators = await poaNetworkConsensus.getValidators.call();
|
||||
let finalized = await poaNetworkConsensus.finalized.call();
|
||||
validators.should.be.deep.equal([
|
||||
masterOfCeremony
|
||||
]);
|
||||
finalized.should.be.false;
|
||||
});
|
||||
|
||||
describe('default values', async () => {
|
||||
it('finalized should be false', async () => {
|
||||
let validators = await poaNetworkConsensus.getValidators();
|
||||
let finalized = await poaNetworkConsensus.finalized();
|
||||
validators.should.be.deep.equal([
|
||||
masterOfCeremony
|
||||
]);
|
||||
finalized.should.be.false;
|
||||
});
|
||||
it('checks systemAddress', async () => {
|
||||
let systemAddress = await poaNetworkConsensus.systemAddress.call();
|
||||
systemAddress.should.be.equal('0xfffffffffffffffffffffffffffffffffffffffe');
|
||||
})
|
||||
it('allows you to set current list of validators', async () => {
|
||||
let validatorsList = [accounts[2], accounts[3], accounts[4]];
|
||||
let poa = await PoaNetworkConsensus.new(masterOfCeremony, validatorsList);
|
||||
let validators = await poa.getValidators.call();
|
||||
let finalized = await poa.finalized.call();
|
||||
validators.should.be.deep.equal([
|
||||
masterOfCeremony,
|
||||
...validatorsList
|
||||
]);
|
||||
|
||||
it('checks systemAddress', async () => {
|
||||
let systemAddress = await poaNetworkConsensus.systemAddress();
|
||||
systemAddress.should.be.equal('0xfffffffffffffffffffffffffffffffffffffffe');
|
||||
})
|
||||
it('allows you to set current list of validators', async () => {
|
||||
let validatorsList = [accounts[2], accounts[3], accounts[4]];
|
||||
let poa = await PoaNetworkConsensus.new(masterOfCeremony, validatorsList);
|
||||
let validators = await poa.getValidators();
|
||||
let finalized = await poa.finalized();
|
||||
validators.should.be.deep.equal([
|
||||
masterOfCeremony,
|
||||
...validatorsList
|
||||
]);
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
describe('#finalizeChange', async () => {
|
||||
it('should only be called by systemAddress', async () => {
|
||||
await poaNetworkConsensus.finalizeChange().should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
it('should set finalized to true', async () => {
|
||||
let finalized = await poaNetworkConsensus.finalized.call();
|
||||
finalized.should.be.false;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
finalized = await poaNetworkConsensus.finalized.call();
|
||||
finalized.should.be.true;
|
||||
})
|
||||
it('should set currentValidators to pendingList', async () => {
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
const { logs } = await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength.call();
|
||||
let currentValidators = [];
|
||||
let pendingList = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators.call(i);
|
||||
currentValidators.push(validator);
|
||||
let pending = await poaNetworkConsensus.pendingList.call(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
currentValidators.should.be.deep.equal(pendingList);
|
||||
logs[0].event.should.be.equal('ChangeFinalized');
|
||||
logs[0].args.newSet.should.be.deep.equal(currentValidators);
|
||||
})
|
||||
|
||||
describe('#finalizeChange', async () => {
|
||||
it('should only be called by systemAddress', async () => {
|
||||
await poaNetworkConsensus.finalizeChange().should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
it('should set finalized to true', async () => {
|
||||
let finalized = await poaNetworkConsensus.finalized();
|
||||
finalized.should.be.false;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
finalized = await poaNetworkConsensus.finalized();
|
||||
finalized.should.be.true;
|
||||
})
|
||||
it('should set currentValidators to pendingList', async () => {
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
const { logs } = await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength();
|
||||
let currentValidators = [];
|
||||
let pendingList = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators(i);
|
||||
currentValidators.push(validator);
|
||||
let pending = await poaNetworkConsensus.pendingList(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
currentValidators.should.be.deep.equal(pendingList);
|
||||
logs[0].event.should.be.equal('ChangeFinalized');
|
||||
logs[0].args.newSet.should.be.deep.equal(currentValidators);
|
||||
})
|
||||
it('set currentValidators to pendingList after addValidator call', async () => {
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true, {from: accounts[1]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength.call();
|
||||
let currentValidators = [];
|
||||
let pendingList = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators.call(i);
|
||||
currentValidators.push(validator);
|
||||
let pending = await poaNetworkConsensus.pendingList.call(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
currentValidators.should.be.deep.equal(pendingList);
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength.call()
|
||||
const expected = [masterOfCeremony, accounts[1], accounts[2]];
|
||||
|
||||
it('set currentValidators to pendingList after addValidator call', async () => {
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true, {from: accounts[1]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength();
|
||||
let currentValidators = [];
|
||||
let pendingList = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators(i);
|
||||
currentValidators.push(validator);
|
||||
let pending = await poaNetworkConsensus.pendingList(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
currentValidators.should.be.deep.equal(pendingList);
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength()
|
||||
const expected = [masterOfCeremony, accounts[1], accounts[2]];
|
||||
currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength.call();
|
||||
currentValidators = [];
|
||||
pendingList = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators.call(i);
|
||||
currentValidators.push(validator);
|
||||
let pending = await poaNetworkConsensus.pendingList.call(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
expected.should.be.deep.equal(pendingList);
|
||||
expected.should.be.deep.equal(currentValidators);
|
||||
})
|
||||
})
|
||||
|
||||
currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength();
|
||||
currentValidators = [];
|
||||
pendingList = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators(i);
|
||||
currentValidators.push(validator);
|
||||
let pending = await poaNetworkConsensus.pendingList(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
expected.should.be.deep.equal(pendingList);
|
||||
expected.should.be.deep.equal(currentValidators);
|
||||
})
|
||||
describe('#addValidator', async () => {
|
||||
it('should be called only from keys manager', async () => {
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true, {from: accounts[2]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[5]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true, {from: accounts[5]}).should.be.fulfilled;
|
||||
})
|
||||
|
||||
describe('#addValidator', async () => {
|
||||
it('should be called only from keys manager', async () => {
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true, {from: accounts[2]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[5]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true, {from: accounts[5]}).should.be.fulfilled;
|
||||
})
|
||||
|
||||
it('should not allow to add already existing validator', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
||||
it('should not allow 0x0 addresses', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator('0x0', true).should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.addValidator('0x0000000000000000000000000000000000000000', true).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
||||
it('should set validatorsState for new validator', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
let state = await poaNetworkConsensus.validatorsState(accounts[1]);
|
||||
let pendingList = await poaNetworkConsensus.getPendingList();
|
||||
state[0].should.be.true;
|
||||
state[1].should.be.bignumber.equal(pendingList.length - 1)
|
||||
})
|
||||
|
||||
it('should set finalized to false', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
let finalized = await poaNetworkConsensus.finalized();
|
||||
finalized.should.be.false;
|
||||
})
|
||||
|
||||
it('should emit InitiateChange with blockhash and pendingList as params', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
const {logs} = await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength();
|
||||
let currentValidators = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators(i);
|
||||
currentValidators.push(validator);
|
||||
}
|
||||
currentValidators.push(accounts[1]);
|
||||
logs[0].args['newSet'].should.deep.equal(currentValidators);
|
||||
logs[0].event.should.be.equal('InitiateChange');
|
||||
})
|
||||
it('should not allow to add already existing validator', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
||||
describe('#swapValidatorKey', async () => {
|
||||
it('should swap validator key', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
it('should not allow 0x0 addresses', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator('0x0', true).should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.addValidator('0x0000000000000000000000000000000000000000', true).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
it('should set validatorsState for new validator', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
let state = await poaNetworkConsensus.validatorsState.call(accounts[1]);
|
||||
let pendingList = await poaNetworkConsensus.getPendingList.call();
|
||||
state[0].should.be.true;
|
||||
state[1].should.be.bignumber.equal(pendingList.length - 1)
|
||||
})
|
||||
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(2);
|
||||
(await poaNetworkConsensus.isValidator(accounts[1])).should.be.equal(true);
|
||||
(await poaNetworkConsensus.isValidator(accounts[2])).should.be.equal(false);
|
||||
|
||||
await poaNetworkConsensus.swapValidatorKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
it('should set finalized to false', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
let finalized = await poaNetworkConsensus.finalized.call();
|
||||
finalized.should.be.false;
|
||||
})
|
||||
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(2);
|
||||
(await poaNetworkConsensus.isValidator(accounts[1])).should.be.equal(false);
|
||||
(await poaNetworkConsensus.isValidator(accounts[2])).should.be.equal(true);
|
||||
});
|
||||
it('should swap MoC', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
it('should emit InitiateChange with blockhash and pendingList as params', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
const {logs} = await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength.call();
|
||||
let currentValidators = [];
|
||||
for (let i = 0; i < currentValidatorsLength.toNumber(10); i++) {
|
||||
let validator = await poaNetworkConsensus.currentValidators.call(i);
|
||||
currentValidators.push(validator);
|
||||
}
|
||||
currentValidators.push(accounts[1]);
|
||||
logs[0].args['newSet'].should.deep.equal(currentValidators);
|
||||
logs[0].event.should.be.equal('InitiateChange');
|
||||
})
|
||||
})
|
||||
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(1);
|
||||
(await poaNetworkConsensus.isValidator(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensus.isValidator(accounts[1])).should.be.equal(false);
|
||||
(await poaNetworkConsensus.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
|
||||
await poaNetworkConsensus.swapValidatorKey(accounts[1], masterOfCeremony).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
describe('#swapValidatorKey', async () => {
|
||||
it('should swap validator key', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(1);
|
||||
(await poaNetworkConsensus.isValidator(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensus.isValidator(accounts[1])).should.be.equal(true);
|
||||
(await poaNetworkConsensus.masterOfCeremony()).should.be.equal(accounts[1]);
|
||||
});
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(2);
|
||||
(await poaNetworkConsensus.isValidator.call(accounts[1])).should.be.equal(true);
|
||||
(await poaNetworkConsensus.isValidator.call(accounts[2])).should.be.equal(false);
|
||||
|
||||
await poaNetworkConsensus.swapValidatorKey(accounts[2], accounts[1]).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(2);
|
||||
(await poaNetworkConsensus.isValidator.call(accounts[1])).should.be.equal(false);
|
||||
(await poaNetworkConsensus.isValidator.call(accounts[2])).should.be.equal(true);
|
||||
});
|
||||
it('should swap MoC', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
|
||||
describe('#removeValidator', async () => {
|
||||
it('should remove validator', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1], true).should.be.fulfilled;
|
||||
})
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(1);
|
||||
(await poaNetworkConsensus.isValidator.call(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensus.isValidator.call(accounts[1])).should.be.equal(false);
|
||||
(await poaNetworkConsensus.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
|
||||
await poaNetworkConsensus.swapValidatorKey(accounts[1], masterOfCeremony).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
|
||||
it('should remove MoC', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
(await poaNetworkConsensus.isValidator(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensus.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
await poaNetworkConsensus.removeValidator(masterOfCeremony, true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength()).should.be.bignumber.equal(0);
|
||||
(await poaNetworkConsensus.isValidator(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensus.masterOfCeremony()).should.be.equal(masterOfCeremony);
|
||||
})
|
||||
|
||||
it('should be called only from keys manager', async () => {
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.rejectedWith(ERROR_MSG);
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
})
|
||||
|
||||
it('should only be allowed to remove from existing set of validators', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
||||
it('should decrease length of pendingList', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength();
|
||||
let pendingList = [];
|
||||
for(let i = 0; i < currentValidatorsLength; i++){
|
||||
let pending = await poaNetworkConsensus.pendingList(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
const indexOfRemovedElement = pendingList.indexOf(accounts[1]);
|
||||
pendingList.splice(indexOfRemovedElement, 1);
|
||||
const { logs } = await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
let pendingListFromContract = logs[0].args['newSet'];
|
||||
pendingListFromContract.length.should.be.equal(currentValidatorsLength.toNumber(10) - 1);
|
||||
pendingList.should.be.deep.equal(pendingListFromContract);
|
||||
logs[0].event.should.be.equal('InitiateChange');
|
||||
const expected = [masterOfCeremony, accounts[2]];
|
||||
expected.should.be.deep.equal(pendingList);
|
||||
})
|
||||
|
||||
it('should change validatorsState', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
const state = await poaNetworkConsensus.validatorsState(accounts[1]);
|
||||
state[0].should.be.false;
|
||||
state[1].should.be.bignumber.equal(0);
|
||||
})
|
||||
|
||||
it('should set finalized to false', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
const finalized = await poaNetworkConsensus.finalized();
|
||||
finalized.should.be.false;
|
||||
})
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(1);
|
||||
(await poaNetworkConsensus.isValidator.call(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensus.isValidator.call(accounts[1])).should.be.equal(true);
|
||||
(await poaNetworkConsensus.masterOfCeremony.call()).should.be.equal(accounts[1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setProxyStorage', async () => {
|
||||
let new_masterOfCeremony = accounts[1];
|
||||
const nonValidator = accounts[3];
|
||||
let validator = accounts[0];
|
||||
it('can be called by any validator', async () => {
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage(nonValidator, {from: accounts[6]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.setProxyStorage(accounts[5], {from: validator}).should.be.fulfilled;
|
||||
})
|
||||
it('can only be called once', async () => {
|
||||
// we already call it in the beforeEach block, hence why I expect it to be rejected
|
||||
await poaNetworkConsensus.setProxyStorage(nonValidator, {from: nonValidator}).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
it('cannot be set to 0x0 address', async () => {
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage('0x0000000000000000000000000000000000000000', {from: validator}).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
it('sets proxyStorage', async () => {
|
||||
let newProxyStorage = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage(newProxyStorage, {from: validator}).should.be.fulfilled;
|
||||
(await poaNetworkConsensus.proxyStorage()).should.be.equal(newProxyStorage);
|
||||
})
|
||||
it('sets isMasterOfCeremonyInitialized', async () => {
|
||||
let newProxyStorage = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage(newProxyStorage, {from: validator}).should.be.fulfilled;
|
||||
(await poaNetworkConsensus.isMasterOfCeremonyInitialized()).should.be.equal(true);
|
||||
})
|
||||
describe('#removeValidator', async () => {
|
||||
it('should remove validator', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1], true).should.be.fulfilled;
|
||||
})
|
||||
|
||||
it('emits MoCInitializedProxyStorage', async () => {
|
||||
let newProxyStorage = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
const {logs} = await poaNetworkConsensus.setProxyStorage(newProxyStorage, {from: validator}).should.be.fulfilled;
|
||||
logs[0].event.should.be.equal('MoCInitializedProxyStorage');
|
||||
logs[0].args.proxyStorage.should.be.equal(newProxyStorage);
|
||||
})
|
||||
it('#getKeysManager', async () => {
|
||||
let newKeysManager = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await proxyStorageMock.setKeysManagerMock(newKeysManager);
|
||||
(await poaNetworkConsensus.getKeysManager()).should.be.equal(newKeysManager);
|
||||
})
|
||||
it('should remove MoC', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
(await poaNetworkConsensus.isValidator.call(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensus.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
await poaNetworkConsensus.removeValidator(masterOfCeremony, true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
(await poaNetworkConsensus.getCurrentValidatorsLength.call()).should.be.bignumber.equal(0);
|
||||
(await poaNetworkConsensus.isValidator.call(masterOfCeremony)).should.be.equal(false);
|
||||
(await poaNetworkConsensus.masterOfCeremony.call()).should.be.equal(masterOfCeremony);
|
||||
})
|
||||
describe('#isValidator', async () => {
|
||||
it('returns address of miner', async () => {
|
||||
(await poaNetworkConsensus.isValidator(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensus.isValidator(accounts[2])).should.be.equal(false);
|
||||
})
|
||||
|
||||
it('should be called only from keys manager', async () => {
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.rejectedWith(ERROR_MSG);
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
})
|
||||
|
||||
it('should only be allowed to remove from existing set of validators', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
|
||||
it('should decrease length of pendingList', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
await poaNetworkConsensus.addValidator(accounts[2], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.finalizeChange().should.be.fulfilled;
|
||||
let currentValidatorsLength = await poaNetworkConsensus.currentValidatorsLength.call();
|
||||
let pendingList = [];
|
||||
for(let i = 0; i < currentValidatorsLength; i++){
|
||||
let pending = await poaNetworkConsensus.pendingList.call(i);
|
||||
pendingList.push(pending);
|
||||
}
|
||||
const indexOfRemovedElement = pendingList.indexOf(accounts[1]);
|
||||
pendingList.splice(indexOfRemovedElement, 1);
|
||||
const { logs } = await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
let pendingListFromContract = logs[0].args['newSet'];
|
||||
pendingListFromContract.length.should.be.equal(currentValidatorsLength.toNumber(10) - 1);
|
||||
pendingList.should.be.deep.equal(pendingListFromContract);
|
||||
logs[0].event.should.be.equal('InitiateChange');
|
||||
const expected = [masterOfCeremony, accounts[2]];
|
||||
expected.should.be.deep.equal(pendingList);
|
||||
})
|
||||
|
||||
it('should change validatorsState', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
const state = await poaNetworkConsensus.validatorsState.call(accounts[1]);
|
||||
state[0].should.be.false;
|
||||
state[1].should.be.bignumber.equal(0);
|
||||
})
|
||||
|
||||
it('should set finalized to false', async () => {
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
await poaNetworkConsensus.addValidator(accounts[1], true).should.be.fulfilled;
|
||||
await poaNetworkConsensus.removeValidator(accounts[1],true).should.be.fulfilled;
|
||||
const finalized = await poaNetworkConsensus.finalized.call();
|
||||
finalized.should.be.false;
|
||||
})
|
||||
});
|
||||
|
||||
describe('#setProxyStorage', async () => {
|
||||
let new_masterOfCeremony = accounts[1];
|
||||
const nonValidator = accounts[3];
|
||||
let validator = accounts[0];
|
||||
it('can be called by any validator', async () => {
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage(nonValidator, {from: accounts[6]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await poaNetworkConsensus.setProxyStorage(accounts[5], {from: validator}).should.be.fulfilled;
|
||||
})
|
||||
it('can only be called once', async () => {
|
||||
// we already call it in the beforeEach block, hence why I expect it to be rejected
|
||||
await poaNetworkConsensus.setProxyStorage(nonValidator, {from: nonValidator}).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
it('cannot be set to 0x0 address', async () => {
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage('0x0000000000000000000000000000000000000000', {from: validator}).should.be.rejectedWith(ERROR_MSG);
|
||||
})
|
||||
it('sets proxyStorage', async () => {
|
||||
let newProxyStorage = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage(newProxyStorage, {from: validator}).should.be.fulfilled;
|
||||
(await poaNetworkConsensus.proxyStorage.call()).should.be.equal(newProxyStorage);
|
||||
})
|
||||
it('sets isMasterOfCeremonyInitialized', async () => {
|
||||
let newProxyStorage = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await poaNetworkConsensus.setProxyStorage(newProxyStorage, {from: validator}).should.be.fulfilled;
|
||||
(await poaNetworkConsensus.isMasterOfCeremonyInitialized.call()).should.be.equal(true);
|
||||
})
|
||||
|
||||
it('emits MoCInitializedProxyStorage', async () => {
|
||||
let newProxyStorage = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
const {logs} = await poaNetworkConsensus.setProxyStorage(newProxyStorage, {from: validator}).should.be.fulfilled;
|
||||
logs[0].event.should.be.equal('MoCInitializedProxyStorage');
|
||||
logs[0].args.proxyStorage.should.be.equal(newProxyStorage);
|
||||
})
|
||||
it('#getKeysManager', async () => {
|
||||
let newKeysManager = accounts[3];
|
||||
await poaNetworkConsensus.setIsMasterOfCeremonyInitializedMock(false);
|
||||
await proxyStorageMock.setKeysManagerMock(newKeysManager);
|
||||
(await poaNetworkConsensus.getKeysManager.call()).should.be.equal(newKeysManager);
|
||||
})
|
||||
})
|
||||
describe('#isValidator', async () => {
|
||||
it('returns address of miner', async () => {
|
||||
(await poaNetworkConsensus.isValidator.call(masterOfCeremony)).should.be.equal(true);
|
||||
(await poaNetworkConsensus.isValidator.call(accounts[2])).should.be.equal(false);
|
||||
})
|
||||
})
|
||||
});
|
|
@ -10,9 +10,9 @@ let VotingToChangeProxy = artifacts.require('./VotingToChangeProxyAddress');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
require('chai')
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-bignumber')(web3.BigNumber))
|
||||
.should();
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-bignumber')(web3.BigNumber))
|
||||
.should();
|
||||
|
||||
let masterOfCeremony;
|
||||
let keysManager, keysManagerEternalStorage;
|
||||
|
@ -31,7 +31,7 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
proxyStorageEternalStorage = await EternalStorageProxy.new(0, proxyStorage.address);
|
||||
proxyStorage = await ProxyStorageMock.at(proxyStorageEternalStorage.address);
|
||||
await proxyStorage.init(poaNetworkConsensus.address).should.be.fulfilled;
|
||||
(await proxyStorageEternalStorage.getProxyStorage()).should.be.equal(
|
||||
(await proxyStorageEternalStorage.getProxyStorage.call()).should.be.equal(
|
||||
proxyStorageEternalStorage.address
|
||||
);
|
||||
|
||||
|
@ -57,10 +57,10 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
describe('#constructor', async () => {
|
||||
it('sets MoC and Poa', async () => {
|
||||
poaNetworkConsensus.address.should.be.equal(
|
||||
await proxyStorage.getPoaConsensus()
|
||||
await proxyStorage.getPoaConsensus.call()
|
||||
);
|
||||
true.should.be.equal(
|
||||
await proxyStorage.isValidator(masterOfCeremony)
|
||||
await proxyStorage.isValidator.call(masterOfCeremony)
|
||||
);
|
||||
})
|
||||
})
|
||||
|
@ -84,22 +84,22 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
validatorMetadataEternalStorage.address,
|
||||
).should.be.fulfilled;
|
||||
keysManagerEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getKeysManager()
|
||||
await proxyStorage.getKeysManager.call()
|
||||
);
|
||||
votingToChangeKeysEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getVotingToChangeKeys()
|
||||
await proxyStorage.getVotingToChangeKeys.call()
|
||||
);
|
||||
votingToChangeMinThresholdEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getVotingToChangeMinThreshold()
|
||||
await proxyStorage.getVotingToChangeMinThreshold.call()
|
||||
);
|
||||
votingToChangeProxyEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getVotingToChangeProxy()
|
||||
await proxyStorage.getVotingToChangeProxy.call()
|
||||
);
|
||||
ballotsEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getBallotsStorage()
|
||||
await proxyStorage.getBallotsStorage.call()
|
||||
);
|
||||
validatorMetadataEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getValidatorMetadata()
|
||||
await proxyStorage.getValidatorMetadata.call()
|
||||
);
|
||||
logs[0].event.should.be.equal('ProxyInitialized');
|
||||
logs[0].args.keysManagerEternalStorage.should.be.equal(keysManagerEternalStorage.address);
|
||||
|
@ -110,7 +110,7 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
logs[0].args.validatorMetadataEternalStorage.should.be.equal(validatorMetadataEternalStorage.address);
|
||||
})
|
||||
it('prevents Moc to call it more than once', async () => {
|
||||
false.should.be.equal(await proxyStorage.mocInitialized());
|
||||
false.should.be.equal(await proxyStorage.mocInitialized.call());
|
||||
const {logs} = await proxyStorage.initializeAddresses(
|
||||
keysManagerEternalStorage.address,
|
||||
votingToChangeKeysEternalStorage.address,
|
||||
|
@ -119,7 +119,7 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
ballotsEternalStorage.address,
|
||||
validatorMetadataEternalStorage.address
|
||||
).should.be.fulfilled;
|
||||
true.should.be.equal(await proxyStorage.mocInitialized());
|
||||
true.should.be.equal(await proxyStorage.mocInitialized.call());
|
||||
await proxyStorage.initializeAddresses(
|
||||
keysManagerEternalStorage.address,
|
||||
votingToChangeKeysEternalStorage.address,
|
||||
|
@ -160,11 +160,11 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(1, keysManagerNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getKeysManager();
|
||||
let eternalProxyAddress = await proxyStorage.getKeysManager.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
keysManagerNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
);
|
||||
})
|
||||
it('sets votingToChangeKeys', async () => {
|
||||
|
@ -173,11 +173,11 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(2, votingToChangeKeysNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeKeys();
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeKeys.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
votingToChangeKeysNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
it('sets votingToChangeMinThreshold', async () => {
|
||||
|
@ -186,11 +186,11 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(3, votingToChangeMinThresholdNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeMinThreshold();
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeMinThreshold.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
votingToChangeMinThresholdNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
//it('sets votingToChangeProxy', async () => {
|
||||
|
@ -203,11 +203,11 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(5, ballotsStorageNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getBallotsStorage();
|
||||
let eternalProxyAddress = await proxyStorage.getBallotsStorage.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
ballotsStorageNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
it('sets poaConsensus', async () => {
|
||||
|
@ -215,7 +215,7 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(6, accounts[5], {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
accounts[5].should.be.equal(
|
||||
await proxyStorage.getPoaConsensus()
|
||||
await proxyStorage.getPoaConsensus.call()
|
||||
)
|
||||
})
|
||||
it('sets validatorMetadata', async () => {
|
||||
|
@ -225,15 +225,15 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(7, validatorMetadataNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getValidatorMetadata();
|
||||
let eternalProxyAddress = await proxyStorage.getValidatorMetadata.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
validatorMetadataNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
it('changes proxyStorage (itself) implementation', async () => {
|
||||
const oldVersion = await proxyStorage.version();
|
||||
const oldVersion = await proxyStorage.version.call();
|
||||
const newVersion = oldVersion.add(1);
|
||||
let proxyStorageNew = await ProxyStorageMock.new();
|
||||
await proxyStorage.setVotingToChangeProxyMock(accounts[4]);
|
||||
|
@ -241,30 +241,30 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
proxyStorageNew.address.should.be.equal(
|
||||
await proxyStorageEternalStorage.implementation()
|
||||
await proxyStorageEternalStorage.implementation.call()
|
||||
);
|
||||
proxyStorageNew.address.should.be.equal(
|
||||
await proxyStorage.implementation()
|
||||
await proxyStorage.implementation.call()
|
||||
);
|
||||
newVersion.should.be.bignumber.equal(
|
||||
await proxyStorageEternalStorage.version()
|
||||
await proxyStorageEternalStorage.version.call()
|
||||
);
|
||||
proxyStorageNew = await ProxyStorageMock.at(proxyStorageEternalStorage.address);
|
||||
newVersion.should.be.bignumber.equal(
|
||||
await proxyStorageNew.version()
|
||||
await proxyStorageNew.version.call()
|
||||
);
|
||||
})
|
||||
})
|
||||
describe('#upgradeTo', async () => {
|
||||
it('may be called only by ProxyStorage (itself)', async () => {
|
||||
const proxyStorageNew = await ProxyStorageNew.new();
|
||||
(await proxyStorageEternalStorage.getProxyStorage()).should.be.equal(
|
||||
(await proxyStorageEternalStorage.getProxyStorage.call()).should.be.equal(
|
||||
proxyStorageEternalStorage.address
|
||||
);
|
||||
await proxyStorageEternalStorage.upgradeTo(proxyStorageNew.address, {from: accounts[0]}).should.be.rejectedWith(ERROR_MSG);
|
||||
await proxyStorageEternalStorage.setProxyStorage(accounts[0]);
|
||||
await proxyStorageEternalStorage.upgradeTo(proxyStorageNew.address, {from: accounts[0]}).should.be.fulfilled;
|
||||
(await proxyStorageEternalStorage.implementation()).should.be.equal(
|
||||
(await proxyStorageEternalStorage.implementation.call()).should.be.equal(
|
||||
proxyStorageNew.address
|
||||
);
|
||||
});
|
||||
|
@ -273,21 +273,21 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorageEternalStorage.setProxyStorage(accounts[0]);
|
||||
await proxyStorageEternalStorage.upgradeTo(proxyStorageNew.address, {from: accounts[0]}).should.be.fulfilled;
|
||||
await proxyStorageEternalStorage.setProxyStorage(proxyStorageEternalStorage.address);
|
||||
(await proxyStorageEternalStorage.implementation()).should.be.equal(
|
||||
(await proxyStorageEternalStorage.implementation.call()).should.be.equal(
|
||||
proxyStorageNew.address
|
||||
);
|
||||
});
|
||||
it('should increment implementation version', async () => {
|
||||
let proxyStorageNew = await ProxyStorageNew.new();
|
||||
const oldVersion = await proxyStorage.version();
|
||||
const oldVersion = await proxyStorage.version.call();
|
||||
const newVersion = oldVersion.add(1);
|
||||
(await proxyStorageEternalStorage.version()).should.be.bignumber.equal(oldVersion);
|
||||
(await proxyStorageEternalStorage.version.call()).should.be.bignumber.equal(oldVersion);
|
||||
await proxyStorageEternalStorage.setProxyStorage(accounts[0]);
|
||||
await proxyStorageEternalStorage.upgradeTo(proxyStorageNew.address, {from: accounts[0]}).should.be.fulfilled;
|
||||
await proxyStorageEternalStorage.setProxyStorage(proxyStorageEternalStorage.address);
|
||||
proxyStorageNew = await ProxyStorageNew.at(proxyStorageEternalStorage.address);
|
||||
(await proxyStorageNew.version()).should.be.bignumber.equal(newVersion);
|
||||
(await proxyStorageEternalStorage.version()).should.be.bignumber.equal(newVersion);
|
||||
(await proxyStorageNew.version.call()).should.be.bignumber.equal(newVersion);
|
||||
(await proxyStorageEternalStorage.version.call()).should.be.bignumber.equal(newVersion);
|
||||
});
|
||||
it('new implementation should work', async () => {
|
||||
let proxyStorageNew = await ProxyStorageNew.new();
|
||||
|
@ -295,9 +295,9 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorageEternalStorage.upgradeTo(proxyStorageNew.address, {from: accounts[0]}).should.be.fulfilled;
|
||||
await proxyStorageEternalStorage.setProxyStorage(proxyStorageEternalStorage.address);
|
||||
proxyStorageNew = await ProxyStorageNew.at(proxyStorageEternalStorage.address);
|
||||
(await proxyStorageNew.initialized()).should.be.equal(false);
|
||||
(await proxyStorageNew.initialized.call()).should.be.equal(false);
|
||||
await proxyStorageNew.initialize();
|
||||
(await proxyStorageNew.initialized()).should.be.equal(true);
|
||||
(await proxyStorageNew.initialized.call()).should.be.equal(true);
|
||||
});
|
||||
it('new implementation should use the same storage', async () => {
|
||||
let proxyStorageNew = await ProxyStorageNew.new();
|
||||
|
@ -305,7 +305,7 @@ contract('ProxyStorage [all features]', function (accounts) {
|
|||
await proxyStorageEternalStorage.upgradeTo(proxyStorageNew.address, {from: accounts[0]}).should.be.fulfilled;
|
||||
await proxyStorageEternalStorage.setProxyStorage(proxyStorageEternalStorage.address);
|
||||
proxyStorageNew = await ProxyStorageNew.at(proxyStorageEternalStorage.address);
|
||||
(await proxyStorageNew.getPoaConsensus()).should.be.equal(poaNetworkConsensus.address);
|
||||
(await proxyStorageNew.getPoaConsensus.call()).should.be.equal(poaNetworkConsensus.address);
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
|
@ -10,9 +10,9 @@ let VotingToChangeProxy = artifacts.require('./VotingToChangeProxyAddress');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
require('chai')
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-bignumber')(web3.BigNumber))
|
||||
.should();
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-bignumber')(web3.BigNumber))
|
||||
.should();
|
||||
|
||||
let masterOfCeremony;
|
||||
let keysManager, keysManagerEternalStorage;
|
||||
|
@ -31,7 +31,7 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
proxyStorageEternalStorage = await EternalStorageProxy.new(0, proxyStorage.address);
|
||||
proxyStorage = await ProxyStorageMock.at(proxyStorageEternalStorage.address);
|
||||
await proxyStorage.init(poaNetworkConsensus.address).should.be.fulfilled;
|
||||
(await proxyStorageEternalStorage.getProxyStorage()).should.be.equal(
|
||||
(await proxyStorageEternalStorage.getProxyStorage.call()).should.be.equal(
|
||||
proxyStorageEternalStorage.address
|
||||
);
|
||||
|
||||
|
@ -63,10 +63,10 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
describe('#constructor', async () => {
|
||||
it('sets MoC and Poa', async () => {
|
||||
poaNetworkConsensus.address.should.be.equal(
|
||||
await proxyStorage.getPoaConsensus()
|
||||
await proxyStorage.getPoaConsensus.call()
|
||||
);
|
||||
true.should.be.equal(
|
||||
await proxyStorage.isValidator(masterOfCeremony)
|
||||
await proxyStorage.isValidator.call(masterOfCeremony)
|
||||
);
|
||||
})
|
||||
})
|
||||
|
@ -90,22 +90,22 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
validatorMetadataEternalStorage.address,
|
||||
).should.be.fulfilled;
|
||||
keysManagerEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getKeysManager()
|
||||
await proxyStorage.getKeysManager.call()
|
||||
);
|
||||
votingToChangeKeysEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getVotingToChangeKeys()
|
||||
await proxyStorage.getVotingToChangeKeys.call()
|
||||
);
|
||||
votingToChangeMinThresholdEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getVotingToChangeMinThreshold()
|
||||
await proxyStorage.getVotingToChangeMinThreshold.call()
|
||||
);
|
||||
votingToChangeProxyEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getVotingToChangeProxy()
|
||||
await proxyStorage.getVotingToChangeProxy.call()
|
||||
);
|
||||
ballotsEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getBallotsStorage()
|
||||
await proxyStorage.getBallotsStorage.call()
|
||||
);
|
||||
validatorMetadataEternalStorage.address.should.be.equal(
|
||||
await proxyStorage.getValidatorMetadata()
|
||||
await proxyStorage.getValidatorMetadata.call()
|
||||
);
|
||||
logs[0].event.should.be.equal('ProxyInitialized');
|
||||
logs[0].args.keysManagerEternalStorage.should.be.equal(keysManagerEternalStorage.address);
|
||||
|
@ -116,7 +116,7 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
logs[0].args.validatorMetadataEternalStorage.should.be.equal(validatorMetadataEternalStorage.address);
|
||||
})
|
||||
it('prevents Moc to call it more than once', async () => {
|
||||
false.should.be.equal(await proxyStorage.mocInitialized());
|
||||
false.should.be.equal(await proxyStorage.mocInitialized.call());
|
||||
const {logs} = await proxyStorage.initializeAddresses(
|
||||
keysManagerEternalStorage.address,
|
||||
votingToChangeKeysEternalStorage.address,
|
||||
|
@ -125,7 +125,7 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
ballotsEternalStorage.address,
|
||||
validatorMetadataEternalStorage.address
|
||||
).should.be.fulfilled;
|
||||
true.should.be.equal(await proxyStorage.mocInitialized());
|
||||
true.should.be.equal(await proxyStorage.mocInitialized.call());
|
||||
await proxyStorage.initializeAddresses(
|
||||
keysManagerEternalStorage.address,
|
||||
votingToChangeKeysEternalStorage.address,
|
||||
|
@ -166,11 +166,11 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(1, keysManagerNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getKeysManager();
|
||||
let eternalProxyAddress = await proxyStorage.getKeysManager.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
keysManagerNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
);
|
||||
})
|
||||
it('sets votingToChangeKeys', async () => {
|
||||
|
@ -179,11 +179,11 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(2, votingToChangeKeysNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeKeys();
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeKeys.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
votingToChangeKeysNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
it('sets votingToChangeMinThreshold', async () => {
|
||||
|
@ -192,11 +192,11 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(3, votingToChangeMinThresholdNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeMinThreshold();
|
||||
let eternalProxyAddress = await proxyStorage.getVotingToChangeMinThreshold.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
votingToChangeMinThresholdNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
//it('sets votingToChangeProxy', async () => {
|
||||
|
@ -209,11 +209,11 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(5, ballotsStorageNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getBallotsStorage();
|
||||
let eternalProxyAddress = await proxyStorage.getBallotsStorage.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
ballotsStorageNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
it('sets poaConsensus', async () => {
|
||||
|
@ -221,7 +221,7 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(6, accounts[5], {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
accounts[5].should.be.equal(
|
||||
await proxyStorage.getPoaConsensus()
|
||||
await proxyStorage.getPoaConsensus.call()
|
||||
)
|
||||
})
|
||||
it('sets validatorMetadata', async () => {
|
||||
|
@ -231,15 +231,15 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setContractAddress(7, validatorMetadataNew.address, {from: accounts[4]}).should.be.fulfilled;
|
||||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
let eternalProxyAddress = await proxyStorage.getValidatorMetadata();
|
||||
let eternalProxyAddress = await proxyStorage.getValidatorMetadata.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
|
||||
validatorMetadataNew.address.should.be.equal(
|
||||
await eternalProxy.implementation()
|
||||
await eternalProxy.implementation.call()
|
||||
)
|
||||
})
|
||||
it('changes proxyStorage (itself) implementation', async () => {
|
||||
const oldVersion = await proxyStorage.version();
|
||||
const oldVersion = await proxyStorage.version.call();
|
||||
const newVersion = oldVersion.add(1);
|
||||
let proxyStorageNew = await ProxyStorageMock.new();
|
||||
await proxyStorage.setVotingToChangeProxyMock(accounts[4]);
|
||||
|
@ -247,17 +247,17 @@ contract('ProxyStorage upgraded [all features]', function (accounts) {
|
|||
await proxyStorage.setVotingToChangeProxyMock(votingToChangeProxyEternalStorage.address);
|
||||
|
||||
proxyStorageNew.address.should.be.equal(
|
||||
await proxyStorageEternalStorage.implementation()
|
||||
await proxyStorageEternalStorage.implementation.call()
|
||||
);
|
||||
proxyStorageNew.address.should.be.equal(
|
||||
await proxyStorage.implementation()
|
||||
await proxyStorage.implementation.call()
|
||||
);
|
||||
newVersion.should.be.bignumber.equal(
|
||||
await proxyStorageEternalStorage.version()
|
||||
await proxyStorageEternalStorage.version.call()
|
||||
);
|
||||
proxyStorageNew = await ProxyStorageMock.at(proxyStorageEternalStorage.address);
|
||||
newVersion.should.be.bignumber.equal(
|
||||
await proxyStorageNew.version()
|
||||
await proxyStorageNew.version.call()
|
||||
);
|
||||
})
|
||||
})
|
||||
|
|
|
@ -7,7 +7,7 @@ let BallotsStorage = artifacts.require('./BallotsStorage');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
const moment = require('moment');
|
||||
const {addValidators} = require('./helpers')
|
||||
const {addValidators} = require('./utils/helpers')
|
||||
|
||||
const choice = {
|
||||
accept: 1,
|
||||
|
@ -70,7 +70,7 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(votingKey, accounts[1]).should.be.fulfilled;
|
||||
const VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
const VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
const id = await voting.nextBallotId();
|
||||
const id = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, // _startTime
|
||||
VOTING_END_DATE, // _endTime
|
||||
|
@ -91,9 +91,9 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
"memo", // _memo
|
||||
{from: votingKey}
|
||||
).should.be.fulfilled;
|
||||
const startTime = await voting.getStartTime(id.toNumber());
|
||||
const endTime = await voting.getEndTime(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
const startTime = await voting.getStartTime.call(id.toNumber());
|
||||
const endTime = await voting.getEndTime.call(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE);
|
||||
|
@ -132,9 +132,9 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
const VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[2], 1, "memo", {from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[2], 1, "memo", {from: votingKey});
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await addValidators({proxyStorageMock, keysManager, poaNetworkConsensusMock}); //add 100 validators, so total will be 101 validator
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[2], 1, "memo", {from: votingKey}).should.be.rejectedWith(ERROR_MSG)
|
||||
})
|
||||
})
|
||||
|
@ -148,16 +148,16 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
await proxyStorageMock.setVotingContractMock(masterOfCeremony);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(votingKey, accounts[1]).should.be.fulfilled;
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[1], 1, "memo", {from: votingKey});
|
||||
})
|
||||
|
||||
it('should let a validator to vote', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.accept, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(1);
|
||||
|
@ -167,9 +167,9 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
it('reject vote should be accepted', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(2);
|
||||
|
@ -187,20 +187,20 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(accounts[4], accounts[2]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.reject, {from: accounts[4]}).should.be.fulfilled;
|
||||
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-2);
|
||||
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(2);
|
||||
|
||||
await keysManager.addMiningKey(accounts[3]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[5], accounts[3]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.accept, {from: accounts[5]}).should.be.fulfilled;
|
||||
|
||||
progress = await voting.getProgress(id);
|
||||
progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
|
||||
totalVoters = await voting.getTotalVoters(id);
|
||||
totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(3);
|
||||
})
|
||||
it('should not let vote nonVoting key', async () => {
|
||||
|
@ -255,8 +255,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
it('happy path - no action since it did not meet minimum number of totalVoters', async () => {
|
||||
// Ballot to Add Payout Key for miner account[1]
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, payoutKeyToAdd, 3, accounts[1], 1, "memo", {from: votingKey});
|
||||
let activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 1);
|
||||
let activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 1);
|
||||
// console.log(votingId);
|
||||
await voting.finalize(votingId, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
|
@ -266,33 +266,33 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey(votingId)).should.be.equal(payoutKeyToAdd);
|
||||
(await voting.getAffectedKeyType(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getMiningKey(votingId)).should.be.equal(accounts[1]);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getBallotType(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey.call(votingId)).should.be.equal(payoutKeyToAdd);
|
||||
(await voting.getAffectedKeyType.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getMiningKey.call(votingId)).should.be.equal(accounts[1]);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getBallotType.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
|
||||
const keysState = await keysManager.validatorKeys(accounts[1]);
|
||||
const keysState = await keysManager.validatorKeys.call(accounts[1]);
|
||||
keysState.should.be.deep.equal(
|
||||
[ votingKey,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -311,7 +311,7 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_ballotType: 1,
|
||||
})
|
||||
|
||||
const keysState = await keysManager.validatorKeys(accounts[1]);
|
||||
const keysState = await keysManager.validatorKeys.call(accounts[1]);
|
||||
keysState.should.be.deep.equal(
|
||||
[ votingKey,
|
||||
payoutKeyToAdd,
|
||||
|
@ -338,7 +338,7 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_miningKey: miningKey,
|
||||
_ballotType: 1,
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ votingKeyToAdd,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -346,7 +346,6 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
true,
|
||||
false ]
|
||||
)
|
||||
|
||||
})
|
||||
it('cannot create ballot for using previous mining key', async () => {
|
||||
await proxyStorageMock.setVotingContractMock(voting.address);
|
||||
|
@ -360,12 +359,11 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_affectedKeyType: 1,
|
||||
_miningKey: '0x0000000000000000000000000000000000000000',
|
||||
_ballotType: 1,
|
||||
|
||||
})
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
let validators = await poaNetworkConsensusMock.getValidators();
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
let validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
await voting.setTime(VOTING_START_DATE - 1);
|
||||
await deployAndTestBallot({
|
||||
_affectedKey: accounts[5],
|
||||
|
@ -392,7 +390,7 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_ballotType: 1,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -402,10 +400,9 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
)
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.contain(miningKey);
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
})
|
||||
it('finalize removal of MiningKey', async () => {
|
||||
let miningKey = accounts[6];
|
||||
|
@ -421,9 +418,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_affectedKeyType: 1,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 2,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -433,9 +429,9 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
)
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(miningKey);
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
})
|
||||
it('finalize removal of VotingKey', async () => {
|
||||
let miningKey = accounts[6];
|
||||
|
@ -455,9 +451,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_affectedKeyType: 2,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 2,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -484,9 +479,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_affectedKeyType: 3,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 2,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -514,9 +508,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_affectedKeyType: 2,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 3,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ newVotingKey,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -543,9 +536,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_affectedKeyType: 3,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 3,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
newPayoutKey,
|
||||
|
@ -569,9 +561,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
_affectedKeyType: 1,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 3,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -579,7 +570,7 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
false,
|
||||
false ]
|
||||
)
|
||||
const keysStateNew = await keysManager.validatorKeys(affectedKey);
|
||||
const keysStateNew = await keysManager.validatorKeys.call(affectedKey);
|
||||
keysStateNew.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -589,11 +580,11 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
)
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(miningKey);
|
||||
validators.should.contain(affectedKey);
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator(affectedKey));
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator.call(affectedKey));
|
||||
})
|
||||
it('prevent double finalize', async () => {
|
||||
let miningKey = accounts[6];
|
||||
|
@ -604,29 +595,29 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, affectedKey, 1, miningKey, 3, "memo",{from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE+2, VOTING_END_DATE+2, affectedKey, 1, miningKey, 2, "memo",{from: votingKey});
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 2);
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 2);
|
||||
let votingIdForSecond = votingId.add(1);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await voting.getBallotType(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await voting.getBallotType.call(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await voting.getBallotType(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized(votingIdForSecond));
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await voting.getBallotType.call(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingIdForSecond));
|
||||
await voting.vote(votingIdForSecond, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 3);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress(votingId))
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress.call(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress.call(votingId))
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -645,37 +636,37 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
});
|
||||
it('should change implementation address', async () => {
|
||||
let votingNew = await VotingToChangeKeysNew.new();
|
||||
let oldImplementation = await voting.implementation();
|
||||
let oldImplementation = await voting.implementation.call();
|
||||
let newImplementation = votingNew.address;
|
||||
(await votingEternalStorage.implementation()).should.be.equal(oldImplementation);
|
||||
(await votingEternalStorage.implementation.call()).should.be.equal(oldImplementation);
|
||||
await votingEternalStorage.upgradeTo(newImplementation, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeKeysNew.at(votingEternalStorage.address);
|
||||
(await votingNew.implementation()).should.be.equal(newImplementation);
|
||||
(await votingEternalStorage.implementation()).should.be.equal(newImplementation);
|
||||
(await votingNew.implementation.call()).should.be.equal(newImplementation);
|
||||
(await votingEternalStorage.implementation.call()).should.be.equal(newImplementation);
|
||||
});
|
||||
it('should increment implementation version', async () => {
|
||||
let votingNew = await VotingToChangeKeysNew.new();
|
||||
let oldVersion = await voting.version();
|
||||
let oldVersion = await voting.version.call();
|
||||
let newVersion = oldVersion.add(1);
|
||||
(await votingEternalStorage.version()).should.be.bignumber.equal(oldVersion);
|
||||
(await votingEternalStorage.version.call()).should.be.bignumber.equal(oldVersion);
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeKeysNew.at(votingEternalStorage.address);
|
||||
(await votingNew.version()).should.be.bignumber.equal(newVersion);
|
||||
(await votingEternalStorage.version()).should.be.bignumber.equal(newVersion);
|
||||
(await votingNew.version.call()).should.be.bignumber.equal(newVersion);
|
||||
(await votingEternalStorage.version.call()).should.be.bignumber.equal(newVersion);
|
||||
});
|
||||
it('new implementation should work', async () => {
|
||||
let votingNew = await VotingToChangeKeysNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeKeysNew.at(votingEternalStorage.address);
|
||||
(await votingNew.initialized()).should.be.equal(false);
|
||||
(await votingNew.initialized.call()).should.be.equal(false);
|
||||
await votingNew.initialize();
|
||||
(await votingNew.initialized()).should.be.equal(true);
|
||||
(await votingNew.initialized.call()).should.be.equal(true);
|
||||
});
|
||||
it('new implementation should use the same proxyStorage address', async () => {
|
||||
let votingNew = await VotingToChangeKeysNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeKeysNew.at(votingEternalStorage.address);
|
||||
(await votingNew.proxyStorage()).should.be.equal(proxyStorageStubAddress);
|
||||
(await votingNew.proxyStorage.call()).should.be.equal(proxyStorageStubAddress);
|
||||
});
|
||||
it('new implementation should use the same storage', async () => {
|
||||
const payoutKeyToAdd = accounts[0];
|
||||
|
@ -691,8 +682,8 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
await votingEternalStorage.setProxyStorage(proxyStorageMock.address);
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, payoutKeyToAdd, 3, accounts[1], 1, "memo", {from: votingKey});
|
||||
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
const votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 1);
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
const votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 1);
|
||||
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
|
@ -706,20 +697,20 @@ contract('Voting to change keys [all features]', function (accounts) {
|
|||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress}).should.be.fulfilled;
|
||||
votingNew = await VotingToChangeKeysNew.at(votingEternalStorage.address);
|
||||
|
||||
(await votingNew.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await votingNew.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await votingNew.getAffectedKey(votingId)).should.be.equal(payoutKeyToAdd);
|
||||
(await votingNew.getAffectedKeyType(votingId)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getMiningKey(votingId)).should.be.equal(accounts[1]);
|
||||
(await votingNew.getTotalVoters(votingId)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getProgress(votingId)).should.be.bignumber.equal(-1);
|
||||
(await votingNew.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await votingNew.getQuorumState(votingId)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getBallotType(votingId)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await votingNew.getMemo(votingId)).should.be.equal("memo");
|
||||
(await votingNew.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await votingNew.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await votingNew.getAffectedKey.call(votingId)).should.be.equal(payoutKeyToAdd);
|
||||
(await votingNew.getAffectedKeyType.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getMiningKey.call(votingId)).should.be.equal(accounts[1]);
|
||||
(await votingNew.getTotalVoters.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getProgress.call(votingId)).should.be.bignumber.equal(-1);
|
||||
(await votingNew.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await votingNew.getQuorumState.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getBallotType.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await votingNew.getMemo.call(votingId)).should.be.equal("memo");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -732,7 +723,7 @@ async function deployAndTestBallot({_affectedKey, _affectedKeyType, _miningKey,
|
|||
// uint256 _affectedKeyType, [enum KeyTypes {Invalid, MiningKey, VotingKey, PayoutKey}]
|
||||
// address _miningKey,
|
||||
// uint256 _ballotType [ enum BallotTypes {Invalid, Adding, Removal, Swap} ]
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE,
|
||||
VOTING_END_DATE,
|
||||
|
@ -742,32 +733,32 @@ async function deployAndTestBallot({_affectedKey, _affectedKeyType, _miningKey,
|
|||
_ballotType,
|
||||
"memo",
|
||||
{from: votingKey});
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
new web3.BigNumber(_ballotType).should.be.bignumber.equal(await voting.getBallotType(votingId));
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
new web3.BigNumber(_ballotType).should.be.bignumber.equal(await voting.getBallotType.call(votingId));
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey(votingId)).should.be.equal(_affectedKey);
|
||||
(await voting.getAffectedKeyType(votingId)).should.be.bignumber.equal(_affectedKeyType);
|
||||
(await voting.getMiningKey(votingId)).should.be.equal(_miningKey);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getBallotType(votingId)).should.be.bignumber.equal(_ballotType);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey.call(votingId)).should.be.equal(_affectedKey);
|
||||
(await voting.getAffectedKeyType.call(votingId)).should.be.bignumber.equal(_affectedKeyType);
|
||||
(await voting.getMiningKey.call(votingId)).should.be.equal(_miningKey);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getBallotType.call(votingId)).should.be.bignumber.equal(_ballotType);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
}
|
|
@ -7,7 +7,7 @@ let BallotsStorage = artifacts.require('./BallotsStorage');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
const moment = require('moment');
|
||||
const {addValidators} = require('./helpers')
|
||||
const {addValidators} = require('./utils/helpers')
|
||||
|
||||
const choice = {
|
||||
accept: 1,
|
||||
|
@ -75,7 +75,7 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(votingKey, accounts[1]).should.be.fulfilled;
|
||||
const VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
const VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
const id = await voting.nextBallotId();
|
||||
const id = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, // _startTime
|
||||
VOTING_END_DATE, // _endTime
|
||||
|
@ -96,9 +96,9 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
"memo", // _memo
|
||||
{from: votingKey}
|
||||
).should.be.fulfilled;
|
||||
const startTime = await voting.getStartTime(id.toNumber());
|
||||
const endTime = await voting.getEndTime(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
const startTime = await voting.getStartTime.call(id.toNumber());
|
||||
const endTime = await voting.getEndTime.call(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE);
|
||||
|
@ -137,9 +137,9 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
const VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[2], 1, "memo", {from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[2], 1, "memo", {from: votingKey});
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await addValidators({proxyStorageMock, keysManager, poaNetworkConsensusMock}); //add 100 validators, so total will be 101 validator
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[2], 1, "memo", {from: votingKey}).should.be.rejectedWith(ERROR_MSG)
|
||||
})
|
||||
})
|
||||
|
@ -153,16 +153,16 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
await proxyStorageMock.setVotingContractMock(masterOfCeremony);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(votingKey, accounts[1]).should.be.fulfilled;
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[3], 1, accounts[1], 1, "memo", {from: votingKey});
|
||||
})
|
||||
|
||||
it('should let a validator to vote', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.accept, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(1);
|
||||
|
@ -172,9 +172,9 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
it('reject vote should be accepted', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(2);
|
||||
|
@ -192,20 +192,20 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(accounts[4], accounts[2]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.reject, {from: accounts[4]}).should.be.fulfilled;
|
||||
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-2);
|
||||
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(2);
|
||||
|
||||
await keysManager.addMiningKey(accounts[3]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[5], accounts[3]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.accept, {from: accounts[5]}).should.be.fulfilled;
|
||||
|
||||
progress = await voting.getProgress(id);
|
||||
progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
|
||||
totalVoters = await voting.getTotalVoters(id);
|
||||
totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(3);
|
||||
})
|
||||
it('should not let vote nonVoting key', async () => {
|
||||
|
@ -260,8 +260,8 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
it('happy path - no action since it did not meet minimum number of totalVoters', async () => {
|
||||
// Ballot to Add Payout Key for miner account[1]
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, payoutKeyToAdd, 3, accounts[1], 1, "memo", {from: votingKey});
|
||||
let activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 1);
|
||||
let activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 1);
|
||||
// console.log(votingId);
|
||||
await voting.finalize(votingId, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
|
@ -271,33 +271,33 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey(votingId)).should.be.equal(payoutKeyToAdd);
|
||||
(await voting.getAffectedKeyType(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getMiningKey(votingId)).should.be.equal(accounts[1]);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getBallotType(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey.call(votingId)).should.be.equal(payoutKeyToAdd);
|
||||
(await voting.getAffectedKeyType.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getMiningKey.call(votingId)).should.be.equal(accounts[1]);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getBallotType.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
|
||||
const keysState = await keysManager.validatorKeys(accounts[1]);
|
||||
const keysState = await keysManager.validatorKeys.call(accounts[1]);
|
||||
keysState.should.be.deep.equal(
|
||||
[ votingKey,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -316,7 +316,7 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_ballotType: 1,
|
||||
})
|
||||
|
||||
const keysState = await keysManager.validatorKeys(accounts[1]);
|
||||
const keysState = await keysManager.validatorKeys.call(accounts[1]);
|
||||
keysState.should.be.deep.equal(
|
||||
[ votingKey,
|
||||
payoutKeyToAdd,
|
||||
|
@ -343,7 +343,7 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_miningKey: miningKey,
|
||||
_ballotType: 1,
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ votingKeyToAdd,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -351,7 +351,6 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
true,
|
||||
false ]
|
||||
)
|
||||
|
||||
})
|
||||
it('cannot create ballot for using previous mining key', async () => {
|
||||
await proxyStorageMock.setVotingContractMock(voting.address);
|
||||
|
@ -365,12 +364,11 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_affectedKeyType: 1,
|
||||
_miningKey: '0x0000000000000000000000000000000000000000',
|
||||
_ballotType: 1,
|
||||
|
||||
})
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
let validators = await poaNetworkConsensusMock.getValidators();
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
let validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
await voting.setTime(VOTING_START_DATE - 1);
|
||||
await deployAndTestBallot({
|
||||
_affectedKey: accounts[5],
|
||||
|
@ -397,7 +395,7 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_ballotType: 1,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -407,10 +405,9 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
)
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.contain(miningKey);
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
})
|
||||
it('finalize removal of MiningKey', async () => {
|
||||
let miningKey = accounts[6];
|
||||
|
@ -426,9 +423,8 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_affectedKeyType: 1,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 2,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -438,9 +434,9 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
)
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(miningKey);
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
})
|
||||
it('finalize removal of VotingKey', async () => {
|
||||
let miningKey = accounts[6];
|
||||
|
@ -460,9 +456,8 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_affectedKeyType: 2,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 2,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -489,9 +484,8 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_affectedKeyType: 3,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 2,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -519,9 +513,8 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_affectedKeyType: 2,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 3,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ newVotingKey,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -548,9 +541,8 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_affectedKeyType: 3,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 3,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
newPayoutKey,
|
||||
|
@ -574,9 +566,8 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
_affectedKeyType: 1,
|
||||
_miningKey: miningKey,
|
||||
_ballotType: 3,
|
||||
|
||||
})
|
||||
const keysState = await keysManager.validatorKeys(miningKey);
|
||||
const keysState = await keysManager.validatorKeys.call(miningKey);
|
||||
keysState.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -584,7 +575,7 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
false,
|
||||
false ]
|
||||
)
|
||||
const keysStateNew = await keysManager.validatorKeys(affectedKey);
|
||||
const keysStateNew = await keysManager.validatorKeys.call(affectedKey);
|
||||
keysStateNew.should.be.deep.equal(
|
||||
[ '0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
|
@ -594,11 +585,11 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
)
|
||||
await poaNetworkConsensusMock.setSystemAddress(accounts[0]);
|
||||
await poaNetworkConsensusMock.finalizeChange().should.be.fulfilled;
|
||||
const validators = await poaNetworkConsensusMock.getValidators();
|
||||
const validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
validators.should.not.contain(miningKey);
|
||||
validators.should.contain(affectedKey);
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator(miningKey));
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator(affectedKey));
|
||||
false.should.be.equal(await poaNetworkConsensusMock.isValidator.call(miningKey));
|
||||
true.should.be.equal(await poaNetworkConsensusMock.isValidator.call(affectedKey));
|
||||
})
|
||||
it('prevent double finalize', async () => {
|
||||
let miningKey = accounts[6];
|
||||
|
@ -609,29 +600,29 @@ contract('Voting to change keys upgraded [all features]', function (accounts) {
|
|||
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, affectedKey, 1, miningKey, 3, "memo",{from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE+2, VOTING_END_DATE+2, affectedKey, 1, miningKey, 2, "memo",{from: votingKey});
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 2);
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 2);
|
||||
let votingIdForSecond = votingId.add(1);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await voting.getBallotType(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
new web3.BigNumber(3).should.be.bignumber.equal(await voting.getBallotType.call(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await voting.getBallotType(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized(votingIdForSecond));
|
||||
new web3.BigNumber(2).should.be.bignumber.equal(await voting.getBallotType.call(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingIdForSecond));
|
||||
await voting.vote(votingIdForSecond, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 3);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress(votingId))
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress.call(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress.call(votingId))
|
||||
})
|
||||
})
|
||||
});
|
||||
|
@ -644,7 +635,7 @@ async function deployAndTestBallot({_affectedKey, _affectedKeyType, _miningKey,
|
|||
// uint256 _affectedKeyType, [enum KeyTypes {Invalid, MiningKey, VotingKey, PayoutKey}]
|
||||
// address _miningKey,
|
||||
// uint256 _ballotType [ enum BallotTypes {Invalid, Adding, Removal, Swap} ]
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE,
|
||||
VOTING_END_DATE,
|
||||
|
@ -654,32 +645,32 @@ async function deployAndTestBallot({_affectedKey, _affectedKeyType, _miningKey,
|
|||
_ballotType,
|
||||
"memo",
|
||||
{from: votingKey});
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
new web3.BigNumber(_ballotType).should.be.bignumber.equal(await voting.getBallotType(votingId));
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
new web3.BigNumber(_ballotType).should.be.bignumber.equal(await voting.getBallotType.call(votingId));
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey(votingId)).should.be.equal(_affectedKey);
|
||||
(await voting.getAffectedKeyType(votingId)).should.be.bignumber.equal(_affectedKeyType);
|
||||
(await voting.getMiningKey(votingId)).should.be.equal(_miningKey);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getBallotType(votingId)).should.be.bignumber.equal(_ballotType);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getAffectedKey.call(votingId)).should.be.equal(_affectedKey);
|
||||
(await voting.getAffectedKeyType.call(votingId)).should.be.bignumber.equal(_affectedKeyType);
|
||||
(await voting.getMiningKey.call(votingId)).should.be.equal(_miningKey);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getBallotType.call(votingId)).should.be.bignumber.equal(_ballotType);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
}
|
|
@ -8,7 +8,7 @@ let BallotsStorage = artifacts.require('./BallotsStorage');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
const moment = require('moment');
|
||||
const {addValidators} = require('./helpers')
|
||||
const {addValidators} = require('./utils/helpers')
|
||||
|
||||
|
||||
const choice = {
|
||||
|
@ -89,24 +89,24 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
beforeEach(async () => {
|
||||
VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
})
|
||||
it('happy path', async () => {
|
||||
const {logs} = await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4, "memo", {from: votingKey});
|
||||
const startTime = await voting.getStartTime(id.toNumber());
|
||||
const endTime = await voting.getEndTime(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
const startTime = await voting.getStartTime.call(id.toNumber());
|
||||
const endTime = await voting.getEndTime.call(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(id)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue(id)).should.be.bignumber.equal(4);
|
||||
(await voting.getCreator(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(id)).should.be.equal("memo");
|
||||
(await voting.getTotalVoters.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized.call(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(id)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue.call(id)).should.be.bignumber.equal(4);
|
||||
(await voting.getCreator.call(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(id)).should.be.equal("memo");
|
||||
keysManagerFromContract.should.be.equal(keysManager.address);
|
||||
logs[0].event.should.be.equal("BallotCreated");
|
||||
logs[0].args.id.should.be.bignumber.equal(0);
|
||||
|
@ -124,9 +124,9 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4,"memo", {from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4,"memo", {from: votingKey});
|
||||
// we have 6 validators, so 200 limit / 6 = 33.3 ~ 33
|
||||
new web3.BigNumber(33).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(33).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await addValidators({proxyStorageMock, keysManager, poaNetworkConsensusMock}); // add 100 validators, so total will be 106 validators
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4, "memo",{from: votingKey}).should.be.rejectedWith(ERROR_MSG)
|
||||
})
|
||||
})
|
||||
|
@ -138,17 +138,17 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
|
||||
id = await voting.nextBallotId();
|
||||
let validators = await poaNetworkConsensusMock.getValidators();
|
||||
id = await voting.nextBallotId.call();
|
||||
let validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4, "memo",{from: votingKey});
|
||||
})
|
||||
|
||||
it('should let a validator to vote', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.accept, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(1);
|
||||
|
@ -159,9 +159,9 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
it('reject vote should be accepted', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(2);
|
||||
|
@ -177,18 +177,18 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
// add new voter
|
||||
await voting.vote(id, choice.reject, {from: votingKey2}).should.be.fulfilled;
|
||||
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-2);
|
||||
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(2);
|
||||
|
||||
await voting.vote(id, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
|
||||
progress = await voting.getProgress(id);
|
||||
progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
|
||||
totalVoters = await voting.getTotalVoters(id);
|
||||
totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(3);
|
||||
})
|
||||
it('should not let vote nonVoting key', async () => {
|
||||
|
@ -230,42 +230,42 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
|
||||
it('does not change if it did not pass minimum threshold', async () => {
|
||||
let proposedValue = 4;
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, proposedValue, "memo", {from: votingKey});
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey}).should.be.fulfilled;
|
||||
// await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold(1);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold.call(1);
|
||||
minThresholdOfVoters.should.be.bignumber.equal(3);
|
||||
});
|
||||
|
||||
it('should change to proposedValue when quorum is reached', async () => {
|
||||
let proposedValue = 4;
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, proposedValue, "memo", {from: votingKey});
|
||||
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
|
@ -276,36 +276,36 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey2)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey2)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey3)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey3)
|
||||
);
|
||||
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold(1);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold.call(1);
|
||||
minThresholdOfVoters.should.be.bignumber.equal(proposedValue);
|
||||
|
||||
let votingForKeys = await VotingForKeys.new();
|
||||
|
@ -313,9 +313,9 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
votingForKeys = await VotingForKeys.at(votingForKeysEternalStorage.address);
|
||||
await votingForKeys.init(172800);
|
||||
|
||||
const nextId = await votingForKeys.nextBallotId();
|
||||
const nextId = await votingForKeys.nextBallotId.call();
|
||||
await votingForKeys.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 3, accounts[1], 1, "memo", {from: votingKey});
|
||||
const minThresholdVotingForKeys = await votingForKeys.getMinThresholdOfVoters(nextId);
|
||||
const minThresholdVotingForKeys = await votingForKeys.getMinThresholdOfVoters.call(nextId);
|
||||
minThresholdVotingForKeys.should.be.bignumber.equal(proposedValue);
|
||||
})
|
||||
|
||||
|
@ -332,30 +332,30 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
|
||||
await voting.createBallot(VOTING_START_DATE+2, VOTING_END_DATE+2, proposedValue2, "memo",{from: votingKey});
|
||||
await voting.finalize(votingId, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 2);
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 2);
|
||||
let votingIdForSecond = votingId.add(1);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await voting.getProposedValue(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await voting.getProposedValue.call(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await voting.getProposedValue(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized(votingIdForSecond));
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await voting.getProposedValue.call(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingIdForSecond));
|
||||
await voting.vote(votingIdForSecond, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 3);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress(votingId))
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress.call(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress.call(votingId))
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -374,59 +374,59 @@ contract('VotingToChangeMinThreshold [all features]', function (accounts) {
|
|||
});
|
||||
it('should change implementation address', async () => {
|
||||
let votingNew = await VotingNew.new();
|
||||
let oldImplementation = await voting.implementation();
|
||||
let oldImplementation = await voting.implementation.call();
|
||||
let newImplementation = votingNew.address;
|
||||
(await votingEternalStorage.implementation()).should.be.equal(oldImplementation);
|
||||
(await votingEternalStorage.implementation.call()).should.be.equal(oldImplementation);
|
||||
await votingEternalStorage.upgradeTo(newImplementation, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingNew.at(votingEternalStorage.address);
|
||||
(await votingNew.implementation()).should.be.equal(newImplementation);
|
||||
(await votingEternalStorage.implementation()).should.be.equal(newImplementation);
|
||||
(await votingNew.implementation.call()).should.be.equal(newImplementation);
|
||||
(await votingEternalStorage.implementation.call()).should.be.equal(newImplementation);
|
||||
});
|
||||
it('should increment implementation version', async () => {
|
||||
let votingNew = await VotingNew.new();
|
||||
let oldVersion = await voting.version();
|
||||
let oldVersion = await voting.version.call();
|
||||
let newVersion = oldVersion.add(1);
|
||||
(await votingEternalStorage.version()).should.be.bignumber.equal(oldVersion);
|
||||
(await votingEternalStorage.version.call()).should.be.bignumber.equal(oldVersion);
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingNew.at(votingEternalStorage.address);
|
||||
(await votingNew.version()).should.be.bignumber.equal(newVersion);
|
||||
(await votingEternalStorage.version()).should.be.bignumber.equal(newVersion);
|
||||
(await votingNew.version.call()).should.be.bignumber.equal(newVersion);
|
||||
(await votingEternalStorage.version.call()).should.be.bignumber.equal(newVersion);
|
||||
});
|
||||
it('new implementation should work', async () => {
|
||||
let votingNew = await VotingNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingNew.at(votingEternalStorage.address);
|
||||
(await votingNew.initialized()).should.be.equal(false);
|
||||
(await votingNew.initialized.call()).should.be.equal(false);
|
||||
await votingNew.initialize();
|
||||
(await votingNew.initialized()).should.be.equal(true);
|
||||
(await votingNew.initialized.call()).should.be.equal(true);
|
||||
});
|
||||
it('new implementation should use the same proxyStorage address', async () => {
|
||||
let votingNew = await VotingNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingNew.at(votingEternalStorage.address);
|
||||
(await votingNew.proxyStorage()).should.be.equal(proxyStorageStubAddress);
|
||||
(await votingNew.proxyStorage.call()).should.be.equal(proxyStorageStubAddress);
|
||||
});
|
||||
it('new implementation should use the same storage', async () => {
|
||||
const VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
const VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
const id = await voting.nextBallotId();
|
||||
const id = await voting.nextBallotId.call();
|
||||
await votingEternalStorage.setProxyStorage(proxyStorageMock.address);
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4, "memo", {from: votingKey}).should.be.fulfilled;
|
||||
await votingEternalStorage.setProxyStorage(proxyStorageStubAddress);
|
||||
let votingNew = await VotingNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress}).should.be.fulfilled;
|
||||
votingNew = await VotingNew.at(votingEternalStorage.address);
|
||||
(await votingNew.getStartTime(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await votingNew.getEndTime(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await votingNew.getTotalVoters(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getProgress(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getIsFinalized(id)).should.be.equal(false);
|
||||
(await votingNew.getQuorumState(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getIndex(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getMinThresholdOfVoters(id)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getProposedValue(id)).should.be.bignumber.equal(4);
|
||||
(await votingNew.getCreator(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await votingNew.getMemo(id)).should.be.equal("memo");
|
||||
(await votingNew.getStartTime.call(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await votingNew.getEndTime.call(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await votingNew.getTotalVoters.call(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getProgress.call(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getIsFinalized.call(id)).should.be.equal(false);
|
||||
(await votingNew.getQuorumState.call(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getIndex.call(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getMinThresholdOfVoters.call(id)).should.be.bignumber.equal(3);
|
||||
(await votingNew.getProposedValue.call(id)).should.be.bignumber.equal(4);
|
||||
(await votingNew.getCreator.call(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await votingNew.getMemo.call(id)).should.be.equal("memo");
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
|
@ -8,7 +8,7 @@ let BallotsStorage = artifacts.require('./BallotsStorage');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
const moment = require('moment');
|
||||
const {addValidators} = require('./helpers')
|
||||
const {addValidators} = require('./utils/helpers')
|
||||
|
||||
|
||||
const choice = {
|
||||
|
@ -95,24 +95,24 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
beforeEach(async () => {
|
||||
VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
})
|
||||
it('happy path', async () => {
|
||||
const {logs} = await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4, "memo", {from: votingKey});
|
||||
const startTime = await voting.getStartTime(id.toNumber());
|
||||
const endTime = await voting.getEndTime(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
const startTime = await voting.getStartTime.call(id.toNumber());
|
||||
const endTime = await voting.getEndTime.call(id.toNumber());
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(id)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue(id)).should.be.bignumber.equal(4);
|
||||
(await voting.getCreator(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(id)).should.be.equal("memo");
|
||||
(await voting.getTotalVoters.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized.call(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(id)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue.call(id)).should.be.bignumber.equal(4);
|
||||
(await voting.getCreator.call(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(id)).should.be.equal("memo");
|
||||
keysManagerFromContract.should.be.equal(keysManager.address);
|
||||
logs[0].event.should.be.equal("BallotCreated");
|
||||
logs[0].args.id.should.be.bignumber.equal(0);
|
||||
|
@ -130,9 +130,9 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4,"memo", {from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4,"memo", {from: votingKey});
|
||||
// we have 6 validators, so 200 limit / 6 = 33.3 ~ 33
|
||||
new web3.BigNumber(33).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(33).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await addValidators({proxyStorageMock, keysManager, poaNetworkConsensusMock}); // add 100 validators, so total will be 106 validators
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4, "memo",{from: votingKey}).should.be.rejectedWith(ERROR_MSG)
|
||||
})
|
||||
})
|
||||
|
@ -144,17 +144,17 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
|
||||
id = await voting.nextBallotId();
|
||||
let validators = await poaNetworkConsensusMock.getValidators();
|
||||
id = await voting.nextBallotId.call();
|
||||
let validators = await poaNetworkConsensusMock.getValidators.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, 4, "memo",{from: votingKey});
|
||||
})
|
||||
|
||||
it('should let a validator to vote', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.accept, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(1);
|
||||
|
@ -165,9 +165,9 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
it('reject vote should be accepted', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const {logs} = await voting.vote(id, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(2);
|
||||
|
@ -183,18 +183,18 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
// add new voter
|
||||
await voting.vote(id, choice.reject, {from: votingKey2}).should.be.fulfilled;
|
||||
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-2);
|
||||
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(2);
|
||||
|
||||
await voting.vote(id, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
|
||||
progress = await voting.getProgress(id);
|
||||
progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
|
||||
totalVoters = await voting.getTotalVoters(id);
|
||||
totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(3);
|
||||
})
|
||||
it('should not let vote nonVoting key', async () => {
|
||||
|
@ -236,42 +236,42 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
|
||||
it('does not change if it did not pass minimum threshold', async () => {
|
||||
let proposedValue = 4;
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, proposedValue, "memo", {from: votingKey});
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey}).should.be.fulfilled;
|
||||
// await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold(1);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold.call(1);
|
||||
minThresholdOfVoters.should.be.bignumber.equal(3);
|
||||
});
|
||||
|
||||
it('should change to proposedValue when quorum is reached', async () => {
|
||||
let proposedValue = 4;
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, proposedValue, "memo", {from: votingKey});
|
||||
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
|
@ -282,36 +282,36 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const {logs} = await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.bignumber.equal(proposedValue);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey2)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey2)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey3)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey3)
|
||||
);
|
||||
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold(1);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold.call(1);
|
||||
minThresholdOfVoters.should.be.bignumber.equal(proposedValue);
|
||||
|
||||
let votingForKeys = await VotingForKeys.new();
|
||||
|
@ -319,9 +319,9 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
votingForKeys = await VotingForKeys.at(votingForKeysEternalStorage.address);
|
||||
await votingForKeys.init(172800);
|
||||
|
||||
const nextId = await votingForKeys.nextBallotId();
|
||||
const nextId = await votingForKeys.nextBallotId.call();
|
||||
await votingForKeys.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 3, accounts[1], 1, "memo", {from: votingKey});
|
||||
const minThresholdVotingForKeys = await votingForKeys.getMinThresholdOfVoters(nextId);
|
||||
const minThresholdVotingForKeys = await votingForKeys.getMinThresholdOfVoters.call(nextId);
|
||||
minThresholdVotingForKeys.should.be.bignumber.equal(proposedValue);
|
||||
})
|
||||
|
||||
|
@ -338,30 +338,30 @@ contract('VotingToChangeMinThreshold upgraded [all features]', function (account
|
|||
|
||||
await voting.createBallot(VOTING_START_DATE+2, VOTING_END_DATE+2, proposedValue2, "memo",{from: votingKey});
|
||||
await voting.finalize(votingId, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 2);
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 2);
|
||||
let votingIdForSecond = votingId.add(1);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await voting.getProposedValue(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
new web3.BigNumber(4).should.be.bignumber.equal(await voting.getProposedValue.call(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await voting.getProposedValue(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized(votingIdForSecond));
|
||||
new web3.BigNumber(5).should.be.bignumber.equal(await voting.getProposedValue.call(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingIdForSecond));
|
||||
await voting.vote(votingIdForSecond, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 3);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress(votingId))
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress.call(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress.call(votingId))
|
||||
})
|
||||
});
|
||||
})
|
||||
|
|
|
@ -10,7 +10,7 @@ let ValidatorMetadata = artifacts.require('./ValidatorMetadata');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
const moment = require('moment');
|
||||
const {addValidators} = require('./helpers')
|
||||
const {addValidators} = require('./utils/helpers')
|
||||
|
||||
const choice = {
|
||||
accept: 1,
|
||||
|
@ -90,7 +90,7 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
proxyStorageMock.setVotingContractMock(votingForKeysEternalStorage.address);
|
||||
VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
})
|
||||
it('happy path', async () => {
|
||||
// uint256 _startTime,
|
||||
|
@ -100,24 +100,24 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
const {logs} = await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], 1, "memo", { from: votingKey }
|
||||
);
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
(await voting.getStartTime(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue(id)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getCreator(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(id)).should.be.equal("memo");
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
(await voting.getStartTime.call(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized.call(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue.call(id)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getCreator.call(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(id)).should.be.equal("memo");
|
||||
|
||||
let activeBallotsLength = await voting.activeBallotsLength();
|
||||
let activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(1);
|
||||
|
||||
let nextBallotId = await voting.nextBallotId();
|
||||
let nextBallotId = await voting.nextBallotId.call();
|
||||
nextBallotId.should.be.bignumber.equal(1);
|
||||
|
||||
keysManagerFromContract.should.be.equal(keysManager.address);
|
||||
|
@ -131,29 +131,29 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
it('can create multiple ballots', async () => {
|
||||
const { logs } = await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], 1, "memo",{ from: votingKey });
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
|
||||
let activeBallotsLength = await voting.activeBallotsLength();
|
||||
let activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(1);
|
||||
|
||||
let nextBallotId = await voting.nextBallotId();
|
||||
let nextBallotId = await voting.nextBallotId.call();
|
||||
nextBallotId.should.be.bignumber.equal(1);
|
||||
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE + 1, VOTING_END_DATE + 1, accounts[5], 2, "memo",{ from: votingKey }
|
||||
);
|
||||
(await voting.getStartTime(nextBallotId)).should.be.bignumber.equal(VOTING_START_DATE+1);
|
||||
(await voting.getEndTime(nextBallotId)).should.be.bignumber.equal(VOTING_END_DATE+1);
|
||||
(await voting.getTotalVoters(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized(nextBallotId)).should.be.equal(false);
|
||||
(await voting.getQuorumState(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getMinThresholdOfVoters(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue(nextBallotId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType(nextBallotId)).should.be.bignumber.equal(2);
|
||||
(await voting.getCreator(nextBallotId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(nextBallotId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(nextBallotId)).should.be.bignumber.equal(VOTING_START_DATE+1);
|
||||
(await voting.getEndTime.call(nextBallotId)).should.be.bignumber.equal(VOTING_END_DATE+1);
|
||||
(await voting.getTotalVoters.call(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress.call(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized.call(nextBallotId)).should.be.equal(false);
|
||||
(await voting.getQuorumState.call(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getMinThresholdOfVoters.call(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue.call(nextBallotId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType.call(nextBallotId)).should.be.bignumber.equal(2);
|
||||
(await voting.getCreator.call(nextBallotId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(nextBallotId)).should.be.equal("memo");
|
||||
})
|
||||
it('should not let create more ballots than the limit', async () => {
|
||||
const VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
|
@ -161,9 +161,9 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 2, "memo",{from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 2, "memo",{from: votingKey});
|
||||
// we have 1 validator, so 200 limit / 1 = 200
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await addValidators({proxyStorageMock, keysManager, poaNetworkConsensusMock}); // add 100 validators, so total will be 101 validator
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 2, "memo",{from: votingKey}).should.be.rejectedWith(ERROR_MSG)
|
||||
})
|
||||
})
|
||||
|
@ -177,7 +177,7 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
await proxyStorageMock.setVotingContractMock(accounts[0]);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(votingKey, accounts[1]).should.be.fulfilled;
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], 1, "memo", { from: votingKey }
|
||||
);
|
||||
|
@ -186,9 +186,9 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
it('should let a validator to vote', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const { logs } = await voting.vote(id, choice.accept, { from: votingKey }).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(1);
|
||||
|
@ -198,9 +198,9 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
it('reject vote should be accepted', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const { logs } = await voting.vote(id, choice.reject, { from: votingKey }).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(2);
|
||||
|
@ -219,20 +219,20 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
await keysManager.addVotingKey(accounts[4], accounts[2]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.reject, { from: accounts[4] }).should.be.fulfilled;
|
||||
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-2);
|
||||
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(2);
|
||||
|
||||
await keysManager.addMiningKey(accounts[3]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[5], accounts[3]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.accept, { from: accounts[5] }).should.be.fulfilled;
|
||||
|
||||
progress = await voting.getProgress(id);
|
||||
progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
|
||||
totalVoters = await voting.getTotalVoters(id);
|
||||
totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(3);
|
||||
})
|
||||
it('should not let vote nonVoting key', async () => {
|
||||
|
@ -289,7 +289,7 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
it('does not change if it did not pass minimum threshold', async () => {
|
||||
let proposedValue = 5;
|
||||
let contractType = 1; //keysManager
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], contractType, "memo", { from: votingKey }
|
||||
);
|
||||
|
@ -300,28 +300,28 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const { logs } = await voting.finalize(votingId, { from: votingKey }).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType.call(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold(1);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold.call(1);
|
||||
minThresholdOfVoters.should.be.bignumber.equal(3);
|
||||
});
|
||||
|
||||
|
@ -330,61 +330,61 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
let keysManagerNew = await KeysManagerMock.new();
|
||||
let newAddress = keysManagerNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getKeysManager();
|
||||
let eternalProxyAddress = await proxyStorageMock.getKeysManager.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change VotingToChangeKeys implementation', async () => {
|
||||
let contractType = 2;
|
||||
let votingToChangeKeysNew = await VotingForKeys.new();
|
||||
let newAddress = votingToChangeKeysNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeKeys();
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeKeys.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change VotingToChangeMinThreshold implementation', async () => {
|
||||
let contractType = 3;
|
||||
let votingToChangeMinThresholdNew = await VotingForMinThreshold.new();
|
||||
let newAddress = votingToChangeMinThresholdNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeMinThreshold();
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeMinThreshold.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change VotingToChangeProxy implementation', async () => {
|
||||
let contractType = 4;
|
||||
let votingToChangeProxyNew = await VotingToChangeProxyAddress.new();
|
||||
let newAddress = votingToChangeProxyNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeProxy();
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeProxy.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change BallotsStorage implementation', async () => {
|
||||
let contractType = 5;
|
||||
let ballotsStorageNew = await BallotsStorage.new();
|
||||
let newAddress = ballotsStorageNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getBallotsStorage();
|
||||
let eternalProxyAddress = await proxyStorageMock.getBallotsStorage.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change ValidatorMetadata implementation', async () => {
|
||||
let contractType = 7;
|
||||
let validatorMetadataNew = await ValidatorMetadata.new();
|
||||
let newAddress = validatorMetadataNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getValidatorMetadata();
|
||||
let eternalProxyAddress = await proxyStorageMock.getValidatorMetadata.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change ProxyStorage implementation', async () => {
|
||||
const contractType = 8;
|
||||
const proxyStorageNew = await ProxyStorageMock.new();
|
||||
const newAddress = proxyStorageNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
newAddress.should.be.equal(await proxyStorageMock.implementation());
|
||||
newAddress.should.be.equal(await proxyStorageMock.implementation.call());
|
||||
})
|
||||
it('prevents double finalize', async () => {
|
||||
let newAddress1 = accounts[4];
|
||||
|
@ -398,58 +398,58 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
VOTING_START_DATE+2, VOTING_END_DATE+2, newAddress2, contractType2, "memo", { from: votingKey }
|
||||
);
|
||||
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 2);
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 2);
|
||||
let votingIdForSecond = votingId.add(1);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingIdForSecond));
|
||||
await voting.vote(votingIdForSecond, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 3);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress(votingId))
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress.call(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress.call(votingId))
|
||||
|
||||
let startTime = await voting.getStartTime(votingId);
|
||||
let endTime = await voting.getEndTime(votingId);
|
||||
let startTime = await voting.getStartTime.call(votingId);
|
||||
let endTime = await voting.getEndTime.call(votingId);
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingId)).should.be.equal(newAddress1);
|
||||
(await voting.getContractType(votingId)).should.be.bignumber.equal(contractType1);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.equal(newAddress1);
|
||||
(await voting.getContractType.call(votingId)).should.be.bignumber.equal(contractType1);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
startTime = await voting.getStartTime(votingIdForSecond);
|
||||
endTime = await voting.getEndTime(votingIdForSecond);
|
||||
startTime = await voting.getStartTime.call(votingIdForSecond);
|
||||
endTime = await voting.getEndTime.call(votingIdForSecond);
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE+2);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE+2);
|
||||
(await voting.getTotalVoters(votingIdForSecond)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingIdForSecond)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized(votingIdForSecond)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingIdForSecond)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex(votingIdForSecond)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingIdForSecond)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingIdForSecond)).should.be.equal(newAddress2);
|
||||
(await voting.getContractType(votingIdForSecond)).should.be.bignumber.equal(contractType2);
|
||||
(await voting.getCreator(votingIdForSecond)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingIdForSecond)).should.be.equal("memo");
|
||||
(await voting.getTotalVoters.call(votingIdForSecond)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingIdForSecond)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized.call(votingIdForSecond)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingIdForSecond)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex.call(votingIdForSecond)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingIdForSecond)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingIdForSecond)).should.be.equal(newAddress2);
|
||||
(await voting.getContractType.call(votingIdForSecond)).should.be.bignumber.equal(contractType2);
|
||||
(await voting.getCreator.call(votingIdForSecond)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingIdForSecond)).should.be.equal("memo");
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -469,42 +469,42 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
});
|
||||
it('should change implementation address', async () => {
|
||||
let votingNew = await VotingToChangeProxyAddressNew.new();
|
||||
let oldImplementation = await voting.implementation();
|
||||
let oldImplementation = await voting.implementation.call();
|
||||
let newImplementation = votingNew.address;
|
||||
(await votingEternalStorage.implementation()).should.be.equal(oldImplementation);
|
||||
(await votingEternalStorage.implementation.call()).should.be.equal(oldImplementation);
|
||||
await votingEternalStorage.upgradeTo(newImplementation, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeProxyAddressNew.at(votingEternalStorage.address);
|
||||
(await votingNew.implementation()).should.be.equal(newImplementation);
|
||||
(await votingEternalStorage.implementation()).should.be.equal(newImplementation);
|
||||
(await votingNew.implementation.call()).should.be.equal(newImplementation);
|
||||
(await votingEternalStorage.implementation.call()).should.be.equal(newImplementation);
|
||||
});
|
||||
it('should increment implementation version', async () => {
|
||||
let votingNew = await VotingToChangeProxyAddressNew.new();
|
||||
let oldVersion = await voting.version();
|
||||
let oldVersion = await voting.version.call();
|
||||
let newVersion = oldVersion.add(1);
|
||||
(await votingEternalStorage.version()).should.be.bignumber.equal(oldVersion);
|
||||
(await votingEternalStorage.version.call()).should.be.bignumber.equal(oldVersion);
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeProxyAddressNew.at(votingEternalStorage.address);
|
||||
(await votingNew.version()).should.be.bignumber.equal(newVersion);
|
||||
(await votingEternalStorage.version()).should.be.bignumber.equal(newVersion);
|
||||
(await votingNew.version.call()).should.be.bignumber.equal(newVersion);
|
||||
(await votingEternalStorage.version.call()).should.be.bignumber.equal(newVersion);
|
||||
});
|
||||
it('new implementation should work', async () => {
|
||||
let votingNew = await VotingToChangeProxyAddressNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeProxyAddressNew.at(votingEternalStorage.address);
|
||||
(await votingNew.initialized()).should.be.equal(false);
|
||||
(await votingNew.initialized.call()).should.be.equal(false);
|
||||
await votingNew.initialize();
|
||||
(await votingNew.initialized()).should.be.equal(true);
|
||||
(await votingNew.initialized.call()).should.be.equal(true);
|
||||
});
|
||||
it('new implementation should use the same proxyStorage address', async () => {
|
||||
let votingNew = await VotingToChangeProxyAddressNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeProxyAddressNew.at(votingEternalStorage.address);
|
||||
(await votingNew.proxyStorage()).should.be.equal(proxyStorageStubAddress);
|
||||
(await votingNew.proxyStorage.call()).should.be.equal(proxyStorageStubAddress);
|
||||
});
|
||||
it('new implementation should use the same storage', async () => {
|
||||
const VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
const VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
const id = await voting.nextBallotId();
|
||||
const id = await voting.nextBallotId.call();
|
||||
proxyStorageMock.setVotingContractMock(accounts[0]);
|
||||
await keysManager.addMiningKey(miningKeyForVotingKey).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(votingKey, miningKeyForVotingKey).should.be.fulfilled;
|
||||
|
@ -517,18 +517,18 @@ contract('VotingToChangeProxyAddress [all features]', function (accounts) {
|
|||
let votingNew = await VotingToChangeProxyAddressNew.new();
|
||||
await votingEternalStorage.upgradeTo(votingNew.address, {from: proxyStorageStubAddress});
|
||||
votingNew = await VotingToChangeProxyAddressNew.at(votingEternalStorage.address);
|
||||
(await votingNew.getStartTime(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await votingNew.getEndTime(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await votingNew.getTotalVoters(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getProgress(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getIsFinalized(id)).should.be.equal(false);
|
||||
(await votingNew.getQuorumState(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getIndex(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getMinThresholdOfVoters(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getProposedValue(id)).should.be.equal(accounts[5]);
|
||||
(await votingNew.getContractType(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getCreator(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await votingNew.getMemo(id)).should.be.equal("memo");
|
||||
(await votingNew.getStartTime.call(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await votingNew.getEndTime.call(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await votingNew.getTotalVoters.call(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getProgress.call(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getIsFinalized.call(id)).should.be.equal(false);
|
||||
(await votingNew.getQuorumState.call(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getIndex.call(id)).should.be.bignumber.equal(0);
|
||||
(await votingNew.getMinThresholdOfVoters.call(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getProposedValue.call(id)).should.be.equal(accounts[5]);
|
||||
(await votingNew.getContractType.call(id)).should.be.bignumber.equal(1);
|
||||
(await votingNew.getCreator.call(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await votingNew.getMemo.call(id)).should.be.equal("memo");
|
||||
});
|
||||
});
|
||||
})
|
||||
|
@ -537,7 +537,7 @@ async function deployAndTest({
|
|||
contractType,
|
||||
newAddress
|
||||
}) {
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, newAddress, contractType, "memo", { from: votingKey }
|
||||
);
|
||||
|
@ -549,35 +549,35 @@ async function deployAndTest({
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const { logs } = await voting.finalize(votingId, { from: votingKey }).should.be.fulfilled;
|
||||
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingId)).should.be.equal(newAddress);
|
||||
(await voting.getContractType(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.equal(newAddress);
|
||||
(await voting.getContractType.call(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
if (contractType !== 1) {
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey2)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey2)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey3)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey3)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ let ValidatorMetadata = artifacts.require('./ValidatorMetadata');
|
|||
let EternalStorageProxy = artifacts.require('./mockContracts/EternalStorageProxyMock');
|
||||
const ERROR_MSG = 'VM Exception while processing transaction: revert';
|
||||
const moment = require('moment');
|
||||
const {addValidators} = require('./helpers')
|
||||
const {addValidators} = require('./utils/helpers')
|
||||
|
||||
const choice = {
|
||||
accept: 1,
|
||||
|
@ -96,7 +96,7 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
proxyStorageMock.setVotingContractMock(votingForKeysEternalStorage.address);
|
||||
VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
VOTING_END_DATE = moment.utc().add(10, 'days').unix();
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
})
|
||||
it('happy path', async () => {
|
||||
// uint256 _startTime,
|
||||
|
@ -106,24 +106,24 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
const {logs} = await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], 1, "memo", { from: votingKey }
|
||||
);
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
(await voting.getStartTime(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue(id)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getCreator(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(id)).should.be.equal("memo");
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
(await voting.getStartTime.call(id)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(id)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized.call(id)).should.be.equal(false);
|
||||
(await voting.getQuorumState.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(id)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue.call(id)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType.call(id)).should.be.bignumber.equal(1);
|
||||
(await voting.getCreator.call(id)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(id)).should.be.equal("memo");
|
||||
|
||||
let activeBallotsLength = await voting.activeBallotsLength();
|
||||
let activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(1);
|
||||
|
||||
let nextBallotId = await voting.nextBallotId();
|
||||
let nextBallotId = await voting.nextBallotId.call();
|
||||
nextBallotId.should.be.bignumber.equal(1);
|
||||
|
||||
keysManagerFromContract.should.be.equal(keysManager.address);
|
||||
|
@ -137,29 +137,29 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
it('can create multiple ballots', async () => {
|
||||
const { logs } = await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], 1, "memo",{ from: votingKey });
|
||||
const keysManagerFromContract = await voting.getKeysManager();
|
||||
const keysManagerFromContract = await voting.getKeysManager.call();
|
||||
|
||||
let activeBallotsLength = await voting.activeBallotsLength();
|
||||
let activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(1);
|
||||
|
||||
let nextBallotId = await voting.nextBallotId();
|
||||
let nextBallotId = await voting.nextBallotId.call();
|
||||
nextBallotId.should.be.bignumber.equal(1);
|
||||
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE + 1, VOTING_END_DATE + 1, accounts[5], 2, "memo",{ from: votingKey }
|
||||
);
|
||||
(await voting.getStartTime(nextBallotId)).should.be.bignumber.equal(VOTING_START_DATE+1);
|
||||
(await voting.getEndTime(nextBallotId)).should.be.bignumber.equal(VOTING_END_DATE+1);
|
||||
(await voting.getTotalVoters(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized(nextBallotId)).should.be.equal(false);
|
||||
(await voting.getQuorumState(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getMinThresholdOfVoters(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue(nextBallotId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType(nextBallotId)).should.be.bignumber.equal(2);
|
||||
(await voting.getCreator(nextBallotId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(nextBallotId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(nextBallotId)).should.be.bignumber.equal(VOTING_START_DATE+1);
|
||||
(await voting.getEndTime.call(nextBallotId)).should.be.bignumber.equal(VOTING_END_DATE+1);
|
||||
(await voting.getTotalVoters.call(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getProgress.call(nextBallotId)).should.be.bignumber.equal(0);
|
||||
(await voting.getIsFinalized.call(nextBallotId)).should.be.equal(false);
|
||||
(await voting.getQuorumState.call(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIndex.call(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getMinThresholdOfVoters.call(nextBallotId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProposedValue.call(nextBallotId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType.call(nextBallotId)).should.be.bignumber.equal(2);
|
||||
(await voting.getCreator.call(nextBallotId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(nextBallotId)).should.be.equal("memo");
|
||||
})
|
||||
it('should not let create more ballots than the limit', async () => {
|
||||
const VOTING_START_DATE = moment.utc().add(20, 'seconds').unix();
|
||||
|
@ -167,9 +167,9 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 2, "memo",{from: votingKey});
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 2, "memo",{from: votingKey});
|
||||
// we have 1 validator, so 200 limit / 1 = 200
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(200).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await addValidators({proxyStorageMock, keysManager, poaNetworkConsensusMock}); // add 100 validators, so total will be 101 validator
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator());
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getBallotLimitPerValidator.call());
|
||||
await voting.createBallot(VOTING_START_DATE, VOTING_END_DATE, accounts[5], 2, "memo",{from: votingKey}).should.be.rejectedWith(ERROR_MSG)
|
||||
})
|
||||
})
|
||||
|
@ -183,7 +183,7 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
await proxyStorageMock.setVotingContractMock(accounts[0]);
|
||||
await keysManager.addMiningKey(accounts[1]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(votingKey, accounts[1]).should.be.fulfilled;
|
||||
id = await voting.nextBallotId();
|
||||
id = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], 1, "memo", { from: votingKey }
|
||||
);
|
||||
|
@ -192,9 +192,9 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
it('should let a validator to vote', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const { logs } = await voting.vote(id, choice.accept, { from: votingKey }).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(1);
|
||||
|
@ -204,9 +204,9 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
it('reject vote should be accepted', async () => {
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
const { logs } = await voting.vote(id, choice.reject, { from: votingKey }).should.be.fulfilled;
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(1);
|
||||
logs[0].event.should.be.equal('Vote');
|
||||
logs[0].args.decision.should.be.bignumber.equal(2);
|
||||
|
@ -225,20 +225,20 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
await keysManager.addVotingKey(accounts[4], accounts[2]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.reject, { from: accounts[4] }).should.be.fulfilled;
|
||||
|
||||
let progress = await voting.getProgress(id);
|
||||
let progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-2);
|
||||
|
||||
let totalVoters = await voting.getTotalVoters(id);
|
||||
let totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(2);
|
||||
|
||||
await keysManager.addMiningKey(accounts[3]).should.be.fulfilled;
|
||||
await keysManager.addVotingKey(accounts[5], accounts[3]).should.be.fulfilled;
|
||||
await voting.vote(id, choice.accept, { from: accounts[5] }).should.be.fulfilled;
|
||||
|
||||
progress = await voting.getProgress(id);
|
||||
progress = await voting.getProgress.call(id);
|
||||
progress.should.be.bignumber.equal(-1);
|
||||
|
||||
totalVoters = await voting.getTotalVoters(id);
|
||||
totalVoters = await voting.getTotalVoters.call(id);
|
||||
totalVoters.should.be.bignumber.equal(3);
|
||||
})
|
||||
it('should not let vote nonVoting key', async () => {
|
||||
|
@ -295,7 +295,7 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
it('does not change if it did not pass minimum threshold', async () => {
|
||||
let proposedValue = 5;
|
||||
let contractType = 1; //keysManager
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, accounts[5], contractType, "memo", { from: votingKey }
|
||||
);
|
||||
|
@ -306,28 +306,28 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const { logs } = await voting.finalize(votingId, { from: votingKey }).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, { from: votingKey }).should.be.rejectedWith(ERROR_MSG);
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.equal(accounts[5]);
|
||||
(await voting.getContractType.call(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold(1);
|
||||
const minThresholdOfVoters = await ballotsStorage.getBallotThreshold.call(1);
|
||||
minThresholdOfVoters.should.be.bignumber.equal(3);
|
||||
});
|
||||
|
||||
|
@ -336,61 +336,61 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
let keysManagerNew = await KeysManagerMock.new();
|
||||
let newAddress = keysManagerNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getKeysManager();
|
||||
let eternalProxyAddress = await proxyStorageMock.getKeysManager.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change VotingToChangeKeys implementation', async () => {
|
||||
let contractType = 2;
|
||||
let votingToChangeKeysNew = await VotingForKeys.new();
|
||||
let newAddress = votingToChangeKeysNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeKeys();
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeKeys.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change VotingToChangeMinThreshold implementation', async () => {
|
||||
let contractType = 3;
|
||||
let votingToChangeMinThresholdNew = await VotingForMinThreshold.new();
|
||||
let newAddress = votingToChangeMinThresholdNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeMinThreshold();
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeMinThreshold.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change VotingToChangeProxy implementation', async () => {
|
||||
let contractType = 4;
|
||||
let votingToChangeProxyNew = await VotingToChangeProxyAddress.new();
|
||||
let newAddress = votingToChangeProxyNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeProxy();
|
||||
let eternalProxyAddress = await proxyStorageMock.getVotingToChangeProxy.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change BallotsStorage implementation', async () => {
|
||||
let contractType = 5;
|
||||
let ballotsStorageNew = await BallotsStorage.new();
|
||||
let newAddress = ballotsStorageNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getBallotsStorage();
|
||||
let eternalProxyAddress = await proxyStorageMock.getBallotsStorage.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change ValidatorMetadata implementation', async () => {
|
||||
let contractType = 7;
|
||||
let validatorMetadataNew = await ValidatorMetadata.new();
|
||||
let newAddress = validatorMetadataNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
let eternalProxyAddress = await proxyStorageMock.getValidatorMetadata();
|
||||
let eternalProxyAddress = await proxyStorageMock.getValidatorMetadata.call();
|
||||
let eternalProxy = await EternalStorageProxy.at(eternalProxyAddress);
|
||||
newAddress.should.be.equal(await eternalProxy.implementation());
|
||||
newAddress.should.be.equal(await eternalProxy.implementation.call());
|
||||
})
|
||||
it('should change ProxyStorage implementation', async () => {
|
||||
const contractType = 8;
|
||||
const proxyStorageNew = await ProxyStorageMock.new();
|
||||
const newAddress = proxyStorageNew.address;
|
||||
await deployAndTest({contractType, newAddress})
|
||||
newAddress.should.be.equal(await proxyStorageMock.implementation());
|
||||
newAddress.should.be.equal(await proxyStorageMock.implementation.call());
|
||||
})
|
||||
it('prevents double finalize', async () => {
|
||||
let newAddress1 = accounts[4];
|
||||
|
@ -404,58 +404,58 @@ contract('VotingToChangeProxyAddress upgraded [all features]', function (account
|
|||
VOTING_START_DATE+2, VOTING_END_DATE+2, newAddress2, contractType2, "memo", { from: votingKey }
|
||||
);
|
||||
|
||||
const activeBallotsLength = await voting.activeBallotsLength();
|
||||
votingId = await voting.activeBallots(activeBallotsLength.toNumber() - 2);
|
||||
const activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
votingId = await voting.activeBallots.call(activeBallotsLength.toNumber() - 2);
|
||||
let votingIdForSecond = votingId.add(1);
|
||||
await voting.setTime(VOTING_START_DATE);
|
||||
await voting.vote(votingId, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
false.should.be.equal(await voting.hasAlreadyVoted(votingId, votingKey2));
|
||||
false.should.be.equal(await voting.hasAlreadyVoted.call(votingId, votingKey2));
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey2}).should.be.fulfilled;
|
||||
await voting.vote(votingId, choice.accept, {from: votingKey3}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.fulfilled;
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
await voting.finalize(votingId, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.rejectedWith(ERROR_MSG);
|
||||
false.should.be.equal(await voting.getIsFinalized(votingIdForSecond));
|
||||
false.should.be.equal(await voting.getIsFinalized.call(votingIdForSecond));
|
||||
await voting.vote(votingIdForSecond, choice.reject, {from: votingKey}).should.be.fulfilled;
|
||||
await voting.setTime(VOTING_END_DATE + 3);
|
||||
await voting.finalize(votingIdForSecond, {from: votingKey}).should.be.fulfilled;
|
||||
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress(votingId))
|
||||
new web3.BigNumber(-1).should.be.bignumber.equal(await voting.getProgress.call(votingIdForSecond))
|
||||
new web3.BigNumber(1).should.be.bignumber.equal(await voting.getProgress.call(votingId))
|
||||
|
||||
let startTime = await voting.getStartTime(votingId);
|
||||
let endTime = await voting.getEndTime(votingId);
|
||||
let startTime = await voting.getStartTime.call(votingId);
|
||||
let endTime = await voting.getEndTime.call(votingId);
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingId)).should.be.equal(newAddress1);
|
||||
(await voting.getContractType(votingId)).should.be.bignumber.equal(contractType1);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.equal(newAddress1);
|
||||
(await voting.getContractType.call(votingId)).should.be.bignumber.equal(contractType1);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
startTime = await voting.getStartTime(votingIdForSecond);
|
||||
endTime = await voting.getEndTime(votingIdForSecond);
|
||||
startTime = await voting.getStartTime.call(votingIdForSecond);
|
||||
endTime = await voting.getEndTime.call(votingIdForSecond);
|
||||
startTime.should.be.bignumber.equal(VOTING_START_DATE+2);
|
||||
endTime.should.be.bignumber.equal(VOTING_END_DATE+2);
|
||||
(await voting.getTotalVoters(votingIdForSecond)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress(votingIdForSecond)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized(votingIdForSecond)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingIdForSecond)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex(votingIdForSecond)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingIdForSecond)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingIdForSecond)).should.be.equal(newAddress2);
|
||||
(await voting.getContractType(votingIdForSecond)).should.be.bignumber.equal(contractType2);
|
||||
(await voting.getCreator(votingIdForSecond)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingIdForSecond)).should.be.equal("memo");
|
||||
(await voting.getTotalVoters.call(votingIdForSecond)).should.be.bignumber.equal(1);
|
||||
(await voting.getProgress.call(votingIdForSecond)).should.be.bignumber.equal(-1);
|
||||
(await voting.getIsFinalized.call(votingIdForSecond)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingIdForSecond)).should.be.bignumber.equal(3);
|
||||
(await voting.getIndex.call(votingIdForSecond)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingIdForSecond)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingIdForSecond)).should.be.equal(newAddress2);
|
||||
(await voting.getContractType.call(votingIdForSecond)).should.be.bignumber.equal(contractType2);
|
||||
(await voting.getCreator.call(votingIdForSecond)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingIdForSecond)).should.be.equal("memo");
|
||||
})
|
||||
});
|
||||
})
|
||||
|
@ -464,7 +464,7 @@ async function deployAndTest({
|
|||
contractType,
|
||||
newAddress
|
||||
}) {
|
||||
votingId = await voting.nextBallotId();
|
||||
votingId = await voting.nextBallotId.call();
|
||||
await voting.createBallot(
|
||||
VOTING_START_DATE, VOTING_END_DATE, newAddress, contractType, "memo", { from: votingKey }
|
||||
);
|
||||
|
@ -476,35 +476,35 @@ async function deployAndTest({
|
|||
await voting.setTime(VOTING_END_DATE + 1);
|
||||
const { logs } = await voting.finalize(votingId, { from: votingKey }).should.be.fulfilled;
|
||||
|
||||
activeBallotsLength = await voting.activeBallotsLength();
|
||||
activeBallotsLength = await voting.activeBallotsLength.call();
|
||||
activeBallotsLength.should.be.bignumber.equal(0);
|
||||
true.should.be.equal(await voting.getIsFinalized(votingId));
|
||||
true.should.be.equal(await voting.getIsFinalized.call(votingId));
|
||||
// Finalized(msg.sender);
|
||||
logs[0].event.should.be.equal("BallotFinalized");
|
||||
logs[0].args.voter.should.be.equal(votingKey);
|
||||
|
||||
(await voting.getStartTime(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue(votingId)).should.be.equal(newAddress);
|
||||
(await voting.getContractType(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo(votingId)).should.be.equal("memo");
|
||||
(await voting.getStartTime.call(votingId)).should.be.bignumber.equal(VOTING_START_DATE);
|
||||
(await voting.getEndTime.call(votingId)).should.be.bignumber.equal(VOTING_END_DATE);
|
||||
(await voting.getTotalVoters.call(votingId)).should.be.bignumber.equal(3);
|
||||
(await voting.getProgress.call(votingId)).should.be.bignumber.equal(1);
|
||||
(await voting.getIsFinalized.call(votingId)).should.be.equal(true);
|
||||
(await voting.getQuorumState.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getIndex.call(votingId)).should.be.bignumber.equal(0);
|
||||
(await voting.getMinThresholdOfVoters.call(votingId)).should.be.bignumber.equal(2);
|
||||
(await voting.getProposedValue.call(votingId)).should.be.equal(newAddress);
|
||||
(await voting.getContractType.call(votingId)).should.be.bignumber.equal(contractType);
|
||||
(await voting.getCreator.call(votingId)).should.be.equal(miningKeyForVotingKey);
|
||||
(await voting.getMemo.call(votingId)).should.be.equal("memo");
|
||||
|
||||
if (contractType !== 1) {
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey2)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey2)
|
||||
);
|
||||
true.should.be.equal(
|
||||
await voting.hasAlreadyVoted(votingId, votingKey3)
|
||||
await voting.hasAlreadyVoted.call(votingId, votingKey3)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
mocha: {
|
||||
reporter: 'mochawesome'
|
||||
reporter: 'mochawesome',
|
||||
enableTimeouts: false
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue