Add company fields to ValidatorMetadata
According to https://github.com/poanetwork/poa-network-consensus-contracts/issues/203
This commit is contained in:
parent
31fa251ab0
commit
16226b781b
|
@ -17,10 +17,12 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
bytes32 internal constant PROXY_STORAGE = keccak256("proxyStorage");
|
||||
|
||||
bytes32 internal constant CONFIRMATIONS = "confirmations";
|
||||
bytes32 internal constant CONTACT_EMAIL = "contactEmail";
|
||||
bytes32 internal constant CREATED_DATE = "createdDate";
|
||||
bytes32 internal constant EXPIRATION_DATE = "expirationDate";
|
||||
bytes32 internal constant FIRST_NAME = "firstName";
|
||||
bytes32 internal constant FULL_ADDRESS = "fullAddress";
|
||||
bytes32 internal constant IS_COMPANY = "isCompany";
|
||||
bytes32 internal constant LAST_NAME = "lastName";
|
||||
bytes32 internal constant LICENSE_ID = "licenseId";
|
||||
bytes32 internal constant MIN_THRESHOLD = "minThreshold";
|
||||
|
@ -102,7 +104,9 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
uint256 expirationDate,
|
||||
uint256 createdDate,
|
||||
uint256 updatedDate,
|
||||
uint256 minThreshold
|
||||
uint256 minThreshold,
|
||||
bytes32 contactEmail,
|
||||
bool isCompany
|
||||
) {
|
||||
return _validators(false, _miningKey);
|
||||
}
|
||||
|
@ -117,7 +121,9 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
uint256 expirationDate,
|
||||
uint256 createdDate,
|
||||
uint256 updatedDate,
|
||||
uint256 minThreshold
|
||||
uint256 minThreshold,
|
||||
bytes32 contactEmail,
|
||||
bool isCompany
|
||||
) {
|
||||
return _validators(true, _miningKey);
|
||||
}
|
||||
|
@ -134,7 +140,7 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
return boolStorage[INIT_METADATA_DISABLED];
|
||||
}
|
||||
|
||||
function initMetadata( // used for migration
|
||||
function initMetadata( // used for migration from v1.0 contracts
|
||||
bytes32 _firstName,
|
||||
bytes32 _lastName,
|
||||
bytes32 _licenseId,
|
||||
|
@ -178,7 +184,9 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
string _fullAddress,
|
||||
bytes32 _state,
|
||||
bytes32 _zipcode,
|
||||
uint256 _expirationDate
|
||||
uint256 _expirationDate,
|
||||
bytes32 _contactEmail,
|
||||
bool _isCompany
|
||||
)
|
||||
public
|
||||
onlyValidVotingKey(msg.sender)
|
||||
|
@ -199,6 +207,8 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
0,
|
||||
getMinThreshold()
|
||||
);
|
||||
_setContactEmail(false, miningKey, _contactEmail);
|
||||
_setIsCompany(false, miningKey, _isCompany);
|
||||
emit MetadataCreated(miningKey);
|
||||
}
|
||||
|
||||
|
@ -209,11 +219,12 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
string _fullAddress,
|
||||
bytes32 _state,
|
||||
bytes32 _zipcode,
|
||||
uint256 _expirationDate
|
||||
uint256 _expirationDate,
|
||||
bytes32 _contactEmail,
|
||||
bool _isCompany
|
||||
)
|
||||
public
|
||||
onlyValidVotingKey(msg.sender)
|
||||
returns(bool)
|
||||
{
|
||||
address miningKey = _getKeysManager().getMiningKeyByVoting(msg.sender);
|
||||
_setMetadata(
|
||||
|
@ -230,8 +241,9 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
getTime(),
|
||||
_getMinThreshold(false, miningKey)
|
||||
);
|
||||
_setContactEmail(true, miningKey, _contactEmail);
|
||||
_setIsCompany(true, miningKey, _isCompany);
|
||||
emit ChangeRequestInitiated(miningKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
function cancelPendingChange() public onlyValidVotingKey(msg.sender) returns(bool) {
|
||||
|
@ -294,6 +306,8 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
_setCreatedDate(false, _miningKey, _getCreatedDate(true, _miningKey));
|
||||
_setUpdatedDate(false, _miningKey, _getUpdatedDate(true, _miningKey));
|
||||
_setMinThreshold(false, _miningKey, minThreshold);
|
||||
_setContactEmail(false, _miningKey, _getContactEmail(true, _miningKey));
|
||||
_setIsCompany(false, _miningKey, _getIsCompany(true, _miningKey));
|
||||
_deleteMetadata(true, _miningKey);
|
||||
emit FinalizedChange(_miningKey);
|
||||
}
|
||||
|
@ -314,6 +328,16 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
return IBallotsStorage(IProxyStorage(proxyStorage()).getBallotsStorage());
|
||||
}
|
||||
|
||||
function _getContactEmail(bool _pending, address _miningKey)
|
||||
private
|
||||
view
|
||||
returns(bytes32)
|
||||
{
|
||||
return bytes32Storage[keccak256(abi.encode(
|
||||
_storeName(_pending), _miningKey, CONTACT_EMAIL
|
||||
))];
|
||||
}
|
||||
|
||||
function _getFirstName(bool _pending, address _miningKey)
|
||||
private
|
||||
view
|
||||
|
@ -324,6 +348,16 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
))];
|
||||
}
|
||||
|
||||
function _getIsCompany(bool _pending, address _miningKey)
|
||||
private
|
||||
view
|
||||
returns(bool)
|
||||
{
|
||||
return boolStorage[keccak256(abi.encode(
|
||||
_storeName(_pending), _miningKey, IS_COMPANY
|
||||
))];
|
||||
}
|
||||
|
||||
function _getLastName(bool _pending, address _miningKey)
|
||||
private
|
||||
view
|
||||
|
@ -460,6 +494,8 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
delete uintStorage[keccak256(abi.encode(_store, _miningKey, CREATED_DATE))];
|
||||
delete uintStorage[keccak256(abi.encode(_store, _miningKey, UPDATED_DATE))];
|
||||
delete uintStorage[keccak256(abi.encode(_store, _miningKey, MIN_THRESHOLD))];
|
||||
delete bytes32Storage[keccak256(abi.encode(_store, _miningKey, CONTACT_EMAIL))];
|
||||
delete boolStorage[keccak256(abi.encode(_store, _miningKey, IS_COMPANY))];
|
||||
if (_pending) {
|
||||
_confirmationsVotersClear(_miningKey);
|
||||
}
|
||||
|
@ -480,7 +516,9 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
_getUpdatedDate(_pending, _oldMiningKey),
|
||||
_getMinThreshold(_pending, _oldMiningKey)
|
||||
);
|
||||
|
||||
_setContactEmail(_pending, _newMiningKey, _getContactEmail(_pending, _oldMiningKey));
|
||||
_setIsCompany(_pending, _newMiningKey, _getIsCompany(_pending, _oldMiningKey));
|
||||
|
||||
if (_pending) {
|
||||
_confirmationsVotersCopy(_oldMiningKey, _newMiningKey);
|
||||
}
|
||||
|
@ -488,6 +526,14 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
_deleteMetadata(_pending, _oldMiningKey);
|
||||
}
|
||||
|
||||
function _setContactEmail(bool _pending, address _miningKey, bytes32 _contactEmail) private {
|
||||
bytes32Storage[keccak256(abi.encode(
|
||||
_storeName(_pending),
|
||||
_miningKey,
|
||||
CONTACT_EMAIL
|
||||
))] = _contactEmail;
|
||||
}
|
||||
|
||||
function _setFirstName(bool _pending, address _miningKey, bytes32 _firstName) private {
|
||||
bytes32Storage[keccak256(abi.encode(
|
||||
_storeName(_pending),
|
||||
|
@ -496,6 +542,14 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
))] = _firstName;
|
||||
}
|
||||
|
||||
function _setIsCompany(bool _pending, address _miningKey, bool _isCompany) private {
|
||||
boolStorage[keccak256(abi.encode(
|
||||
_storeName(_pending),
|
||||
_miningKey,
|
||||
IS_COMPANY
|
||||
))] = _isCompany;
|
||||
}
|
||||
|
||||
function _setLastName(bool _pending, address _miningKey, bytes32 _lastName) private {
|
||||
bytes32Storage[keccak256(abi.encode(
|
||||
_storeName(_pending),
|
||||
|
@ -647,7 +701,9 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
uint256 expirationDate,
|
||||
uint256 createdDate,
|
||||
uint256 updatedDate,
|
||||
uint256 minThreshold
|
||||
uint256 minThreshold,
|
||||
bytes32 contactEmail,
|
||||
bool isCompany
|
||||
) {
|
||||
firstName = _getFirstName(_pending, _miningKey);
|
||||
lastName = _getLastName(_pending, _miningKey);
|
||||
|
@ -659,6 +715,8 @@ contract ValidatorMetadata is EternalStorage, EnumThresholdTypes, IValidatorMeta
|
|||
createdDate = _getCreatedDate(_pending, _miningKey);
|
||||
updatedDate = _getUpdatedDate(_pending, _miningKey);
|
||||
minThreshold = _getMinThreshold(_pending, _miningKey);
|
||||
contactEmail = _getContactEmail(_pending, _miningKey);
|
||||
isCompany = _getIsCompany(_pending, _miningKey);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -27,6 +27,11 @@ async function main() {
|
|||
|
||||
for (let i = 0; i < filenames.length; i++) {
|
||||
const filename = filenames[i];
|
||||
|
||||
if (filename.indexOf('.sol') != filename.length - 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const stats = fs.statSync(dir + filename);
|
||||
|
||||
if (stats.isFile()) {
|
||||
|
|
|
@ -21,13 +21,13 @@ let keysManager, poaNetworkConsensusMock;
|
|||
let metadata, metadataEternalStorage;
|
||||
let votingKey, votingKey2, votingKey3, miningKey;
|
||||
let fakeData = [
|
||||
"Djamshut", "Roosvelt", "123asd", "Moskva", "ZZ", "234", 23423
|
||||
"Djamshut", "Roosvelt", "123asd", "Moskva", "ZZ", "234", 23423, "info@poa.net", false
|
||||
];
|
||||
let newMetadata = [
|
||||
"Feodosiy", "Kennedy", "123123", "Petrovka 38", "ZA", "1337", 71
|
||||
"Feodosiy", "Kennedy", "123123", "Petrovka 38", "ZA", "1337", 71, "", false
|
||||
];
|
||||
let anotherData = [
|
||||
"Feodosiy", "Bush", "123123", "Petrovka 38", "ZA", "1337", 71
|
||||
"Feodosiy", "Bush", "123123", "Petrovka 38", "ZA", "1337", 71, "", false
|
||||
];
|
||||
contract('ValidatorMetadata [all features]', function (accounts) {
|
||||
beforeEach(async () => {
|
||||
|
@ -102,7 +102,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal('MetadataCreated');
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -127,7 +129,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
})
|
||||
it('should not let create metadata if called second time', async () => {
|
||||
|
@ -149,7 +153,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal('MetadataCreated');
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -166,7 +172,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -195,7 +203,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey)).should.be.deep.equal([
|
||||
|
@ -208,7 +218,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -226,7 +238,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal('MetadataCreated');
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -243,7 +257,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -263,7 +279,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey2)).should.be.deep.equal([
|
||||
|
@ -276,7 +294,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
|
@ -299,7 +319,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey)).should.be.deep.equal([
|
||||
|
@ -312,7 +334,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
confirmations = await metadata.confirmations.call(miningKey2);
|
||||
|
@ -329,7 +353,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey2)).should.be.deep.equal([
|
||||
|
@ -342,7 +368,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -379,7 +407,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(123),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(3)
|
||||
new web3.BigNumber(3),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
validatorData[7] = 0;
|
||||
|
@ -398,7 +428,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(123),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(3)
|
||||
new web3.BigNumber(3),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
validatorData[10] = miningKey3;
|
||||
|
@ -427,7 +459,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -469,7 +503,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
false
|
||||
]);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
|
@ -482,7 +518,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -504,7 +542,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
|
@ -517,7 +557,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
});
|
||||
})
|
||||
|
@ -581,7 +623,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
|
@ -594,7 +638,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal('FinalizedChange');
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -669,7 +715,9 @@ contract('ValidatorMetadata [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,13 +21,13 @@ let keysManager, poaNetworkConsensusMock;
|
|||
let metadata, metadataEternalStorage;
|
||||
let votingKey, votingKey2, votingKey3, miningKey;
|
||||
let fakeData = [
|
||||
"Djamshut", "Roosvelt", "123asd", "Moskva", "ZZ", "234", 23423
|
||||
"Djamshut", "Roosvelt", "123asd", "Moskva", "ZZ", "234", 23423, "info@poa.net", false
|
||||
];
|
||||
let newMetadata = [
|
||||
"Feodosiy", "Kennedy", "123123", "Petrovka 38", "ZA", "1337", 71
|
||||
"Feodosiy", "Kennedy", "123123", "Petrovka 38", "ZA", "1337", 71, "", false
|
||||
];
|
||||
let anotherData = [
|
||||
"Feodosiy", "Bush", "123123", "Petrovka 38", "ZA", "1337", 71
|
||||
"Feodosiy", "Bush", "123123", "Petrovka 38", "ZA", "1337", 71, "", false
|
||||
];
|
||||
contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
||||
beforeEach(async () => {
|
||||
|
@ -109,7 +109,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal('MetadataCreated');
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -134,7 +136,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
})
|
||||
it('should not let create metadata if called second time', async () => {
|
||||
|
@ -156,7 +160,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal('MetadataCreated');
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -173,7 +179,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -202,7 +210,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey)).should.be.deep.equal([
|
||||
|
@ -215,7 +225,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -233,7 +245,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal('MetadataCreated');
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -250,7 +264,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
result.logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
result.logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -270,7 +286,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey2)).should.be.deep.equal([
|
||||
|
@ -283,7 +301,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
await proxyStorageMock.setKeysManagerMock(accounts[0]);
|
||||
|
@ -306,7 +326,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey)).should.be.deep.equal([
|
||||
|
@ -319,7 +341,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
confirmations = await metadata.confirmations.call(miningKey2);
|
||||
|
@ -336,7 +360,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
|
||||
(await metadata.pendingChanges.call(miningKey2)).should.be.deep.equal([
|
||||
|
@ -349,7 +375,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -386,7 +414,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(123),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(3)
|
||||
new web3.BigNumber(3),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
validatorData[7] = 0;
|
||||
|
@ -405,7 +435,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(123),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(3)
|
||||
new web3.BigNumber(3),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
|
||||
validatorData[10] = miningKey3;
|
||||
|
@ -434,7 +466,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -476,7 +510,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
false
|
||||
]);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
|
@ -489,7 +525,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal("ChangeRequestInitiated");
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -511,7 +549,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
const validators = await metadata.validators.call(miningKey);
|
||||
validators.should.be.deep.equal([
|
||||
|
@ -524,7 +564,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(23423),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex("info@poa.net"),
|
||||
false
|
||||
]);
|
||||
});
|
||||
})
|
||||
|
@ -588,7 +630,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(71),
|
||||
new web3.BigNumber(55555),
|
||||
new web3.BigNumber(4444),
|
||||
new web3.BigNumber(2)
|
||||
new web3.BigNumber(2),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
const pendingChanges = await metadata.pendingChanges.call(miningKey);
|
||||
pendingChanges.should.be.deep.equal([
|
||||
|
@ -601,7 +645,9 @@ contract('ValidatorMetadata upgraded [all features]', function (accounts) {
|
|||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0),
|
||||
new web3.BigNumber(0)
|
||||
new web3.BigNumber(0),
|
||||
toHex(""),
|
||||
false
|
||||
]);
|
||||
logs[0].event.should.be.equal('FinalizedChange');
|
||||
logs[0].args.miningKey.should.be.equal(miningKey);
|
||||
|
@ -636,4 +682,4 @@ async function addMiningKey(_key) {
|
|||
async function addVotingKey(_key, _miningKey) {
|
||||
const {logs} = await keysManager.addVotingKey(_key, _miningKey);
|
||||
logs[0].event.should.be.equal("VotingKeyChanged");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue